33
33
#include < daw/daw_string_view.h>
34
34
35
35
#include " json_to_cpp.h"
36
+ #include < daw/json/daw_json_parser_v2.h>
37
+ #include < daw/json/daw_json_parser.h>
38
+ #include < daw/json/daw_json_value_t.h>
36
39
37
40
namespace daw {
38
41
namespace json_to_cpp {
@@ -167,7 +170,7 @@ namespace daw {
167
170
bool &is_optional ( ) noexcept ;
168
171
bool const &is_optional ( ) const noexcept ;
169
172
170
- std::type_index type ( ) const ;
173
+ size_t type ( ) const ;
171
174
172
175
ti_value ( )
173
176
: value{nullptr } {}
@@ -217,12 +220,12 @@ namespace daw {
217
220
218
221
type_info_t ( ) = default ;
219
222
type_info_t ( type_info_t const & ) = default ;
220
- type_info_t ( type_info_t && ) = default ;
223
+ type_info_t ( type_info_t && ) noexcept = default ;
221
224
type_info_t &operator =( type_info_t const & ) = default ;
222
- type_info_t &operator =( type_info_t && ) = default ;
225
+ type_info_t &operator =( type_info_t && ) noexcept = default ;
223
226
virtual ~type_info_t ( );
224
227
225
- virtual std::type_index type ( ) const = 0;
228
+ virtual size_t type ( ) const = 0;
226
229
virtual std::string name ( ) const = 0;
227
230
228
231
virtual type_info_t *clone ( ) const = 0;
@@ -234,7 +237,7 @@ namespace daw {
234
237
return value->name ( );
235
238
}
236
239
237
- std::type_index ti_value::type ( ) const {
240
+ size_t ti_value::type ( ) const {
238
241
return value->type ( );
239
242
}
240
243
std::map<std::string, ti_value> const &ti_value::children ( ) const {
@@ -254,8 +257,9 @@ namespace daw {
254
257
}
255
258
256
259
struct ti_null : public type_info_t {
257
- std::type_index type ( ) const override {
258
- return std::type_index ( typeid ( daw::json::json_value_t ::null_t ) );
260
+ size_t type ( ) const override {
261
+ return daw::json::json_value_t ::index_of<
262
+ daw::json::json_value_t ::null_t >( );
259
263
}
260
264
261
265
std::string name ( ) const override {
@@ -281,9 +285,9 @@ namespace daw {
281
285
}
282
286
283
287
struct ti_integral : public type_info_t {
284
- std::type_index type ( ) const override {
285
- return std::type_index (
286
- typeid ( daw::json::json_value_t ::integer_t ) );
288
+ size_t type ( ) const override {
289
+ return daw::json:: json_value_t ::index_of<
290
+ daw::json::json_value_t ::integer_t >( );
287
291
}
288
292
289
293
std::string name ( ) const override {
@@ -296,8 +300,9 @@ namespace daw {
296
300
};
297
301
298
302
struct ti_real : public type_info_t {
299
- std::type_index type ( ) const override {
300
- return std::type_index ( typeid ( daw::json::json_value_t ::real_t ) );
303
+ size_t type ( ) const override {
304
+ return daw::json::json_value_t ::index_of<
305
+ daw::json::json_value_t ::real_t >( );
301
306
}
302
307
303
308
std::string name ( ) const override {
@@ -310,9 +315,9 @@ namespace daw {
310
315
};
311
316
312
317
struct ti_boolean : public type_info_t {
313
- std::type_index type ( ) const override {
314
- return std::type_index (
315
- typeid ( daw::json::json_value_t ::boolean_t ) );
318
+ size_t type ( ) const override {
319
+ return daw::json:: json_value_t ::index_of<
320
+ daw::json::json_value_t ::boolean_t >( );
316
321
}
317
322
318
323
std::string name ( ) const override {
@@ -325,9 +330,9 @@ namespace daw {
325
330
};
326
331
327
332
struct ti_string : public type_info_t {
328
- std::type_index type ( ) const override {
329
- return std::type_index (
330
- typeid ( daw::json::json_value_t ::string_t ) );
333
+ size_t type ( ) const override {
334
+ return daw::json:: json_value_t ::index_of<
335
+ daw::json::json_value_t ::string_t >( );
331
336
}
332
337
333
338
std::string name ( ) const override {
@@ -342,9 +347,9 @@ namespace daw {
342
347
struct ti_object : public type_info_t {
343
348
std::string object_name;
344
349
345
- std::type_index type ( ) const override {
346
- return std::type_index (
347
- typeid ( daw::json::json_value_t ::object_t ) );
350
+ size_t type ( ) const override {
351
+ return daw::json:: json_value_t ::index_of<
352
+ daw::json::json_value_t ::object_t >( );
348
353
}
349
354
350
355
std::string name ( ) const override {
@@ -360,9 +365,9 @@ namespace daw {
360
365
};
361
366
362
367
struct ti_array : public type_info_t {
363
- std::type_index type ( ) const override {
364
- return std::type_index (
365
- typeid ( daw::json::json_value_t ::array_t ) );
368
+ size_t type ( ) const override {
369
+ return daw::json:: json_value_t ::index_of<
370
+ daw::json::json_value_t ::array_t >( );
366
371
}
367
372
368
373
std::string name ( ) const override {
@@ -416,7 +421,7 @@ namespace daw {
416
421
using daw::json::json_value_t ;
417
422
types::ti_value result = b;
418
423
static auto const null_type =
419
- std::type_index ( typeid ( daw::json::json_value_t ::null_t ) );
424
+ daw::json:: json_value_t ::index_of< daw::json::json_value_t ::null_t >( );
420
425
if ( null_type == a.type ( ) ) {
421
426
result = b;
422
427
result.is_optional ( ) = true ;
@@ -549,7 +554,7 @@ namespace daw {
549
554
config.header_file ( ) << " #pragma once\n\n " ;
550
555
}
551
556
if ( obj_state.has_optionals )
552
- config.header_file ( ) << " #include <boost/ optional.hpp >\n " ;
557
+ config.header_file ( ) << " #include <optional>\n " ;
553
558
if ( obj_state.has_integrals )
554
559
config.header_file ( ) << " #include <cstdint>\n " ;
555
560
if ( obj_state.has_strings )
@@ -577,7 +582,7 @@ namespace daw {
577
582
auto const &member_type = child.second .name ( );
578
583
config.header_file ( ) << " \t " ;
579
584
if ( child.second .is_optional ( ) ) {
580
- config.header_file ( ) << " boost ::optional<" << member_type << " >" ;
585
+ config.header_file ( ) << " std ::optional<" << member_type << " >" ;
581
586
} else {
582
587
config.header_file ( ) << member_type;
583
588
}
0 commit comments