Skip to content

Commit 76d5979

Browse files
committed
minor changes
1 parent 5cafc5f commit 76d5979

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/json_to_cpp.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,17 @@ namespace daw {
8383
namespace {
8484
struct val_info_t {
8585
std::string name;
86+
bool is_array;
8687
bool is_optional;
8788
daw::json::impl::value_t::value_types type;
89+
std::string type_string;
8890

8991
val_info_t( ):
9092
name{ },
93+
is_array{ false },
9194
is_optional{ false },
92-
type{ daw::json::impl::value_t::value_types::null } { }
95+
type{ daw::json::impl::value_t::value_types::null },
96+
type_string{ "" } { }
9397

9498
}; // val_info_t;
9599

@@ -153,6 +157,7 @@ namespace daw {
153157
switch( val_info.type ) {
154158
case value_t::value_types::array:
155159
obj_state.has_arrays = true;
160+
val_info.is_array = true;
156161
parse_json_array( val_info.name, member.second, obj_info, obj_state );
157162
break;
158163
case value_t::value_types::object:
@@ -164,9 +169,11 @@ namespace daw {
164169
case value_t::value_types::string:
165170
obj_state.has_strings = true;
166171
break;
172+
case value_t::value_types::null:
173+
val_info.is_optional = true;
174+
break;
167175
case value_t::value_types::real:
168176
case value_t::value_types::boolean:
169-
case value_t::value_types::null:
170177
break;
171178
}
172179
}
@@ -188,6 +195,7 @@ namespace daw {
188195
switch( val_info.type ) {
189196
case value_t::value_types::array: {
190197
obj_state.has_arrays = true;
198+
val_info.is_array = true;
191199
for( auto const & item: arry ) {
192200
parse_json_array( val_info.name, item, obj_info, obj_state );
193201
}
@@ -204,9 +212,11 @@ namespace daw {
204212
case value_t::value_types::string:
205213
obj_state.has_strings = true;
206214
break;
215+
case value_t::value_types::null:
216+
val_info.is_optional = true;
217+
break;
207218
case value_t::value_types::real:
208219
case value_t::value_types::boolean:
209-
case value_t::value_types::null:
210220
break;
211221
}
212222

@@ -378,7 +388,11 @@ namespace daw {
378388
if( cur_obj.is_array ) {
379389
ss << "std::vector<";
380390
}
381-
ss << member_type;
391+
if( member.type == daw::json::impl::value_t::value_types::object ) {
392+
ss << member.name << "_t";
393+
} else {
394+
ss << member_type;
395+
}
382396
if( cur_obj.is_array ) {
383397
ss << ">";
384398
}

0 commit comments

Comments
 (0)