// __ _____ _____ _____ // __| | __| | | | JSON for Modern C++ // | | |__ | | | | | | version 3.11.3 // |_____|_____|_____|_|___| https://github.com/nlohmann/json // // SPDX-FileCopyrightText: 2013-2023 Niels Lohmann // SPDX-License-Identifier: MIT #pragma once #include // strlen #include // string #include // forward #include #include NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { inline std::size_t concat_length() { return 0; } template inline std::size_t concat_length(const char* cstr, const Args&... rest); template inline std::size_t concat_length(const StringType& str, const Args&... rest); template inline std::size_t concat_length(const char /*c*/, const Args&... rest) { return 1 + concat_length(rest...); } template inline std::size_t concat_length(const char* cstr, const Args&... rest) { // cppcheck-suppress ignoredReturnValue return ::strlen(cstr) + concat_length(rest...); } template inline std::size_t concat_length(const StringType& str, const Args&... rest) { return str.size() + concat_length(rest...); } template inline void concat_into(OutStringType& /*out*/) {} template using string_can_append = decltype(std::declval().append(std::declval())); template using detect_string_can_append = is_detected; template using string_can_append_op = decltype(std::declval() += std::declval()); template using detect_string_can_append_op = is_detected; template using string_can_append_iter = decltype(std::declval().append(std::declval().begin(), std::declval().end())); template using detect_string_can_append_iter = is_detected; template using string_can_append_data = decltype(std::declval().append(std::declval().data(), std::declval().size())); template using detect_string_can_append_data = is_detected; template::value && detect_string_can_append_op::value, int> = 0> inline void concat_into(OutStringType& out, Arg&& arg, Args&&... rest); template::value && !detect_string_can_append_op::value && detect_string_can_append_iter::value, int> = 0> inline void concat_into(OutStringType& out, const Arg& arg, Args&&... rest); template::value && !detect_string_can_append_op::value && !detect_string_can_append_iter::value && detect_string_can_append_data::value, int> = 0> inline void concat_into(OutStringType& out, const Arg& arg, Args&&... rest); template::value, int> = 0> inline void concat_into(OutStringType& out, Arg&& arg, Args&&... rest) { out.append(std::forward(arg)); concat_into(out, std::forward(rest)...); } template::value && detect_string_can_append_op::value, int>> inline void concat_into(OutStringType& out, Arg&& arg, Args&&... rest) { out += std::forward(arg); concat_into(out, std::forward(rest)...); } template::value && !detect_string_can_append_op::value && detect_string_can_append_iter::value, int>> inline void concat_into(OutStringType& out, const Arg& arg, Args&&... rest) { out.append(arg.begin(), arg.end()); concat_into(out, std::forward(rest)...); } template::value && !detect_string_can_append_op::value && !detect_string_can_append_iter::value && detect_string_can_append_data::value, int>> inline void concat_into(OutStringType& out, const Arg& arg, Args&&... rest) { out.append(arg.data(), arg.size()); concat_into(out, std::forward(rest)...); } template inline OutStringType concat(Args&&... args) { OutStringType str; str.reserve(concat_length(args...)); concat_into(str, std::forward(args)...); return str; } } // namespace detail NLOHMANN_JSON_NAMESPACE_END