Skip to content

Commit 3471ef5

Browse files
committed
.
1 parent 4fbc84a commit 3471ef5

File tree

14 files changed

+62
-108
lines changed

14 files changed

+62
-108
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ set( HEADER_FILES
6868
set( SOURCE_FILES
6969
${SOURCE_FOLDER}/curl_t.cpp
7070
${SOURCE_FOLDER}/json_to_cpp.cpp
71-
${SOURCE_FOLDER}/ti_value.cpp
7271
${SOURCE_FOLDER}/ti_array.cpp
7372
${SOURCE_FOLDER}/ti_object.cpp
7473
)

dependent_projects/CMakeListsCompiler.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ if( ${CMAKE_CXX_COMPILER_ID} STREQUAL 'MSVC' )
44
add_definitions( -DNOMINMAX -DD_WIN32_WINNT=0x0601 )
55
else( )
66
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang" )
7-
add_compile_options( -march=native -ffast-math -ftemplate-backtrace-limit=0 -Wall -Wextra -pedantic -Weverything -Wno-c++98-compat -Wno-covered-switch-default -Wnull-dereference -Wno-padded -Wno-exit-time-destructors -Wno-c++98-compat-pedantic -Wno-unused-parameter -Wno-missing-noreturn -Wno-missing-prototypes -Wno-disabled-macro-expansion -Wno-missing-braces -Wno-return-std-move-in-c++11 )
7+
add_compile_options( -march=native -ffast-math -ftemplate-backtrace-limit=0 -Wall -Wextra -pedantic -Weverything -Wno-c++98-compat -Wno-covered-switch-default -Wnull-dereference -Wno-padded -Wno-exit-time-destructors -Wno-c++98-compat-pedantic -Wno-missing-prototypes -Wno-disabled-macro-expansion -Wno-return-std-move-in-c++11 )
8+
#add_compile_options( -march=native -ffast-math -ftemplate-backtrace-limit=0 -Wall -Wextra -pedantic -Weverything -Wno-c++98-compat -Wno-covered-switch-default -Wnull-dereference -Wno-padded -Wno-exit-time-destructors -Wno-c++98-compat-pedantic -Wno-unused-parameter -Wno-missing-noreturn -Wno-missing-prototypes -Wno-disabled-macro-expansion -Wno-missing-braces -Wno-return-std-move-in-c++11 )
89
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -DDEBUG -fsanitize=undefined")
910
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g -DNDEBUG")
1011
elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" )

include/ti_array.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace daw::json_to_cpp::types {
6262
}
6363

6464
std::string name( ) const;
65-
std::string json_name( std::string member_name ) const;
65+
std::string json_name( daw::string_view member_name ) const;
6666
std::string array_member_info( ) const;
6767
};
6868
} // namespace daw::json_to_cpp::types

include/ti_boolean.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ namespace daw::json_to_cpp::types {
5151

5252
inline static std::string
5353
json_name( daw::string_view member_name ) noexcept {
54-
5554
return "json_bool<" + member_name + ">";
5655
}
5756
};

include/ti_integral.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace daw::json_to_cpp::types {
4949
return "json_number<no_name, int64_t>";
5050
}
5151

52-
inline static std::string json_name( std::string member_name ) noexcept {
52+
inline static std::string json_name( daw::string_view member_name ) noexcept {
5353
return "json_number<" + member_name + ", intmax_t>";
5454
}
5555
};

include/ti_null.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace daw::json_to_cpp::types {
4949
return "json_custom<no_name>";
5050
}
5151

52-
inline static std::string json_name( std::string member_name ) noexcept {
52+
inline static std::string json_name( daw::string_view member_name ) noexcept {
5353
return "json_custom<" + member_name + ">";
5454
}
5555
};

include/ti_object.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ namespace daw::json_to_cpp::types {
6464

6565
std::string name( ) const;
6666
std::string array_member_info( ) const;
67-
std::string json_name( std::string member_name ) const;
67+
68+
std::string json_name( daw::string_view member_name ) const {
69+
return "json_class<" + member_name + ", " + name( ) + ">";
70+
}
6871
};
6972
} // namespace daw::json_to_cpp::types

include/ti_real.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace daw::json_to_cpp::types {
4949
return "json_number<no_name>";
5050
}
5151

52-
inline static std::string json_name( std::string member_name ) noexcept {
52+
inline static std::string json_name( daw::string_view member_name ) noexcept {
5353
return "json_number<" + member_name + ">";
5454
}
5555
};

include/ti_string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace daw::json_to_cpp::types {
5858
return "json_string<no_name>";
5959
}
6060

61-
inline std::string json_name( std::string member_name ) const noexcept {
61+
inline std::string json_name( daw::string_view member_name ) const noexcept {
6262
if( m_use_string_view ) {
6363
return "json_string<" + member_name + ", std::string_view>";
6464
}

include/ti_value.h

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,51 @@ namespace daw::json_to_cpp::types {
5252
return *this;
5353
}
5454

55-
std::string name( ) const noexcept;
56-
std::string json_name( std::string member_name ) const noexcept;
57-
std::string array_member_info( ) const;
55+
inline std::string name( ) const noexcept {
56+
return daw::visit_nt( value,
57+
[]( auto const &item ) { return item.name( ); } );
58+
}
59+
60+
inline std::string json_name( std::string member_name ) const noexcept {
61+
return daw::visit_nt( value, [&member_name]( auto const &item ) {
62+
return item.json_name( member_name );
63+
} );
64+
}
5865

59-
daw::ordered_map<std::string, ti_types_t> const &children( ) const;
60-
daw::ordered_map<std::string, ti_types_t> &children( );
66+
inline std::string array_member_info( ) const {
67+
return daw::visit_nt(
68+
value, []( auto const &item ) { return item.array_member_info( ); } );
69+
}
6170

71+
inline daw::ordered_map<std::string, ti_types_t> const &children( ) const {
72+
return daw::visit_nt(
73+
value,
74+
[]( ti_array const &v )
75+
-> daw::ordered_map<std::string, ti_types_t> const & {
76+
return *v.children;
77+
},
78+
[]( ti_object const &v )
79+
-> daw::ordered_map<std::string, ti_types_t> const & {
80+
return *v.children;
81+
},
82+
[]( ... ) -> daw::ordered_map<std::string, ti_types_t> const & {
83+
std::terminate( );
84+
} );
85+
}
86+
87+
inline daw::ordered_map<std::string, ti_types_t> &children( ) {
88+
return daw::visit_nt(
89+
value,
90+
[]( ti_array &v ) -> daw::ordered_map<std::string, ti_types_t> & {
91+
return *v.children;
92+
},
93+
[]( ti_object &v ) -> daw::ordered_map<std::string, ti_types_t> & {
94+
return *v.children;
95+
},
96+
[]( ... ) -> daw::ordered_map<std::string, ti_types_t> & {
97+
std::terminate( );
98+
} );
99+
}
62100
template<typename Function>
63101
constexpr void on_children( Function ) const {}
64102

0 commit comments

Comments
 (0)