@@ -23,7 +23,6 @@ SOFTWARE.
2323*/
2424
2525
26-
2726#include " json2cpp.hpp"
2827#include < fstream>
2928
@@ -36,13 +35,12 @@ std::string compile(const nlohmann::json &value, std::size_t &obj_count, std::ve
3635 if (value.is_object ()) {
3736 std::vector<std::string> pairs;
3837 for (auto itr = value.begin (); itr != value.end (); ++itr) {
39- pairs.push_back (fmt::format (
40- " value_pair_t{{{}, {{{}}}}}," , json_string (itr.key ()), compile (*itr, obj_count, lines)));
38+ pairs.push_back (
39+ fmt::format ( " value_pair_t{{{}, {{{}}}}}," , json_string (itr.key ()), compile (*itr, obj_count, lines)));
4140 }
4241
43- lines.push_back (fmt::format (" inline constexpr std::array<value_pair_t, {}> object_data_{} = {{" ,
44- pairs.size (),
45- current_object_number));
42+ lines.push_back (fmt::format (
43+ " inline constexpr std::array<value_pair_t, {}> object_data_{} = {{" , pairs.size (), current_object_number));
4644
4745 std::transform (pairs.begin (), pairs.end (), std::back_inserter (lines), [](const auto &pair) {
4846 return fmt::format (" {}" , pair);
@@ -58,9 +56,8 @@ std::string compile(const nlohmann::json &value, std::size_t &obj_count, std::ve
5856 });
5957
6058
61- lines.push_back (fmt::format (" inline constexpr std::array<json, {}> object_data_{} = {{{{" ,
62- entries.size (),
63- current_object_number));
59+ lines.push_back (fmt::format (
60+ " inline constexpr std::array<json, {}> object_data_{} = {{{{" , entries.size (), current_object_number));
6461
6562 std::transform (entries.begin (), entries.end (), std::back_inserter (lines), [](const auto &entry) {
6663 return fmt::format (" {}" , entry);
@@ -112,8 +109,7 @@ compile_results compile(const std::string_view document_name, const nlohmann::js
112109
113110 results.impl .emplace_back (" #include <json2cpp/json2cpp.hpp>" );
114111
115- results.impl .push_back (
116- fmt::format (R"(
112+ results.impl .push_back (fmt::format (R"(
117113namespace compiled_json::{}::impl {{
118114
119115using json = json2cpp::basic_json<char>;
@@ -123,7 +119,8 @@ using array_t=json2cpp::basic_array_t<char>;
123119using object_t=json2cpp::basic_object_t<char>;
124120using value_pair_t=json2cpp::basic_value_pair_t<char>;
125121
126- )" , document_name));
122+ )" ,
123+ document_name));
127124
128125
129126 const auto last_obj_name = compile (json, obj_count, results.impl );
@@ -136,7 +133,8 @@ inline constexpr auto document = json{{{{{}}}}};
136133
137134#endif
138135
139- )" , last_obj_name));
136+ )" ,
137+ last_obj_name));
140138
141139
142140 spdlog::info (" {} JSON objects processed." , obj_count);
@@ -178,7 +176,10 @@ void write_compilation([[maybe_unused]] std::string_view document_name,
178176
179177 std::ofstream cpp (cpp_name);
180178 cpp << fmt::format (" #include \" {}\"\n " , impl_name.filename ().string ());
181- cpp << fmt::format (" namespace compiled_json::{} {{\n const json2cpp::json &get() {{ return compiled_json::{}::impl::document; }}\n }}\n " , document_name, document_name);
179+ cpp << fmt::format (
180+ " namespace compiled_json::{} {{\n const json2cpp::json &get() {{ return compiled_json::{}::impl::document; }}\n }}\n " ,
181+ document_name,
182+ document_name);
182183}
183184
184185void compile_to (const std::string_view document_name,
0 commit comments