From 758c4addc1c6a010a3e9f3730419f9dfae9cd769 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 9 Mar 2017 18:20:26 +0100 Subject: [PATCH 01/14] :ambulance: fix for #492 The original test case relied on an invalidated iterator. This error did not occur before, but only with GCC with -D_GLIBCXX_DEBUG. This commit fixes the test case. The library is unaffected by this change. --- test/src/unit-modifiers.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/src/unit-modifiers.cpp b/test/src/unit-modifiers.cpp index 0edc9a12..2b5fdd71 100644 --- a/test/src/unit-modifiers.cpp +++ b/test/src/unit-modifiers.cpp @@ -583,10 +583,11 @@ TEST_CASE("modifiers") SECTION("insert nothing (count = 0)") { - auto pos = j_array.end(); auto it = j_array.insert(j_array.end(), 0, 5); CHECK(j_array.size() == 4); - CHECK(it == pos); + // the returned iterator points to the first inserted element; + // there were 4 elements, so it should point to the 5th + CHECK(it == j_array.begin() + 4); CHECK(j_array == json({1, 2, 3, 4})); } } From 9cfb777b654fbd96535e96069bc36f7bf92f476a Mon Sep 17 00:00:00 2001 From: Ted Lyngmo Date: Sat, 11 Mar 2017 13:56:38 +0100 Subject: [PATCH 02/14] Fix -Weffc++ warnings (GNU 6.3.1) --- src/json.hpp | 1156 +++++++++++------------------------------ src/json.hpp.re2c | 15 + test/src/unit-udt.cpp | 13 + 3 files changed, 340 insertions(+), 844 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index ff0ce5ad..f2e02628 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -6168,6 +6168,21 @@ class basic_json thousands_sep(!loc->thousands_sep ? '\0' : loc->thousands_sep[0]), decimal_point(!loc->decimal_point ? '\0' : loc->decimal_point[0]) {} + serializer(const serializer& cpy) + : o(cpy.o), + thousands_sep(cpy.thousands_sep), + decimal_point(cpy.decimal_point), + loc(cpy.loc), + indent_string(cpy.indent_string) + {} + serializer& operator=(const serializer& rhs) { + o = rhs.o; + thousands_sep = rhs.thousands_sep; + decimal_point = rhs.decimal_point; + loc = rhs.loc; + indent_string = rhs.indent_string; + return *this; + } /*! @brief internal implementation of the serialization function @@ -9859,12 +9874,11 @@ class basic_json { lexer_char_t yych; unsigned int yyaccept = 0; - static const unsigned char yybm[] = - { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 32, 32, 0, 0, 32, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + static const unsigned char yybm[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 32, 32, 0, 0, 32, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 160, 128, 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 192, 192, 192, 192, 192, 192, 192, 192, @@ -9877,1012 +9891,466 @@ class basic_json 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, }; - if ((m_limit - m_cursor) < 5) - { - fill_line_buffer(5); // LCOV_EXCL_LINE - } + if ((m_limit - m_cursor) < 5) fill_line_buffer(5); // LCOV_EXCL_LINE yych = *m_cursor; - if (yybm[0 + yych] & 32) - { + if (yybm[0+yych] & 32) { goto basic_json_parser_6; } - if (yych <= '[') - { - if (yych <= '-') - { - if (yych <= '"') - { - if (yych <= 0x00) - { - goto basic_json_parser_2; - } - if (yych <= '!') - { - goto basic_json_parser_4; - } + if (yych <= '[') { + if (yych <= '-') { + if (yych <= '"') { + if (yych <= 0x00) goto basic_json_parser_2; + if (yych <= '!') goto basic_json_parser_4; goto basic_json_parser_9; - } - else - { - if (yych <= '+') - { - goto basic_json_parser_4; - } - if (yych <= ',') - { - goto basic_json_parser_10; - } + } else { + if (yych <= '+') goto basic_json_parser_4; + if (yych <= ',') goto basic_json_parser_10; goto basic_json_parser_12; } - } - else - { - if (yych <= '9') - { - if (yych <= '/') - { - goto basic_json_parser_4; - } - if (yych <= '0') - { - goto basic_json_parser_13; - } + } else { + if (yych <= '9') { + if (yych <= '/') goto basic_json_parser_4; + if (yych <= '0') goto basic_json_parser_13; goto basic_json_parser_15; - } - else - { - if (yych <= ':') - { - goto basic_json_parser_17; - } - if (yych <= 'Z') - { - goto basic_json_parser_4; - } + } else { + if (yych <= ':') goto basic_json_parser_17; + if (yych <= 'Z') goto basic_json_parser_4; goto basic_json_parser_19; } } - } - else - { - if (yych <= 'n') - { - if (yych <= 'e') - { - if (yych == ']') - { - goto basic_json_parser_21; - } + } else { + if (yych <= 'n') { + if (yych <= 'e') { + if (yych == ']') goto basic_json_parser_21; goto basic_json_parser_4; - } - else - { - if (yych <= 'f') - { - goto basic_json_parser_23; - } - if (yych <= 'm') - { - goto basic_json_parser_4; - } + } else { + if (yych <= 'f') goto basic_json_parser_23; + if (yych <= 'm') goto basic_json_parser_4; goto basic_json_parser_24; } - } - else - { - if (yych <= 'z') - { - if (yych == 't') - { - goto basic_json_parser_25; - } + } else { + if (yych <= 'z') { + if (yych == 't') goto basic_json_parser_25; goto basic_json_parser_4; - } - else - { - if (yych <= '{') - { - goto basic_json_parser_26; - } - if (yych == '}') - { - goto basic_json_parser_28; - } + } else { + if (yych <= '{') goto basic_json_parser_26; + if (yych == '}') goto basic_json_parser_28; goto basic_json_parser_4; } } } -basic_json_parser_2: + basic_json_parser_2: ++m_cursor; - { - last_token_type = token_type::end_of_input; - break; - } -basic_json_parser_4: + { last_token_type = token_type::end_of_input; break; } + basic_json_parser_4: ++m_cursor; -basic_json_parser_5: - { - last_token_type = token_type::parse_error; - break; - } -basic_json_parser_6: + basic_json_parser_5: + { last_token_type = token_type::parse_error; break; } + basic_json_parser_6: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yybm[0 + yych] & 32) - { + if (yybm[0+yych] & 32) { goto basic_json_parser_6; } - { - continue; - } -basic_json_parser_9: + { continue; } + basic_json_parser_9: yyaccept = 0; yych = *(m_marker = ++m_cursor); - if (yych <= 0x1F) - { - goto basic_json_parser_5; - } - if (yych <= 0x7F) - { - goto basic_json_parser_31; - } - if (yych <= 0xC1) - { - goto basic_json_parser_5; - } - if (yych <= 0xF4) - { - goto basic_json_parser_31; - } + if (yych <= 0x1F) goto basic_json_parser_5; + if (yych <= 0x7F) goto basic_json_parser_31; + if (yych <= 0xC1) goto basic_json_parser_5; + if (yych <= 0xF4) goto basic_json_parser_31; goto basic_json_parser_5; -basic_json_parser_10: + basic_json_parser_10: ++m_cursor; - { - last_token_type = token_type::value_separator; - break; - } -basic_json_parser_12: + { last_token_type = token_type::value_separator; break; } + basic_json_parser_12: yych = *++m_cursor; - if (yych <= '/') - { - goto basic_json_parser_5; - } - if (yych <= '0') - { - goto basic_json_parser_43; - } - if (yych <= '9') - { - goto basic_json_parser_45; - } + if (yych <= '/') goto basic_json_parser_5; + if (yych <= '0') goto basic_json_parser_43; + if (yych <= '9') goto basic_json_parser_45; goto basic_json_parser_5; -basic_json_parser_13: + basic_json_parser_13: yyaccept = 1; yych = *(m_marker = ++m_cursor); - if (yych <= '9') - { - if (yych == '.') - { - goto basic_json_parser_47; - } - if (yych >= '0') - { - goto basic_json_parser_48; + if (yych <= '9') { + if (yych == '.') goto basic_json_parser_47; + if (yych >= '0') goto basic_json_parser_48; + } else { + if (yych <= 'E') { + if (yych >= 'E') goto basic_json_parser_51; + } else { + if (yych == 'e') goto basic_json_parser_51; } } - else - { - if (yych <= 'E') - { - if (yych >= 'E') - { - goto basic_json_parser_51; - } - } - else - { - if (yych == 'e') - { - goto basic_json_parser_51; - } - } - } -basic_json_parser_14: - { - last_token_type = token_type::value_unsigned; - break; - } -basic_json_parser_15: + basic_json_parser_14: + { last_token_type = token_type::value_unsigned; break; } + basic_json_parser_15: yyaccept = 1; m_marker = ++m_cursor; - if ((m_limit - m_cursor) < 3) - { - fill_line_buffer(3); // LCOV_EXCL_LINE - } + if ((m_limit - m_cursor) < 3) fill_line_buffer(3); // LCOV_EXCL_LINE yych = *m_cursor; - if (yybm[0 + yych] & 64) - { + if (yybm[0+yych] & 64) { goto basic_json_parser_15; } - if (yych <= 'D') - { - if (yych == '.') - { - goto basic_json_parser_47; - } + if (yych <= 'D') { + if (yych == '.') goto basic_json_parser_47; + goto basic_json_parser_14; + } else { + if (yych <= 'E') goto basic_json_parser_51; + if (yych == 'e') goto basic_json_parser_51; goto basic_json_parser_14; } - else - { - if (yych <= 'E') - { - goto basic_json_parser_51; - } - if (yych == 'e') - { - goto basic_json_parser_51; - } - goto basic_json_parser_14; - } -basic_json_parser_17: + basic_json_parser_17: ++m_cursor; - { - last_token_type = token_type::name_separator; - break; - } -basic_json_parser_19: + { last_token_type = token_type::name_separator; break; } + basic_json_parser_19: ++m_cursor; - { - last_token_type = token_type::begin_array; - break; - } -basic_json_parser_21: + { last_token_type = token_type::begin_array; break; } + basic_json_parser_21: ++m_cursor; - { - last_token_type = token_type::end_array; - break; - } -basic_json_parser_23: + { last_token_type = token_type::end_array; break; } + basic_json_parser_23: yyaccept = 0; yych = *(m_marker = ++m_cursor); - if (yych == 'a') - { - goto basic_json_parser_52; - } + if (yych == 'a') goto basic_json_parser_52; goto basic_json_parser_5; -basic_json_parser_24: + basic_json_parser_24: yyaccept = 0; yych = *(m_marker = ++m_cursor); - if (yych == 'u') - { - goto basic_json_parser_53; - } + if (yych == 'u') goto basic_json_parser_53; goto basic_json_parser_5; -basic_json_parser_25: + basic_json_parser_25: yyaccept = 0; yych = *(m_marker = ++m_cursor); - if (yych == 'r') - { - goto basic_json_parser_54; - } + if (yych == 'r') goto basic_json_parser_54; goto basic_json_parser_5; -basic_json_parser_26: + basic_json_parser_26: ++m_cursor; - { - last_token_type = token_type::begin_object; - break; - } -basic_json_parser_28: + { last_token_type = token_type::begin_object; break; } + basic_json_parser_28: ++m_cursor; - { - last_token_type = token_type::end_object; - break; - } -basic_json_parser_30: + { last_token_type = token_type::end_object; break; } + basic_json_parser_30: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; -basic_json_parser_31: - if (yybm[0 + yych] & 128) - { + basic_json_parser_31: + if (yybm[0+yych] & 128) { goto basic_json_parser_30; } - if (yych <= 0xE0) - { - if (yych <= '\\') - { - if (yych <= 0x1F) - { - goto basic_json_parser_32; - } - if (yych <= '"') - { - goto basic_json_parser_33; - } + if (yych <= 0xE0) { + if (yych <= '\\') { + if (yych <= 0x1F) goto basic_json_parser_32; + if (yych <= '"') goto basic_json_parser_33; goto basic_json_parser_35; - } - else - { - if (yych <= 0xC1) - { - goto basic_json_parser_32; - } - if (yych <= 0xDF) - { - goto basic_json_parser_36; - } + } else { + if (yych <= 0xC1) goto basic_json_parser_32; + if (yych <= 0xDF) goto basic_json_parser_36; goto basic_json_parser_37; } - } - else - { - if (yych <= 0xEF) - { - if (yych == 0xED) - { - goto basic_json_parser_39; - } + } else { + if (yych <= 0xEF) { + if (yych == 0xED) goto basic_json_parser_39; goto basic_json_parser_38; - } - else - { - if (yych <= 0xF0) - { - goto basic_json_parser_40; - } - if (yych <= 0xF3) - { - goto basic_json_parser_41; - } - if (yych <= 0xF4) - { - goto basic_json_parser_42; - } + } else { + if (yych <= 0xF0) goto basic_json_parser_40; + if (yych <= 0xF3) goto basic_json_parser_41; + if (yych <= 0xF4) goto basic_json_parser_42; } } -basic_json_parser_32: + basic_json_parser_32: m_cursor = m_marker; - if (yyaccept <= 1) - { - if (yyaccept == 0) - { + if (yyaccept <= 1) { + if (yyaccept == 0) { goto basic_json_parser_5; - } - else - { + } else { goto basic_json_parser_14; } - } - else - { - if (yyaccept == 2) - { + } else { + if (yyaccept == 2) { goto basic_json_parser_44; - } - else - { + } else { goto basic_json_parser_58; } } -basic_json_parser_33: + basic_json_parser_33: ++m_cursor; - { - last_token_type = token_type::value_string; - break; - } -basic_json_parser_35: + { last_token_type = token_type::value_string; break; } + basic_json_parser_35: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= 'e') - { - if (yych <= '/') - { - if (yych == '"') - { - goto basic_json_parser_30; - } - if (yych <= '.') - { - goto basic_json_parser_32; - } + if (yych <= 'e') { + if (yych <= '/') { + if (yych == '"') goto basic_json_parser_30; + if (yych <= '.') goto basic_json_parser_32; goto basic_json_parser_30; - } - else - { - if (yych <= '\\') - { - if (yych <= '[') - { - goto basic_json_parser_32; - } + } else { + if (yych <= '\\') { + if (yych <= '[') goto basic_json_parser_32; goto basic_json_parser_30; - } - else - { - if (yych == 'b') - { - goto basic_json_parser_30; - } + } else { + if (yych == 'b') goto basic_json_parser_30; goto basic_json_parser_32; } } - } - else - { - if (yych <= 'q') - { - if (yych <= 'f') - { - goto basic_json_parser_30; - } - if (yych == 'n') - { - goto basic_json_parser_30; - } + } else { + if (yych <= 'q') { + if (yych <= 'f') goto basic_json_parser_30; + if (yych == 'n') goto basic_json_parser_30; goto basic_json_parser_32; - } - else - { - if (yych <= 's') - { - if (yych <= 'r') - { - goto basic_json_parser_30; - } + } else { + if (yych <= 's') { + if (yych <= 'r') goto basic_json_parser_30; goto basic_json_parser_32; - } - else - { - if (yych <= 't') - { - goto basic_json_parser_30; - } - if (yych <= 'u') - { - goto basic_json_parser_55; - } + } else { + if (yych <= 't') goto basic_json_parser_30; + if (yych <= 'u') goto basic_json_parser_55; goto basic_json_parser_32; } } } -basic_json_parser_36: + basic_json_parser_36: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= 0x7F) - { - goto basic_json_parser_32; - } - if (yych <= 0xBF) - { - goto basic_json_parser_30; - } + if (yych <= 0x7F) goto basic_json_parser_32; + if (yych <= 0xBF) goto basic_json_parser_30; goto basic_json_parser_32; -basic_json_parser_37: + basic_json_parser_37: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= 0x9F) - { - goto basic_json_parser_32; - } - if (yych <= 0xBF) - { - goto basic_json_parser_36; - } + if (yych <= 0x9F) goto basic_json_parser_32; + if (yych <= 0xBF) goto basic_json_parser_36; goto basic_json_parser_32; -basic_json_parser_38: + basic_json_parser_38: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= 0x7F) - { - goto basic_json_parser_32; - } - if (yych <= 0xBF) - { - goto basic_json_parser_36; - } + if (yych <= 0x7F) goto basic_json_parser_32; + if (yych <= 0xBF) goto basic_json_parser_36; goto basic_json_parser_32; -basic_json_parser_39: + basic_json_parser_39: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= 0x7F) - { - goto basic_json_parser_32; - } - if (yych <= 0x9F) - { - goto basic_json_parser_36; - } + if (yych <= 0x7F) goto basic_json_parser_32; + if (yych <= 0x9F) goto basic_json_parser_36; goto basic_json_parser_32; -basic_json_parser_40: + basic_json_parser_40: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= 0x8F) - { - goto basic_json_parser_32; - } - if (yych <= 0xBF) - { - goto basic_json_parser_38; - } + if (yych <= 0x8F) goto basic_json_parser_32; + if (yych <= 0xBF) goto basic_json_parser_38; goto basic_json_parser_32; -basic_json_parser_41: + basic_json_parser_41: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= 0x7F) - { - goto basic_json_parser_32; - } - if (yych <= 0xBF) - { - goto basic_json_parser_38; - } + if (yych <= 0x7F) goto basic_json_parser_32; + if (yych <= 0xBF) goto basic_json_parser_38; goto basic_json_parser_32; -basic_json_parser_42: + basic_json_parser_42: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= 0x7F) - { - goto basic_json_parser_32; - } - if (yych <= 0x8F) - { - goto basic_json_parser_38; - } + if (yych <= 0x7F) goto basic_json_parser_32; + if (yych <= 0x8F) goto basic_json_parser_38; goto basic_json_parser_32; -basic_json_parser_43: + basic_json_parser_43: yyaccept = 2; yych = *(m_marker = ++m_cursor); - if (yych <= '9') - { - if (yych == '.') - { - goto basic_json_parser_47; - } - if (yych >= '0') - { - goto basic_json_parser_48; + if (yych <= '9') { + if (yych == '.') goto basic_json_parser_47; + if (yych >= '0') goto basic_json_parser_48; + } else { + if (yych <= 'E') { + if (yych >= 'E') goto basic_json_parser_51; + } else { + if (yych == 'e') goto basic_json_parser_51; } } - else - { - if (yych <= 'E') - { - if (yych >= 'E') - { - goto basic_json_parser_51; - } - } - else - { - if (yych == 'e') - { - goto basic_json_parser_51; - } - } - } -basic_json_parser_44: - { - last_token_type = token_type::value_integer; - break; - } -basic_json_parser_45: + basic_json_parser_44: + { last_token_type = token_type::value_integer; break; } + basic_json_parser_45: yyaccept = 2; m_marker = ++m_cursor; - if ((m_limit - m_cursor) < 3) - { - fill_line_buffer(3); // LCOV_EXCL_LINE - } + if ((m_limit - m_cursor) < 3) fill_line_buffer(3); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= '9') - { - if (yych == '.') - { - goto basic_json_parser_47; - } - if (yych <= '/') - { - goto basic_json_parser_44; - } + if (yych <= '9') { + if (yych == '.') goto basic_json_parser_47; + if (yych <= '/') goto basic_json_parser_44; goto basic_json_parser_45; - } - else - { - if (yych <= 'E') - { - if (yych <= 'D') - { - goto basic_json_parser_44; - } + } else { + if (yych <= 'E') { + if (yych <= 'D') goto basic_json_parser_44; goto basic_json_parser_51; - } - else - { - if (yych == 'e') - { - goto basic_json_parser_51; - } + } else { + if (yych == 'e') goto basic_json_parser_51; goto basic_json_parser_44; } } -basic_json_parser_47: + basic_json_parser_47: yych = *++m_cursor; - if (yych <= '/') - { - goto basic_json_parser_32; - } - if (yych <= '9') - { - goto basic_json_parser_56; - } + if (yych <= '/') goto basic_json_parser_32; + if (yych <= '9') goto basic_json_parser_56; goto basic_json_parser_32; -basic_json_parser_48: + basic_json_parser_48: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= '/') - { - goto basic_json_parser_50; - } - if (yych <= '9') - { - goto basic_json_parser_48; - } -basic_json_parser_50: - { - last_token_type = token_type::parse_error; - break; - } -basic_json_parser_51: + if (yych <= '/') goto basic_json_parser_50; + if (yych <= '9') goto basic_json_parser_48; + basic_json_parser_50: + { last_token_type = token_type::parse_error; break; } + basic_json_parser_51: yych = *++m_cursor; - if (yych <= ',') - { - if (yych == '+') - { - goto basic_json_parser_59; - } + if (yych <= ',') { + if (yych == '+') goto basic_json_parser_59; + goto basic_json_parser_32; + } else { + if (yych <= '-') goto basic_json_parser_59; + if (yych <= '/') goto basic_json_parser_32; + if (yych <= '9') goto basic_json_parser_60; goto basic_json_parser_32; } - else - { - if (yych <= '-') - { - goto basic_json_parser_59; - } - if (yych <= '/') - { - goto basic_json_parser_32; - } - if (yych <= '9') - { - goto basic_json_parser_60; - } - goto basic_json_parser_32; - } -basic_json_parser_52: + basic_json_parser_52: yych = *++m_cursor; - if (yych == 'l') - { - goto basic_json_parser_62; - } + if (yych == 'l') goto basic_json_parser_62; goto basic_json_parser_32; -basic_json_parser_53: + basic_json_parser_53: yych = *++m_cursor; - if (yych == 'l') - { - goto basic_json_parser_63; - } + if (yych == 'l') goto basic_json_parser_63; goto basic_json_parser_32; -basic_json_parser_54: + basic_json_parser_54: yych = *++m_cursor; - if (yych == 'u') - { - goto basic_json_parser_64; - } + if (yych == 'u') goto basic_json_parser_64; goto basic_json_parser_32; -basic_json_parser_55: + basic_json_parser_55: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= '@') - { - if (yych <= '/') - { - goto basic_json_parser_32; - } - if (yych <= '9') - { - goto basic_json_parser_65; - } + if (yych <= '@') { + if (yych <= '/') goto basic_json_parser_32; + if (yych <= '9') goto basic_json_parser_65; + goto basic_json_parser_32; + } else { + if (yych <= 'F') goto basic_json_parser_65; + if (yych <= '`') goto basic_json_parser_32; + if (yych <= 'f') goto basic_json_parser_65; goto basic_json_parser_32; } - else - { - if (yych <= 'F') - { - goto basic_json_parser_65; - } - if (yych <= '`') - { - goto basic_json_parser_32; - } - if (yych <= 'f') - { - goto basic_json_parser_65; - } - goto basic_json_parser_32; - } -basic_json_parser_56: + basic_json_parser_56: yyaccept = 3; m_marker = ++m_cursor; - if ((m_limit - m_cursor) < 3) - { - fill_line_buffer(3); // LCOV_EXCL_LINE - } + if ((m_limit - m_cursor) < 3) fill_line_buffer(3); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= 'D') - { - if (yych <= '/') - { - goto basic_json_parser_58; - } - if (yych <= '9') - { - goto basic_json_parser_56; - } + if (yych <= 'D') { + if (yych <= '/') goto basic_json_parser_58; + if (yych <= '9') goto basic_json_parser_56; + } else { + if (yych <= 'E') goto basic_json_parser_51; + if (yych == 'e') goto basic_json_parser_51; } - else - { - if (yych <= 'E') - { - goto basic_json_parser_51; - } - if (yych == 'e') - { - goto basic_json_parser_51; - } - } -basic_json_parser_58: - { - last_token_type = token_type::value_float; - break; - } -basic_json_parser_59: + basic_json_parser_58: + { last_token_type = token_type::value_float; break; } + basic_json_parser_59: yych = *++m_cursor; - if (yych <= '/') - { - goto basic_json_parser_32; - } - if (yych >= ':') - { - goto basic_json_parser_32; - } -basic_json_parser_60: + if (yych <= '/') goto basic_json_parser_32; + if (yych >= ':') goto basic_json_parser_32; + basic_json_parser_60: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= '/') - { - goto basic_json_parser_58; - } - if (yych <= '9') - { - goto basic_json_parser_60; - } + if (yych <= '/') goto basic_json_parser_58; + if (yych <= '9') goto basic_json_parser_60; goto basic_json_parser_58; -basic_json_parser_62: + basic_json_parser_62: yych = *++m_cursor; - if (yych == 's') - { - goto basic_json_parser_66; - } + if (yych == 's') goto basic_json_parser_66; goto basic_json_parser_32; -basic_json_parser_63: + basic_json_parser_63: yych = *++m_cursor; - if (yych == 'l') - { - goto basic_json_parser_67; - } + if (yych == 'l') goto basic_json_parser_67; goto basic_json_parser_32; -basic_json_parser_64: + basic_json_parser_64: yych = *++m_cursor; - if (yych == 'e') - { - goto basic_json_parser_69; - } + if (yych == 'e') goto basic_json_parser_69; goto basic_json_parser_32; -basic_json_parser_65: + basic_json_parser_65: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= '@') - { - if (yych <= '/') - { - goto basic_json_parser_32; - } - if (yych <= '9') - { - goto basic_json_parser_71; - } + if (yych <= '@') { + if (yych <= '/') goto basic_json_parser_32; + if (yych <= '9') goto basic_json_parser_71; + goto basic_json_parser_32; + } else { + if (yych <= 'F') goto basic_json_parser_71; + if (yych <= '`') goto basic_json_parser_32; + if (yych <= 'f') goto basic_json_parser_71; goto basic_json_parser_32; } - else - { - if (yych <= 'F') - { - goto basic_json_parser_71; - } - if (yych <= '`') - { - goto basic_json_parser_32; - } - if (yych <= 'f') - { - goto basic_json_parser_71; - } - goto basic_json_parser_32; - } -basic_json_parser_66: + basic_json_parser_66: yych = *++m_cursor; - if (yych == 'e') - { - goto basic_json_parser_72; - } + if (yych == 'e') goto basic_json_parser_72; goto basic_json_parser_32; -basic_json_parser_67: + basic_json_parser_67: ++m_cursor; - { - last_token_type = token_type::literal_null; - break; - } -basic_json_parser_69: + { last_token_type = token_type::literal_null; break; } + basic_json_parser_69: ++m_cursor; - { - last_token_type = token_type::literal_true; - break; - } -basic_json_parser_71: + { last_token_type = token_type::literal_true; break; } + basic_json_parser_71: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= '@') - { - if (yych <= '/') - { - goto basic_json_parser_32; - } - if (yych <= '9') - { - goto basic_json_parser_74; - } + if (yych <= '@') { + if (yych <= '/') goto basic_json_parser_32; + if (yych <= '9') goto basic_json_parser_74; + goto basic_json_parser_32; + } else { + if (yych <= 'F') goto basic_json_parser_74; + if (yych <= '`') goto basic_json_parser_32; + if (yych <= 'f') goto basic_json_parser_74; goto basic_json_parser_32; } - else - { - if (yych <= 'F') - { - goto basic_json_parser_74; - } - if (yych <= '`') - { - goto basic_json_parser_32; - } - if (yych <= 'f') - { - goto basic_json_parser_74; - } - goto basic_json_parser_32; - } -basic_json_parser_72: + basic_json_parser_72: ++m_cursor; - { - last_token_type = token_type::literal_false; - break; - } -basic_json_parser_74: + { last_token_type = token_type::literal_false; break; } + basic_json_parser_74: ++m_cursor; - if (m_limit <= m_cursor) - { - fill_line_buffer(1); // LCOV_EXCL_LINE - } + if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= '@') - { - if (yych <= '/') - { - goto basic_json_parser_32; - } - if (yych <= '9') - { - goto basic_json_parser_30; - } + if (yych <= '@') { + if (yych <= '/') goto basic_json_parser_32; + if (yych <= '9') goto basic_json_parser_30; goto basic_json_parser_32; - } - else - { - if (yych <= 'F') - { - goto basic_json_parser_30; - } - if (yych <= '`') - { - goto basic_json_parser_32; - } - if (yych <= 'f') - { - goto basic_json_parser_30; - } + } else { + if (yych <= 'F') goto basic_json_parser_30; + if (yych <= '`') goto basic_json_parser_32; + if (yych <= 'f') goto basic_json_parser_30; goto basic_json_parser_32; } } diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index fc7cf965..3a53f16c 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -6168,6 +6168,21 @@ class basic_json thousands_sep(!loc->thousands_sep ? '\0' : loc->thousands_sep[0]), decimal_point(!loc->decimal_point ? '\0' : loc->decimal_point[0]) {} + serializer(const serializer& cpy) + : o(cpy.o), + thousands_sep(cpy.thousands_sep), + decimal_point(cpy.decimal_point), + loc(cpy.loc), + indent_string(cpy.indent_string) + {} + serializer& operator=(const serializer& rhs) { + o = rhs.o; + thousands_sep = rhs.thousands_sep; + decimal_point = rhs.decimal_point; + loc = rhs.loc; + indent_string = rhs.indent_string; + return *this; + } /*! @brief internal implementation of the serialization function diff --git a/test/src/unit-udt.cpp b/test/src/unit-udt.cpp index a8103082..6b37a106 100644 --- a/test/src/unit-udt.cpp +++ b/test/src/unit-udt.cpp @@ -49,16 +49,19 @@ enum class country struct age { int m_val; + age(int rhs=0) : m_val(rhs) {} }; struct name { std::string m_val; + name(const std::string rhs="") : m_val(rhs) {} }; struct address { std::string m_val; + address(const std::string rhs="") : m_val(rhs) {} }; struct person @@ -66,18 +69,24 @@ struct person age m_age; name m_name; country m_country; + person() : m_age(),m_name(),m_country() {} + person(const age& a, const name& n, const country& c) : m_age(a), m_name(n), m_country(c) {} }; struct contact { person m_person; address m_address; + contact() : m_person(), m_address() {} + contact(const person& p, const address& a) : m_person(p), m_address(a) {} }; struct contact_book { name m_book_name; std::vector m_contacts; + contact_book() : m_book_name(), m_contacts() {} + contact_book(const name& n, const std::vector& c) : m_book_name(n), m_contacts(c) {} }; } @@ -319,6 +328,8 @@ namespace udt struct legacy_type { std::string number; + legacy_type() : number() {} + legacy_type(const std::string& n) : number(n) {} }; } @@ -593,6 +604,8 @@ struct small_pod struct non_pod { std::string s; + non_pod() : s() {} + non_pod(const std::string& S) : s(S) {} }; template From 5b809b97374488c628c8cb7e27d614cb19cfb24a Mon Sep 17 00:00:00 2001 From: Ted Lyngmo Date: Sat, 11 Mar 2017 13:56:38 +0100 Subject: [PATCH 03/14] Fix -Weffc++ warnings (GNU 6.3.1) --- src/json.hpp | 4 ++++ src/json.hpp.re2c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/json.hpp b/src/json.hpp index f2e02628..8883acd9 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -6159,6 +6159,10 @@ class basic_json */ class serializer { + private: + serializer(const serializer&) = delete; + serializer& operator=(const serializer&) = delete; + public: /*! @param[in] s output stream to serialize to diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 3a53f16c..6e90e6b8 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -6159,6 +6159,10 @@ class basic_json */ class serializer { + private: + serializer(const serializer&) = delete; + serializer& operator=(const serializer&) = delete; + public: /*! @param[in] s output stream to serialize to From 70bbf1952739f2890d1d19186eb1dcad11b23486 Mon Sep 17 00:00:00 2001 From: Ted Lyngmo Date: Sat, 11 Mar 2017 13:56:38 +0100 Subject: [PATCH 04/14] Fix -Weffc++ warnings (GNU 6.3.1) --- src/json.hpp | 15 --------------- src/json.hpp.re2c | 15 --------------- 2 files changed, 30 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 8883acd9..6d5b5586 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -6172,21 +6172,6 @@ class basic_json thousands_sep(!loc->thousands_sep ? '\0' : loc->thousands_sep[0]), decimal_point(!loc->decimal_point ? '\0' : loc->decimal_point[0]) {} - serializer(const serializer& cpy) - : o(cpy.o), - thousands_sep(cpy.thousands_sep), - decimal_point(cpy.decimal_point), - loc(cpy.loc), - indent_string(cpy.indent_string) - {} - serializer& operator=(const serializer& rhs) { - o = rhs.o; - thousands_sep = rhs.thousands_sep; - decimal_point = rhs.decimal_point; - loc = rhs.loc; - indent_string = rhs.indent_string; - return *this; - } /*! @brief internal implementation of the serialization function diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 6e90e6b8..21639efc 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -6172,21 +6172,6 @@ class basic_json thousands_sep(!loc->thousands_sep ? '\0' : loc->thousands_sep[0]), decimal_point(!loc->decimal_point ? '\0' : loc->decimal_point[0]) {} - serializer(const serializer& cpy) - : o(cpy.o), - thousands_sep(cpy.thousands_sep), - decimal_point(cpy.decimal_point), - loc(cpy.loc), - indent_string(cpy.indent_string) - {} - serializer& operator=(const serializer& rhs) { - o = rhs.o; - thousands_sep = rhs.thousands_sep; - decimal_point = rhs.decimal_point; - loc = rhs.loc; - indent_string = rhs.indent_string; - return *this; - } /*! @brief internal implementation of the serialization function From f5f6dac8009fb481118be94ce18e043a057bd036 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 11 Mar 2017 15:32:44 +0100 Subject: [PATCH 05/14] :sparkles: added overload for std::vector #494 Adds a to_json function for std::vector to allow implicit conversion from bit vectors to basic_json. --- src/json.hpp | 19 +++++++++++++++++++ src/json.hpp.re2c | 19 +++++++++++++++++++ test/src/unit-regression.cpp | 9 +++++++++ 3 files changed, 47 insertions(+) diff --git a/src/json.hpp b/src/json.hpp index ff0ce5ad..432cf553 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -324,6 +324,19 @@ struct external_constructor j.m_value.array = j.template create(begin(arr), end(arr)); j.assert_invariant(); } + + template + static void construct(BasicJsonType& j, const std::vector& arr) + { + j.m_type = value_t::array; + j.m_value = value_t::array; + j.m_value.array->reserve(arr.size()); + for (bool x : arr) + { + j.m_value.array->push_back(x); + } + j.assert_invariant(); + } }; template<> @@ -562,6 +575,12 @@ void to_json(BasicJsonType& j, UnscopedEnumType e) noexcept external_constructor::construct(j, e); } +template +void to_json(BasicJsonType& j, std::vector e) noexcept +{ + external_constructor::construct(j, e); +} + template < typename BasicJsonType, typename CompatibleArrayType, enable_if_t < diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index fc7cf965..21b4fd3a 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -324,6 +324,19 @@ struct external_constructor j.m_value.array = j.template create(begin(arr), end(arr)); j.assert_invariant(); } + + template + static void construct(BasicJsonType& j, const std::vector& arr) + { + j.m_type = value_t::array; + j.m_value = value_t::array; + j.m_value.array->reserve(arr.size()); + for (bool x : arr) + { + j.m_value.array->push_back(x); + } + j.assert_invariant(); + } }; template<> @@ -562,6 +575,12 @@ void to_json(BasicJsonType& j, UnscopedEnumType e) noexcept external_constructor::construct(j, e); } +template +void to_json(BasicJsonType& j, std::vector e) noexcept +{ + external_constructor::construct(j, e); +} + template < typename BasicJsonType, typename CompatibleArrayType, enable_if_t < diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 7980371b..bfd2c954 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -795,4 +795,13 @@ TEST_CASE("regression tests") std::string s2 = j2.dump(); CHECK(s1 == s2); } + + SECTION("issue #494 - conversion from vector to json fails to build") + { + std::vector boolVector = {false, true, false, false}; + json j; + j["bool_vector"] = boolVector; + + CHECK(j["bool_vector"].dump() == "[false,true,false,false]"); + } } From f4126e4dd84dfb723acb34dd3dbfcd6364b11fb2 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 11 Mar 2017 15:44:14 +0100 Subject: [PATCH 06/14] :sparkles: added overload for std::less #486 MSVC needs this overload to compile code containing a std::map that uses nlohmann::detail::operator as key. --- src/json.hpp | 16 ++++++++++++++++ src/json.hpp.re2c | 16 ++++++++++++++++ test/src/unit-regression.cpp | 7 +++++++ 3 files changed, 39 insertions(+) diff --git a/src/json.hpp b/src/json.hpp index ff0ce5ad..6f52255b 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -13025,6 +13025,22 @@ struct hash return h(j.dump()); } }; + +/// specialization for std::less +template <> +struct less<::nlohmann::detail::value_t> +{ + /*! + @brief compare two value_t enum values + @since version 3.0.0 + */ + bool operator()(nlohmann::detail::value_t lhs, + nlohmann::detail::value_t rhs) const noexcept + { + return nlohmann::detail::operator<(lhs, rhs); + } +}; + } // namespace std /*! diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index fc7cf965..7c2c24bf 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -12059,6 +12059,22 @@ struct hash return h(j.dump()); } }; + +/// specialization for std::less +template <> +struct less<::nlohmann::detail::value_t> +{ + /*! + @brief compare two value_t enum values + @since version 3.0.0 + */ + bool operator()(nlohmann::detail::value_t lhs, + nlohmann::detail::value_t rhs) const noexcept + { + return nlohmann::detail::operator<(lhs, rhs); + } +}; + } // namespace std /*! diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 7980371b..f7b56050 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -795,4 +795,11 @@ TEST_CASE("regression tests") std::string s2 = j2.dump(); CHECK(s1 == s2); } + + SECTION("issue #486 - json::value_t can't be a map's key type in VC++ 2015") + { + // the code below must compile with MSVC + std::map jsonTypes ; + jsonTypes[json::value_t::array] = "array"; + } } From d9e2dd03bf4faabe63f09c7853939d67eb04539d Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 11 Mar 2017 15:46:52 +0100 Subject: [PATCH 07/14] :hammer: fixed interface for to_json function --- src/json.hpp | 2 +- src/json.hpp.re2c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 432cf553..d3601078 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -576,7 +576,7 @@ void to_json(BasicJsonType& j, UnscopedEnumType e) noexcept } template -void to_json(BasicJsonType& j, std::vector e) noexcept +void to_json(BasicJsonType& j, const std::vector& e) { external_constructor::construct(j, e); } diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 21b4fd3a..1560f1ef 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -576,7 +576,7 @@ void to_json(BasicJsonType& j, UnscopedEnumType e) noexcept } template -void to_json(BasicJsonType& j, std::vector e) noexcept +void to_json(BasicJsonType& j, const std::vector& e) { external_constructor::construct(j, e); } From c7afb34e57fc7d343a6c6f3ddee859fe92a7cf92 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 11 Mar 2017 16:01:26 +0100 Subject: [PATCH 08/14] :art: cleanup after #496 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ran “make pretty” and added a note to the README file. --- README.md | 2 +- src/json.hpp | 1183 ++++++++++++++++++++++++++++++----------- test/src/unit-udt.cpp | 8 +- 3 files changed, 870 insertions(+), 323 deletions(-) diff --git a/README.md b/README.md index 94120db6..2a896210 100644 --- a/README.md +++ b/README.md @@ -828,7 +828,7 @@ I deeply appreciate the help of the following people. - [rswanson-ihi](https://github.com/rswanson-ihi) noted a typo in the README. - [Mihai Stan](https://github.com/stanmihai4) fixed a bug in the comparison with `nullptr`s. - [Tushar Maheshwari](https://github.com/tusharpm) added [cotire](https://github.com/sakra/cotire) support to speed up the compilation. -- [TedLyngmo](https://github.com/TedLyngmo) noted a typo in the README. +- [TedLyngmo](https://github.com/TedLyngmo) noted a typo in the README and fixed some `-Weffc++` warnings. Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone. diff --git a/src/json.hpp b/src/json.hpp index 6d5b5586..32ba8d10 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -9863,11 +9863,12 @@ class basic_json { lexer_char_t yych; unsigned int yyaccept = 0; - static const unsigned char yybm[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 32, 32, 0, 0, 32, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + static const unsigned char yybm[] = + { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 32, 32, 0, 0, 32, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 160, 128, 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 192, 192, 192, 192, 192, 192, 192, 192, @@ -9880,466 +9881,1012 @@ class basic_json 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, }; - if ((m_limit - m_cursor) < 5) fill_line_buffer(5); // LCOV_EXCL_LINE + if ((m_limit - m_cursor) < 5) + { + fill_line_buffer(5); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yybm[0+yych] & 32) { + if (yybm[0 + yych] & 32) + { goto basic_json_parser_6; } - if (yych <= '[') { - if (yych <= '-') { - if (yych <= '"') { - if (yych <= 0x00) goto basic_json_parser_2; - if (yych <= '!') goto basic_json_parser_4; + if (yych <= '[') + { + if (yych <= '-') + { + if (yych <= '"') + { + if (yych <= 0x00) + { + goto basic_json_parser_2; + } + if (yych <= '!') + { + goto basic_json_parser_4; + } goto basic_json_parser_9; - } else { - if (yych <= '+') goto basic_json_parser_4; - if (yych <= ',') goto basic_json_parser_10; + } + else + { + if (yych <= '+') + { + goto basic_json_parser_4; + } + if (yych <= ',') + { + goto basic_json_parser_10; + } goto basic_json_parser_12; } - } else { - if (yych <= '9') { - if (yych <= '/') goto basic_json_parser_4; - if (yych <= '0') goto basic_json_parser_13; + } + else + { + if (yych <= '9') + { + if (yych <= '/') + { + goto basic_json_parser_4; + } + if (yych <= '0') + { + goto basic_json_parser_13; + } goto basic_json_parser_15; - } else { - if (yych <= ':') goto basic_json_parser_17; - if (yych <= 'Z') goto basic_json_parser_4; + } + else + { + if (yych <= ':') + { + goto basic_json_parser_17; + } + if (yych <= 'Z') + { + goto basic_json_parser_4; + } goto basic_json_parser_19; } } - } else { - if (yych <= 'n') { - if (yych <= 'e') { - if (yych == ']') goto basic_json_parser_21; + } + else + { + if (yych <= 'n') + { + if (yych <= 'e') + { + if (yych == ']') + { + goto basic_json_parser_21; + } goto basic_json_parser_4; - } else { - if (yych <= 'f') goto basic_json_parser_23; - if (yych <= 'm') goto basic_json_parser_4; + } + else + { + if (yych <= 'f') + { + goto basic_json_parser_23; + } + if (yych <= 'm') + { + goto basic_json_parser_4; + } goto basic_json_parser_24; } - } else { - if (yych <= 'z') { - if (yych == 't') goto basic_json_parser_25; + } + else + { + if (yych <= 'z') + { + if (yych == 't') + { + goto basic_json_parser_25; + } goto basic_json_parser_4; - } else { - if (yych <= '{') goto basic_json_parser_26; - if (yych == '}') goto basic_json_parser_28; + } + else + { + if (yych <= '{') + { + goto basic_json_parser_26; + } + if (yych == '}') + { + goto basic_json_parser_28; + } goto basic_json_parser_4; } } } - basic_json_parser_2: +basic_json_parser_2: ++m_cursor; - { last_token_type = token_type::end_of_input; break; } - basic_json_parser_4: + { + last_token_type = token_type::end_of_input; + break; + } +basic_json_parser_4: ++m_cursor; - basic_json_parser_5: - { last_token_type = token_type::parse_error; break; } - basic_json_parser_6: +basic_json_parser_5: + { + last_token_type = token_type::parse_error; + break; + } +basic_json_parser_6: ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yybm[0+yych] & 32) { + if (yybm[0 + yych] & 32) + { goto basic_json_parser_6; } - { continue; } - basic_json_parser_9: + { + continue; + } +basic_json_parser_9: yyaccept = 0; yych = *(m_marker = ++m_cursor); - if (yych <= 0x1F) goto basic_json_parser_5; - if (yych <= 0x7F) goto basic_json_parser_31; - if (yych <= 0xC1) goto basic_json_parser_5; - if (yych <= 0xF4) goto basic_json_parser_31; + if (yych <= 0x1F) + { + goto basic_json_parser_5; + } + if (yych <= 0x7F) + { + goto basic_json_parser_31; + } + if (yych <= 0xC1) + { + goto basic_json_parser_5; + } + if (yych <= 0xF4) + { + goto basic_json_parser_31; + } goto basic_json_parser_5; - basic_json_parser_10: +basic_json_parser_10: ++m_cursor; - { last_token_type = token_type::value_separator; break; } - basic_json_parser_12: + { + last_token_type = token_type::value_separator; + break; + } +basic_json_parser_12: yych = *++m_cursor; - if (yych <= '/') goto basic_json_parser_5; - if (yych <= '0') goto basic_json_parser_43; - if (yych <= '9') goto basic_json_parser_45; + if (yych <= '/') + { + goto basic_json_parser_5; + } + if (yych <= '0') + { + goto basic_json_parser_43; + } + if (yych <= '9') + { + goto basic_json_parser_45; + } goto basic_json_parser_5; - basic_json_parser_13: +basic_json_parser_13: yyaccept = 1; yych = *(m_marker = ++m_cursor); - if (yych <= '9') { - if (yych == '.') goto basic_json_parser_47; - if (yych >= '0') goto basic_json_parser_48; - } else { - if (yych <= 'E') { - if (yych >= 'E') goto basic_json_parser_51; - } else { - if (yych == 'e') goto basic_json_parser_51; + if (yych <= '9') + { + if (yych == '.') + { + goto basic_json_parser_47; + } + if (yych >= '0') + { + goto basic_json_parser_48; } } - basic_json_parser_14: - { last_token_type = token_type::value_unsigned; break; } - basic_json_parser_15: + else + { + if (yych <= 'E') + { + if (yych >= 'E') + { + goto basic_json_parser_51; + } + } + else + { + if (yych == 'e') + { + goto basic_json_parser_51; + } + } + } +basic_json_parser_14: + { + last_token_type = token_type::value_unsigned; + break; + } +basic_json_parser_15: yyaccept = 1; m_marker = ++m_cursor; - if ((m_limit - m_cursor) < 3) fill_line_buffer(3); // LCOV_EXCL_LINE + if ((m_limit - m_cursor) < 3) + { + fill_line_buffer(3); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yybm[0+yych] & 64) { + if (yybm[0 + yych] & 64) + { goto basic_json_parser_15; } - if (yych <= 'D') { - if (yych == '.') goto basic_json_parser_47; - goto basic_json_parser_14; - } else { - if (yych <= 'E') goto basic_json_parser_51; - if (yych == 'e') goto basic_json_parser_51; + if (yych <= 'D') + { + if (yych == '.') + { + goto basic_json_parser_47; + } goto basic_json_parser_14; } - basic_json_parser_17: + else + { + if (yych <= 'E') + { + goto basic_json_parser_51; + } + if (yych == 'e') + { + goto basic_json_parser_51; + } + goto basic_json_parser_14; + } +basic_json_parser_17: ++m_cursor; - { last_token_type = token_type::name_separator; break; } - basic_json_parser_19: + { + last_token_type = token_type::name_separator; + break; + } +basic_json_parser_19: ++m_cursor; - { last_token_type = token_type::begin_array; break; } - basic_json_parser_21: + { + last_token_type = token_type::begin_array; + break; + } +basic_json_parser_21: ++m_cursor; - { last_token_type = token_type::end_array; break; } - basic_json_parser_23: + { + last_token_type = token_type::end_array; + break; + } +basic_json_parser_23: yyaccept = 0; yych = *(m_marker = ++m_cursor); - if (yych == 'a') goto basic_json_parser_52; + if (yych == 'a') + { + goto basic_json_parser_52; + } goto basic_json_parser_5; - basic_json_parser_24: +basic_json_parser_24: yyaccept = 0; yych = *(m_marker = ++m_cursor); - if (yych == 'u') goto basic_json_parser_53; + if (yych == 'u') + { + goto basic_json_parser_53; + } goto basic_json_parser_5; - basic_json_parser_25: +basic_json_parser_25: yyaccept = 0; yych = *(m_marker = ++m_cursor); - if (yych == 'r') goto basic_json_parser_54; + if (yych == 'r') + { + goto basic_json_parser_54; + } goto basic_json_parser_5; - basic_json_parser_26: +basic_json_parser_26: ++m_cursor; - { last_token_type = token_type::begin_object; break; } - basic_json_parser_28: + { + last_token_type = token_type::begin_object; + break; + } +basic_json_parser_28: ++m_cursor; - { last_token_type = token_type::end_object; break; } - basic_json_parser_30: + { + last_token_type = token_type::end_object; + break; + } +basic_json_parser_30: ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } yych = *m_cursor; - basic_json_parser_31: - if (yybm[0+yych] & 128) { +basic_json_parser_31: + if (yybm[0 + yych] & 128) + { goto basic_json_parser_30; } - if (yych <= 0xE0) { - if (yych <= '\\') { - if (yych <= 0x1F) goto basic_json_parser_32; - if (yych <= '"') goto basic_json_parser_33; + if (yych <= 0xE0) + { + if (yych <= '\\') + { + if (yych <= 0x1F) + { + goto basic_json_parser_32; + } + if (yych <= '"') + { + goto basic_json_parser_33; + } goto basic_json_parser_35; - } else { - if (yych <= 0xC1) goto basic_json_parser_32; - if (yych <= 0xDF) goto basic_json_parser_36; + } + else + { + if (yych <= 0xC1) + { + goto basic_json_parser_32; + } + if (yych <= 0xDF) + { + goto basic_json_parser_36; + } goto basic_json_parser_37; } - } else { - if (yych <= 0xEF) { - if (yych == 0xED) goto basic_json_parser_39; + } + else + { + if (yych <= 0xEF) + { + if (yych == 0xED) + { + goto basic_json_parser_39; + } goto basic_json_parser_38; - } else { - if (yych <= 0xF0) goto basic_json_parser_40; - if (yych <= 0xF3) goto basic_json_parser_41; - if (yych <= 0xF4) goto basic_json_parser_42; + } + else + { + if (yych <= 0xF0) + { + goto basic_json_parser_40; + } + if (yych <= 0xF3) + { + goto basic_json_parser_41; + } + if (yych <= 0xF4) + { + goto basic_json_parser_42; + } } } - basic_json_parser_32: +basic_json_parser_32: m_cursor = m_marker; - if (yyaccept <= 1) { - if (yyaccept == 0) { + if (yyaccept <= 1) + { + if (yyaccept == 0) + { goto basic_json_parser_5; - } else { + } + else + { goto basic_json_parser_14; } - } else { - if (yyaccept == 2) { + } + else + { + if (yyaccept == 2) + { goto basic_json_parser_44; - } else { + } + else + { goto basic_json_parser_58; } } - basic_json_parser_33: +basic_json_parser_33: ++m_cursor; - { last_token_type = token_type::value_string; break; } - basic_json_parser_35: + { + last_token_type = token_type::value_string; + break; + } +basic_json_parser_35: ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yych <= 'e') { - if (yych <= '/') { - if (yych == '"') goto basic_json_parser_30; - if (yych <= '.') goto basic_json_parser_32; - goto basic_json_parser_30; - } else { - if (yych <= '\\') { - if (yych <= '[') goto basic_json_parser_32; + if (yych <= 'e') + { + if (yych <= '/') + { + if (yych == '"') + { goto basic_json_parser_30; - } else { - if (yych == 'b') goto basic_json_parser_30; + } + if (yych <= '.') + { goto basic_json_parser_32; } + goto basic_json_parser_30; } - } else { - if (yych <= 'q') { - if (yych <= 'f') goto basic_json_parser_30; - if (yych == 'n') goto basic_json_parser_30; - goto basic_json_parser_32; - } else { - if (yych <= 's') { - if (yych <= 'r') goto basic_json_parser_30; - goto basic_json_parser_32; - } else { - if (yych <= 't') goto basic_json_parser_30; - if (yych <= 'u') goto basic_json_parser_55; + else + { + if (yych <= '\\') + { + if (yych <= '[') + { + goto basic_json_parser_32; + } + goto basic_json_parser_30; + } + else + { + if (yych == 'b') + { + goto basic_json_parser_30; + } goto basic_json_parser_32; } } } - basic_json_parser_36: + else + { + if (yych <= 'q') + { + if (yych <= 'f') + { + goto basic_json_parser_30; + } + if (yych == 'n') + { + goto basic_json_parser_30; + } + goto basic_json_parser_32; + } + else + { + if (yych <= 's') + { + if (yych <= 'r') + { + goto basic_json_parser_30; + } + goto basic_json_parser_32; + } + else + { + if (yych <= 't') + { + goto basic_json_parser_30; + } + if (yych <= 'u') + { + goto basic_json_parser_55; + } + goto basic_json_parser_32; + } + } + } +basic_json_parser_36: ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yych <= 0x7F) goto basic_json_parser_32; - if (yych <= 0xBF) goto basic_json_parser_30; + if (yych <= 0x7F) + { + goto basic_json_parser_32; + } + if (yych <= 0xBF) + { + goto basic_json_parser_30; + } goto basic_json_parser_32; - basic_json_parser_37: +basic_json_parser_37: ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yych <= 0x9F) goto basic_json_parser_32; - if (yych <= 0xBF) goto basic_json_parser_36; + if (yych <= 0x9F) + { + goto basic_json_parser_32; + } + if (yych <= 0xBF) + { + goto basic_json_parser_36; + } goto basic_json_parser_32; - basic_json_parser_38: +basic_json_parser_38: ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yych <= 0x7F) goto basic_json_parser_32; - if (yych <= 0xBF) goto basic_json_parser_36; + if (yych <= 0x7F) + { + goto basic_json_parser_32; + } + if (yych <= 0xBF) + { + goto basic_json_parser_36; + } goto basic_json_parser_32; - basic_json_parser_39: +basic_json_parser_39: ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yych <= 0x7F) goto basic_json_parser_32; - if (yych <= 0x9F) goto basic_json_parser_36; + if (yych <= 0x7F) + { + goto basic_json_parser_32; + } + if (yych <= 0x9F) + { + goto basic_json_parser_36; + } goto basic_json_parser_32; - basic_json_parser_40: +basic_json_parser_40: ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yych <= 0x8F) goto basic_json_parser_32; - if (yych <= 0xBF) goto basic_json_parser_38; + if (yych <= 0x8F) + { + goto basic_json_parser_32; + } + if (yych <= 0xBF) + { + goto basic_json_parser_38; + } goto basic_json_parser_32; - basic_json_parser_41: +basic_json_parser_41: ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yych <= 0x7F) goto basic_json_parser_32; - if (yych <= 0xBF) goto basic_json_parser_38; + if (yych <= 0x7F) + { + goto basic_json_parser_32; + } + if (yych <= 0xBF) + { + goto basic_json_parser_38; + } goto basic_json_parser_32; - basic_json_parser_42: +basic_json_parser_42: ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yych <= 0x7F) goto basic_json_parser_32; - if (yych <= 0x8F) goto basic_json_parser_38; + if (yych <= 0x7F) + { + goto basic_json_parser_32; + } + if (yych <= 0x8F) + { + goto basic_json_parser_38; + } goto basic_json_parser_32; - basic_json_parser_43: +basic_json_parser_43: yyaccept = 2; yych = *(m_marker = ++m_cursor); - if (yych <= '9') { - if (yych == '.') goto basic_json_parser_47; - if (yych >= '0') goto basic_json_parser_48; - } else { - if (yych <= 'E') { - if (yych >= 'E') goto basic_json_parser_51; - } else { - if (yych == 'e') goto basic_json_parser_51; + if (yych <= '9') + { + if (yych == '.') + { + goto basic_json_parser_47; + } + if (yych >= '0') + { + goto basic_json_parser_48; } } - basic_json_parser_44: - { last_token_type = token_type::value_integer; break; } - basic_json_parser_45: + else + { + if (yych <= 'E') + { + if (yych >= 'E') + { + goto basic_json_parser_51; + } + } + else + { + if (yych == 'e') + { + goto basic_json_parser_51; + } + } + } +basic_json_parser_44: + { + last_token_type = token_type::value_integer; + break; + } +basic_json_parser_45: yyaccept = 2; m_marker = ++m_cursor; - if ((m_limit - m_cursor) < 3) fill_line_buffer(3); // LCOV_EXCL_LINE + if ((m_limit - m_cursor) < 3) + { + fill_line_buffer(3); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yych <= '9') { - if (yych == '.') goto basic_json_parser_47; - if (yych <= '/') goto basic_json_parser_44; + if (yych <= '9') + { + if (yych == '.') + { + goto basic_json_parser_47; + } + if (yych <= '/') + { + goto basic_json_parser_44; + } goto basic_json_parser_45; - } else { - if (yych <= 'E') { - if (yych <= 'D') goto basic_json_parser_44; + } + else + { + if (yych <= 'E') + { + if (yych <= 'D') + { + goto basic_json_parser_44; + } goto basic_json_parser_51; - } else { - if (yych == 'e') goto basic_json_parser_51; + } + else + { + if (yych == 'e') + { + goto basic_json_parser_51; + } goto basic_json_parser_44; } } - basic_json_parser_47: +basic_json_parser_47: yych = *++m_cursor; - if (yych <= '/') goto basic_json_parser_32; - if (yych <= '9') goto basic_json_parser_56; - goto basic_json_parser_32; - basic_json_parser_48: - ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE - yych = *m_cursor; - if (yych <= '/') goto basic_json_parser_50; - if (yych <= '9') goto basic_json_parser_48; - basic_json_parser_50: - { last_token_type = token_type::parse_error; break; } - basic_json_parser_51: - yych = *++m_cursor; - if (yych <= ',') { - if (yych == '+') goto basic_json_parser_59; - goto basic_json_parser_32; - } else { - if (yych <= '-') goto basic_json_parser_59; - if (yych <= '/') goto basic_json_parser_32; - if (yych <= '9') goto basic_json_parser_60; + if (yych <= '/') + { goto basic_json_parser_32; } - basic_json_parser_52: - yych = *++m_cursor; - if (yych == 'l') goto basic_json_parser_62; + if (yych <= '9') + { + goto basic_json_parser_56; + } goto basic_json_parser_32; - basic_json_parser_53: - yych = *++m_cursor; - if (yych == 'l') goto basic_json_parser_63; - goto basic_json_parser_32; - basic_json_parser_54: - yych = *++m_cursor; - if (yych == 'u') goto basic_json_parser_64; - goto basic_json_parser_32; - basic_json_parser_55: +basic_json_parser_48: ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yych <= '@') { - if (yych <= '/') goto basic_json_parser_32; - if (yych <= '9') goto basic_json_parser_65; - goto basic_json_parser_32; - } else { - if (yych <= 'F') goto basic_json_parser_65; - if (yych <= '`') goto basic_json_parser_32; - if (yych <= 'f') goto basic_json_parser_65; + if (yych <= '/') + { + goto basic_json_parser_50; + } + if (yych <= '9') + { + goto basic_json_parser_48; + } +basic_json_parser_50: + { + last_token_type = token_type::parse_error; + break; + } +basic_json_parser_51: + yych = *++m_cursor; + if (yych <= ',') + { + if (yych == '+') + { + goto basic_json_parser_59; + } goto basic_json_parser_32; } - basic_json_parser_56: + else + { + if (yych <= '-') + { + goto basic_json_parser_59; + } + if (yych <= '/') + { + goto basic_json_parser_32; + } + if (yych <= '9') + { + goto basic_json_parser_60; + } + goto basic_json_parser_32; + } +basic_json_parser_52: + yych = *++m_cursor; + if (yych == 'l') + { + goto basic_json_parser_62; + } + goto basic_json_parser_32; +basic_json_parser_53: + yych = *++m_cursor; + if (yych == 'l') + { + goto basic_json_parser_63; + } + goto basic_json_parser_32; +basic_json_parser_54: + yych = *++m_cursor; + if (yych == 'u') + { + goto basic_json_parser_64; + } + goto basic_json_parser_32; +basic_json_parser_55: + ++m_cursor; + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } + yych = *m_cursor; + if (yych <= '@') + { + if (yych <= '/') + { + goto basic_json_parser_32; + } + if (yych <= '9') + { + goto basic_json_parser_65; + } + goto basic_json_parser_32; + } + else + { + if (yych <= 'F') + { + goto basic_json_parser_65; + } + if (yych <= '`') + { + goto basic_json_parser_32; + } + if (yych <= 'f') + { + goto basic_json_parser_65; + } + goto basic_json_parser_32; + } +basic_json_parser_56: yyaccept = 3; m_marker = ++m_cursor; - if ((m_limit - m_cursor) < 3) fill_line_buffer(3); // LCOV_EXCL_LINE - yych = *m_cursor; - if (yych <= 'D') { - if (yych <= '/') goto basic_json_parser_58; - if (yych <= '9') goto basic_json_parser_56; - } else { - if (yych <= 'E') goto basic_json_parser_51; - if (yych == 'e') goto basic_json_parser_51; + if ((m_limit - m_cursor) < 3) + { + fill_line_buffer(3); // LCOV_EXCL_LINE } - basic_json_parser_58: - { last_token_type = token_type::value_float; break; } - basic_json_parser_59: - yych = *++m_cursor; - if (yych <= '/') goto basic_json_parser_32; - if (yych >= ':') goto basic_json_parser_32; - basic_json_parser_60: - ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE yych = *m_cursor; - if (yych <= '/') goto basic_json_parser_58; - if (yych <= '9') goto basic_json_parser_60; + if (yych <= 'D') + { + if (yych <= '/') + { + goto basic_json_parser_58; + } + if (yych <= '9') + { + goto basic_json_parser_56; + } + } + else + { + if (yych <= 'E') + { + goto basic_json_parser_51; + } + if (yych == 'e') + { + goto basic_json_parser_51; + } + } +basic_json_parser_58: + { + last_token_type = token_type::value_float; + break; + } +basic_json_parser_59: + yych = *++m_cursor; + if (yych <= '/') + { + goto basic_json_parser_32; + } + if (yych >= ':') + { + goto basic_json_parser_32; + } +basic_json_parser_60: + ++m_cursor; + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } + yych = *m_cursor; + if (yych <= '/') + { + goto basic_json_parser_58; + } + if (yych <= '9') + { + goto basic_json_parser_60; + } goto basic_json_parser_58; - basic_json_parser_62: +basic_json_parser_62: yych = *++m_cursor; - if (yych == 's') goto basic_json_parser_66; + if (yych == 's') + { + goto basic_json_parser_66; + } goto basic_json_parser_32; - basic_json_parser_63: +basic_json_parser_63: yych = *++m_cursor; - if (yych == 'l') goto basic_json_parser_67; + if (yych == 'l') + { + goto basic_json_parser_67; + } goto basic_json_parser_32; - basic_json_parser_64: +basic_json_parser_64: yych = *++m_cursor; - if (yych == 'e') goto basic_json_parser_69; + if (yych == 'e') + { + goto basic_json_parser_69; + } goto basic_json_parser_32; - basic_json_parser_65: +basic_json_parser_65: ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yych <= '@') { - if (yych <= '/') goto basic_json_parser_32; - if (yych <= '9') goto basic_json_parser_71; - goto basic_json_parser_32; - } else { - if (yych <= 'F') goto basic_json_parser_71; - if (yych <= '`') goto basic_json_parser_32; - if (yych <= 'f') goto basic_json_parser_71; + if (yych <= '@') + { + if (yych <= '/') + { + goto basic_json_parser_32; + } + if (yych <= '9') + { + goto basic_json_parser_71; + } goto basic_json_parser_32; } - basic_json_parser_66: - yych = *++m_cursor; - if (yych == 'e') goto basic_json_parser_72; - goto basic_json_parser_32; - basic_json_parser_67: - ++m_cursor; - { last_token_type = token_type::literal_null; break; } - basic_json_parser_69: - ++m_cursor; - { last_token_type = token_type::literal_true; break; } - basic_json_parser_71: - ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE - yych = *m_cursor; - if (yych <= '@') { - if (yych <= '/') goto basic_json_parser_32; - if (yych <= '9') goto basic_json_parser_74; - goto basic_json_parser_32; - } else { - if (yych <= 'F') goto basic_json_parser_74; - if (yych <= '`') goto basic_json_parser_32; - if (yych <= 'f') goto basic_json_parser_74; + else + { + if (yych <= 'F') + { + goto basic_json_parser_71; + } + if (yych <= '`') + { + goto basic_json_parser_32; + } + if (yych <= 'f') + { + goto basic_json_parser_71; + } goto basic_json_parser_32; } - basic_json_parser_72: +basic_json_parser_66: + yych = *++m_cursor; + if (yych == 'e') + { + goto basic_json_parser_72; + } + goto basic_json_parser_32; +basic_json_parser_67: ++m_cursor; - { last_token_type = token_type::literal_false; break; } - basic_json_parser_74: + { + last_token_type = token_type::literal_null; + break; + } +basic_json_parser_69: ++m_cursor; - if (m_limit <= m_cursor) fill_line_buffer(1); // LCOV_EXCL_LINE + { + last_token_type = token_type::literal_true; + break; + } +basic_json_parser_71: + ++m_cursor; + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } yych = *m_cursor; - if (yych <= '@') { - if (yych <= '/') goto basic_json_parser_32; - if (yych <= '9') goto basic_json_parser_30; + if (yych <= '@') + { + if (yych <= '/') + { + goto basic_json_parser_32; + } + if (yych <= '9') + { + goto basic_json_parser_74; + } goto basic_json_parser_32; - } else { - if (yych <= 'F') goto basic_json_parser_30; - if (yych <= '`') goto basic_json_parser_32; - if (yych <= 'f') goto basic_json_parser_30; + } + else + { + if (yych <= 'F') + { + goto basic_json_parser_74; + } + if (yych <= '`') + { + goto basic_json_parser_32; + } + if (yych <= 'f') + { + goto basic_json_parser_74; + } + goto basic_json_parser_32; + } +basic_json_parser_72: + ++m_cursor; + { + last_token_type = token_type::literal_false; + break; + } +basic_json_parser_74: + ++m_cursor; + if (m_limit <= m_cursor) + { + fill_line_buffer(1); // LCOV_EXCL_LINE + } + yych = *m_cursor; + if (yych <= '@') + { + if (yych <= '/') + { + goto basic_json_parser_32; + } + if (yych <= '9') + { + goto basic_json_parser_30; + } + goto basic_json_parser_32; + } + else + { + if (yych <= 'F') + { + goto basic_json_parser_30; + } + if (yych <= '`') + { + goto basic_json_parser_32; + } + if (yych <= 'f') + { + goto basic_json_parser_30; + } goto basic_json_parser_32; } } diff --git a/test/src/unit-udt.cpp b/test/src/unit-udt.cpp index 6b37a106..6aa469fe 100644 --- a/test/src/unit-udt.cpp +++ b/test/src/unit-udt.cpp @@ -49,19 +49,19 @@ enum class country struct age { int m_val; - age(int rhs=0) : m_val(rhs) {} + age(int rhs = 0) : m_val(rhs) {} }; struct name { std::string m_val; - name(const std::string rhs="") : m_val(rhs) {} + name(const std::string rhs = "") : m_val(rhs) {} }; struct address { std::string m_val; - address(const std::string rhs="") : m_val(rhs) {} + address(const std::string rhs = "") : m_val(rhs) {} }; struct person @@ -69,7 +69,7 @@ struct person age m_age; name m_name; country m_country; - person() : m_age(),m_name(),m_country() {} + person() : m_age(), m_name(), m_country() {} person(const age& a, const name& n, const country& c) : m_age(a), m_name(n), m_country(c) {} }; From 65dfc97d401e17befa4d9a2320660b381529304e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 11 Mar 2017 17:44:54 +0100 Subject: [PATCH 09/14] :hammer: using __cpp_exceptions to detect exception support #498 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I used __EXCEPTIONS to detect whether exceptions are supported. Apparently, this is a macro that is only used by libstdc++ (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64276). It’s much cleaner to use __cpp_exceptions as it is in the standard since C++98. Note that compiling the unit-tests with “-fno-exceptions” still does not work, because Catch uses throw internally. However, the library’s exceptions can be switched off by defining JSON_NOEXCEPTION. --- src/json.hpp | 2 +- src/json.hpp.re2c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 33456a51..9fb5fefe 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -82,7 +82,7 @@ SOFTWARE. #endif // allow to disable exceptions -#if not defined(JSON_NOEXCEPTION) || defined(__EXCEPTIONS) +#if __cpp_exceptions && not defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception #define JSON_TRY try #define JSON_CATCH(exception) catch(exception) diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 180f5d3b..a837df06 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -82,7 +82,7 @@ SOFTWARE. #endif // allow to disable exceptions -#if not defined(JSON_NOEXCEPTION) || defined(__EXCEPTIONS) +#if __cpp_exceptions && not defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception #define JSON_TRY try #define JSON_CATCH(exception) catch(exception) From e3e6cbecc7a150590636d13b17a0260b5c46d90e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 11 Mar 2017 17:59:24 +0100 Subject: [PATCH 10/14] :checkered_flag: added check for _CPPUNWIND MSVC does not define __cpp_exceptions, but seems to use _CPPUNWIND when exception support is switched on, see https://msdn.microsoft.com/en-us/library/b0084kay.aspx. --- src/json.hpp | 2 +- src/json.hpp.re2c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 9fb5fefe..f9a92820 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -82,7 +82,7 @@ SOFTWARE. #endif // allow to disable exceptions -#if __cpp_exceptions && not defined(JSON_NOEXCEPTION) +#if (__cpp_exceptions || defined(_CPPUNWIND)) && not defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception #define JSON_TRY try #define JSON_CATCH(exception) catch(exception) diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index a837df06..2cad18aa 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -82,7 +82,7 @@ SOFTWARE. #endif // allow to disable exceptions -#if __cpp_exceptions && not defined(JSON_NOEXCEPTION) +#if (__cpp_exceptions || defined(_CPPUNWIND)) && not defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception #define JSON_TRY try #define JSON_CATCH(exception) catch(exception) From 122afbf1280413ade3719d6af2c37352215e30f0 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 11 Mar 2017 18:43:21 +0100 Subject: [PATCH 11/14] :hammer: added defined() check --- src/json.hpp | 2 +- src/json.hpp.re2c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index f9a92820..725310f6 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -82,7 +82,7 @@ SOFTWARE. #endif // allow to disable exceptions -#if (__cpp_exceptions || defined(_CPPUNWIND)) && not defined(JSON_NOEXCEPTION) +#if (defined(__cpp_exceptions) || defined(_CPPUNWIND)) && not defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception #define JSON_TRY try #define JSON_CATCH(exception) catch(exception) diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 2cad18aa..9172d2bf 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -82,7 +82,7 @@ SOFTWARE. #endif // allow to disable exceptions -#if (__cpp_exceptions || defined(_CPPUNWIND)) && not defined(JSON_NOEXCEPTION) +#if (defined(__cpp_exceptions) || defined(_CPPUNWIND)) && not defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception #define JSON_TRY try #define JSON_CATCH(exception) catch(exception) From 4b9c2f128740842abb8ba60956778bb59af15bd4 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 11 Mar 2017 20:16:13 +0100 Subject: [PATCH 12/14] :hammer: added __EXCEPTIONS to the list --- src/json.hpp | 2 +- src/json.hpp.re2c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 725310f6..c7b0154a 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -82,7 +82,7 @@ SOFTWARE. #endif // allow to disable exceptions -#if (defined(__cpp_exceptions) || defined(_CPPUNWIND)) && not defined(JSON_NOEXCEPTION) +#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && not defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception #define JSON_TRY try #define JSON_CATCH(exception) catch(exception) diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 9172d2bf..3ee67b1a 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -82,7 +82,7 @@ SOFTWARE. #endif // allow to disable exceptions -#if (defined(__cpp_exceptions) || defined(_CPPUNWIND)) && not defined(JSON_NOEXCEPTION) +#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && not defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception #define JSON_TRY try #define JSON_CATCH(exception) catch(exception) From 01470f388b496050be164b9fe6bcc613d1203109 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 12 Mar 2017 11:04:26 +0100 Subject: [PATCH 13/14] :construction_worker: fixed no_exceptions test case This test case relied on logics that have been replaced by CMake with #461. This change enables compilation and execution of the test suite without exceptions by adding an after_success task. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c3cba69e..5060b728 100644 --- a/.travis.yml +++ b/.travis.yml @@ -78,13 +78,13 @@ matrix: env: - COMPILER=g++-4.9 - SPECIAL=no_exceptions - - TEST_PATTERN=-e \"*\" addons: apt: sources: ['ubuntu-toolchain-r-test'] packages: [g++-4.9, cppcheck] - before_script: - - CPPFLAGS="-DJSON_NOEXCEPTION" make + after_success: + - make clean + - CPPFLAGS="-DJSON_NOEXCEPTION" make check TEST_PATTERN=-e \"*\"" # Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/) From e3e941ef2b9a5405cff77c64e52b3c5f20567029 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 12 Mar 2017 11:19:27 +0100 Subject: [PATCH 14/14] :construction_worker: fixed a syntax error --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5060b728..dcf7b6a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -84,7 +84,7 @@ matrix: packages: [g++-4.9, cppcheck] after_success: - make clean - - CPPFLAGS="-DJSON_NOEXCEPTION" make check TEST_PATTERN=-e \"*\"" + - CPPFLAGS="-DJSON_NOEXCEPTION" make check TEST_PATTERN="-e \"*\"" # Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/)