Commit 005a5c28 authored by Niels's avatar Niels

some fixes and cleanup

parent 36e36bf8
...@@ -9,11 +9,7 @@ before_install: ...@@ -9,11 +9,7 @@ before_install:
- if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.9; fi - if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.9; fi
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
- sudo pip install cpp-coveralls pyyaml - sudo pip install cpp-coveralls pyyaml
- sudo apt-get install valgrind re2c - sudo apt-get install valgrind
before_script:
- autoreconf -iv
- ./configure
script: script:
- make - make
......
.PHONY: header_only
noinst_PROGRAMS = json_unit
FLAGS = -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder
json_unit_SOURCES = src/json.hpp test/catch.hpp test/unit.cpp
json_unit_CXXFLAGS = $(FLAGS) -std=c++11
json_unit_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/test -Dprivate=public
# parameters:
# -b use bit vectors
# -s nested ifs
# -i do not create #line information
# --no-generation-date suppress generation date output
src/json.hpp: src/json.hpp.re2c
$(AM_V_GEN)$(RE2C) -b -s -i --no-generation-date $< | $(SED) '1d' > $@
cppcheck:
cppcheck --enable=all --inconclusive --std=c++11 src/json.hpp
svn-clean: maintainer-clean
rm -fr configure INSTALL aclocal.m4 build-aux depcomp install-sh missing test-driver
for DIR in $(DIST_SUBDIRS) .; do rm -f $$DIR/Makefile.in; done
pretty:
astyle --style=allman --indent=spaces=4 --indent-modifiers \
--indent-switches --indent-preproc-block --indent-preproc-define \
--indent-col1-comments --pad-oper --pad-header --align-pointer=type \
--align-reference=type --add-brackets --convert-tabs --close-templates \
--lineend=linux --preserve-date --suffix=none \
src/json.hpp src/json.hpp.re2c test/unit.cpp
AC_INIT([JSON], [3.0], [mail@nlohmann.me])
AC_CONFIG_SRCDIR([src/json.hpp.re2c])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AM_SILENT_RULES([yes])
AC_PROG_CXX
AC_PROG_SED
AM_MISSING_PROG(RE2C, [re2c])
AM_MISSING_PROG(CPPCHECK, [cppcheck])
AM_MISSING_PROG(ASTYLE, [astyle])
AC_CONFIG_FILES(Makefile)
AC_OUTPUT
...@@ -454,7 +454,12 @@ class basic_json ...@@ -454,7 +454,12 @@ class basic_json
} }
/// copy assignment /// copy assignment
inline reference& operator=(basic_json other) noexcept inline reference& operator=(basic_json other) noexcept (
std::is_nothrow_move_constructible<value_t>::value and
std::is_nothrow_move_assignable<value_t>::value and
std::is_nothrow_move_constructible<json_value>::value and
std::is_nothrow_move_assignable<json_value>::value
)
{ {
std::swap(m_type, other.m_type); std::swap(m_type, other.m_type);
std::swap(m_value, other.m_value); std::swap(m_value, other.m_value);
...@@ -1043,7 +1048,12 @@ class basic_json ...@@ -1043,7 +1048,12 @@ class basic_json
} }
/// swaps the contents /// swaps the contents
inline void swap(reference other) noexcept inline void swap(reference other) noexcept (
std::is_nothrow_move_constructible<value_t>::value and
std::is_nothrow_move_assignable<value_t>::value and
std::is_nothrow_move_constructible<json_value>::value and
std::is_nothrow_move_assignable<json_value>::value
)
{ {
std::swap(m_type, other.m_type); std::swap(m_type, other.m_type);
std::swap(m_value, other.m_value); std::swap(m_value, other.m_value);
...@@ -1464,10 +1474,13 @@ class basic_json ...@@ -1464,10 +1474,13 @@ class basic_json
inline string_t dump(const bool prettyPrint, const unsigned int indentStep, inline string_t dump(const bool prettyPrint, const unsigned int indentStep,
unsigned int currentIndent = 0) const noexcept unsigned int currentIndent = 0) const noexcept
{ {
// variable to hold indentation for recursive calls
auto new_indent = currentIndent;
// helper function to return whitespace as indentation // helper function to return whitespace as indentation
const auto indent = [prettyPrint, &currentIndent]() const auto indent = [prettyPrint, &new_indent]()
{ {
return prettyPrint ? string_t(currentIndent, ' ') : string_t(); return prettyPrint ? string_t(new_indent, ' ') : string_t();
}; };
switch (m_type) switch (m_type)
...@@ -1484,7 +1497,7 @@ class basic_json ...@@ -1484,7 +1497,7 @@ class basic_json
// increase indentation // increase indentation
if (prettyPrint) if (prettyPrint)
{ {
currentIndent += indentStep; new_indent += indentStep;
result += "\n"; result += "\n";
} }
...@@ -1495,13 +1508,13 @@ class basic_json ...@@ -1495,13 +1508,13 @@ class basic_json
result += prettyPrint ? ",\n" : ","; result += prettyPrint ? ",\n" : ",";
} }
result += indent() + "\"" + escape_string(i->first) + "\":" + (prettyPrint ? " " : "") result += indent() + "\"" + escape_string(i->first) + "\":" + (prettyPrint ? " " : "")
+ i->second.dump(prettyPrint, indentStep, currentIndent); + i->second.dump(prettyPrint, indentStep, new_indent);
} }
// decrease indentation // decrease indentation
if (prettyPrint) if (prettyPrint)
{ {
currentIndent -= indentStep; new_indent -= indentStep;
result += "\n"; result += "\n";
} }
...@@ -1520,7 +1533,7 @@ class basic_json ...@@ -1520,7 +1533,7 @@ class basic_json
// increase indentation // increase indentation
if (prettyPrint) if (prettyPrint)
{ {
currentIndent += indentStep; new_indent += indentStep;
result += "\n"; result += "\n";
} }
...@@ -1530,13 +1543,13 @@ class basic_json ...@@ -1530,13 +1543,13 @@ class basic_json
{ {
result += prettyPrint ? ",\n" : ","; result += prettyPrint ? ",\n" : ",";
} }
result += indent() + i->dump(prettyPrint, indentStep, currentIndent); result += indent() + i->dump(prettyPrint, indentStep, new_indent);
} }
// decrease indentation // decrease indentation
if (prettyPrint) if (prettyPrint)
{ {
currentIndent -= indentStep; new_indent -= indentStep;
result += "\n"; result += "\n";
} }
...@@ -2477,715 +2490,359 @@ class basic_json ...@@ -2477,715 +2490,359 @@ class basic_json
// remember the begin of the token // remember the begin of the token
m_start = m_cursor; m_start = m_cursor;
{
char yych;
unsigned int yyaccept = 0;
static const unsigned char yybm[] = {
0, 64, 64, 64, 64, 64, 64, 64,
64, 96, 96, 64, 64, 96, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
96, 64, 0, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 0, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
};
{ yych = *m_cursor;
char yych; if (yych <= '9') {
unsigned int yyaccept = 0; if (yych <= ' ') {
static const unsigned char yybm[] = if (yych <= '\n') {
{ if (yych <= 0x00) goto json_parser_27;
0, 64, 64, 64, 64, 64, 64, 64, if (yych <= 0x08) goto json_parser_29;
64, 96, 96, 64, 64, 96, 64, 64, if (yych <= '\t') goto json_parser_3;
64, 64, 64, 64, 64, 64, 64, 64, goto json_parser_4;
64, 64, 64, 64, 64, 64, 64, 64, } else {
96, 64, 0, 64, 64, 64, 64, 64, if (yych == '\r') goto json_parser_3;
64, 64, 64, 64, 64, 64, 64, 64, if (yych <= 0x1F) goto json_parser_29;
192, 192, 192, 192, 192, 192, 192, 192, goto json_parser_3;
192, 192, 64, 64, 64, 64, 64, 64, }
64, 64, 64, 64, 64, 64, 64, 64, } else {
64, 64, 64, 64, 64, 64, 64, 64, if (yych <= ',') {
64, 64, 64, 64, 64, 64, 64, 64, if (yych == '"') goto json_parser_26;
64, 64, 64, 64, 0, 64, 64, 64, if (yych <= '+') goto json_parser_29;
64, 64, 64, 64, 64, 64, 64, 64, goto json_parser_14;
64, 64, 64, 64, 64, 64, 64, 64, } else {
64, 64, 64, 64, 64, 64, 64, 64, if (yych <= '-') goto json_parser_22;
64, 64, 64, 64, 64, 64, 64, 64, if (yych <= '/') goto json_parser_29;
64, 64, 64, 64, 64, 64, 64, 64, if (yych <= '0') goto json_parser_23;
64, 64, 64, 64, 64, 64, 64, 64, goto json_parser_25;
64, 64, 64, 64, 64, 64, 64, 64, }
64, 64, 64, 64, 64, 64, 64, 64, }
64, 64, 64, 64, 64, 64, 64, 64, } else {
64, 64, 64, 64, 64, 64, 64, 64, if (yych <= 'm') {
64, 64, 64, 64, 64, 64, 64, 64, if (yych <= '\\') {
64, 64, 64, 64, 64, 64, 64, 64, if (yych <= ':') goto json_parser_16;
64, 64, 64, 64, 64, 64, 64, 64, if (yych == '[') goto json_parser_6;
64, 64, 64, 64, 64, 64, 64, 64, goto json_parser_29;
64, 64, 64, 64, 64, 64, 64, 64, } else {
64, 64, 64, 64, 64, 64, 64, 64, if (yych <= ']') goto json_parser_8;
64, 64, 64, 64, 64, 64, 64, 64, if (yych == 'f') goto json_parser_21;
64, 64, 64, 64, 64, 64, 64, 64, goto json_parser_29;
64, 64, 64, 64, 64, 64, 64, 64, }
64, 64, 64, 64, 64, 64, 64, 64, } else {
}; if (yych <= 'z') {
if (yych <= 'n') goto json_parser_18;
yych = *m_cursor; if (yych == 't') goto json_parser_20;
if (yych <= '9') goto json_parser_29;
{ } else {
if (yych <= ' ') if (yych <= '{') goto json_parser_10;
{ if (yych == '}') goto json_parser_12;
if (yych <= '\n') goto json_parser_29;
{
if (yych <= 0x00)
{
goto json_parser_27;
}
if (yych <= 0x08)
{
goto json_parser_29;
}
if (yych <= '\t')
{
goto json_parser_3;
}
goto json_parser_4;
}
else
{
if (yych == '\r')
{
goto json_parser_3;
}
if (yych <= 0x1F)
{
goto json_parser_29;
}
goto json_parser_3;
}
}
else
{
if (yych <= ',')
{
if (yych == '"')
{
goto json_parser_26;
}
if (yych <= '+')
{
goto json_parser_29;
}
goto json_parser_14;
}
else
{
if (yych <= '-')
{
goto json_parser_22;
}
if (yych <= '/')
{
goto json_parser_29;
}
if (yych <= '0')
{
goto json_parser_23;
}
goto json_parser_25;
}
}
}
else
{
if (yych <= 'm')
{
if (yych <= '\\')
{
if (yych <= ':')
{
goto json_parser_16;
}
if (yych == '[')
{
goto json_parser_6;
}
goto json_parser_29;
}
else
{
if (yych <= ']')
{
goto json_parser_8;
}
if (yych == 'f')
{
goto json_parser_21;
}
goto json_parser_29;
}
}
else
{
if (yych <= 'z')
{
if (yych <= 'n')
{
goto json_parser_18;
}
if (yych == 't')
{
goto json_parser_20;
}
goto json_parser_29;
}
else
{
if (yych <= '{')
{
goto json_parser_10;
}
if (yych == '}')
{
goto json_parser_12;
}
goto json_parser_29;
}
}
} }
}
}
json_parser_2: json_parser_2:
{ { return scan(); }
return scan();
}
json_parser_3: json_parser_3:
yych = *++m_cursor; yych = *++m_cursor;
goto json_parser_5; goto json_parser_5;
json_parser_4: json_parser_4:
++m_cursor; ++m_cursor;
yych = *m_cursor; yych = *m_cursor;
json_parser_5: json_parser_5:
if (yybm[0 + yych] & 32) if (yybm[0+yych] & 32) {
{ goto json_parser_4;
goto json_parser_4; }
} goto json_parser_2;
goto json_parser_2;
json_parser_6: json_parser_6:
++m_cursor; ++m_cursor;
{ { return token_type::begin_array; }
return token_type::begin_array;
}
json_parser_8: json_parser_8:
++m_cursor; ++m_cursor;
{ { return token_type::end_array; }
return token_type::end_array;
}
json_parser_10: json_parser_10:
++m_cursor; ++m_cursor;
{ { return token_type::begin_object; }
return token_type::begin_object;
}
json_parser_12: json_parser_12:
++m_cursor; ++m_cursor;
{ { return token_type::end_object; }
return token_type::end_object;
}
json_parser_14: json_parser_14:
++m_cursor; ++m_cursor;
{ { return token_type::value_separator; }
return token_type::value_separator;
}
json_parser_16: json_parser_16:
++m_cursor; ++m_cursor;
{ { return token_type::name_separator; }
return token_type::name_separator;
}
json_parser_18: json_parser_18:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych == 'u') if (yych == 'u') goto json_parser_59;
{
goto json_parser_59;
}
json_parser_19: json_parser_19:
{ { return token_type::parse_error; }
return token_type::parse_error;
}
json_parser_20: json_parser_20:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych == 'r') if (yych == 'r') goto json_parser_55;
{ goto json_parser_19;
goto json_parser_55;
}
goto json_parser_19;
json_parser_21: json_parser_21:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych == 'a') if (yych == 'a') goto json_parser_50;
{ goto json_parser_19;
goto json_parser_50;
}
goto json_parser_19;
json_parser_22: json_parser_22:
yych = *++m_cursor; yych = *++m_cursor;
if (yych <= '/') if (yych <= '/') goto json_parser_19;
{ if (yych <= '0') goto json_parser_49;
goto json_parser_19; if (yych <= '9') goto json_parser_40;
} goto json_parser_19;
if (yych <= '0')
{
goto json_parser_49;
}
if (yych <= '9')
{
goto json_parser_40;
}
goto json_parser_19;
json_parser_23: json_parser_23:
yyaccept = 1; yyaccept = 1;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych <= 'D') if (yych <= 'D') {
{ if (yych == '.') goto json_parser_42;
if (yych == '.') } else {
{ if (yych <= 'E') goto json_parser_43;
goto json_parser_42; if (yych == 'e') goto json_parser_43;
} }
}
else
{
if (yych <= 'E')
{
goto json_parser_43;
}
if (yych == 'e')
{
goto json_parser_43;
}
}
json_parser_24: json_parser_24:
{ { return token_type::value_number; }
return token_type::value_number;
}
json_parser_25: json_parser_25:
yyaccept = 1; yyaccept = 1;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
goto json_parser_41; goto json_parser_41;
json_parser_26: json_parser_26:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych <= 0x00) if (yych <= 0x00) goto json_parser_19;
{ goto json_parser_31;
goto json_parser_19;
}
goto json_parser_31;
json_parser_27: json_parser_27:
++m_cursor; ++m_cursor;
{ { return token_type::end_of_input; }
return token_type::end_of_input;
}
json_parser_29: json_parser_29:
yych = *++m_cursor; yych = *++m_cursor;
goto json_parser_19; goto json_parser_19;
json_parser_30: json_parser_30:
++m_cursor; ++m_cursor;
yych = *m_cursor; yych = *m_cursor;
json_parser_31: json_parser_31:
if (yybm[0 + yych] & 64) if (yybm[0+yych] & 64) {
{ goto json_parser_30;
goto json_parser_30; }
} if (yych <= 0x00) goto json_parser_32;
if (yych <= 0x00) if (yych <= '"') goto json_parser_34;
{ goto json_parser_33;
goto json_parser_32;
}
if (yych <= '"')
{
goto json_parser_34;
}
goto json_parser_33;
json_parser_32: json_parser_32:
m_cursor = m_marker; m_cursor = m_marker;
if (yyaccept == 0) if (yyaccept == 0) {
{ goto json_parser_19;
goto json_parser_19; } else {
} goto json_parser_24;
else }
{
goto json_parser_24;
}
json_parser_33: json_parser_33:
++m_cursor; ++m_cursor;
yych = *m_cursor; yych = *m_cursor;
if (yych <= 'e') if (yych <= 'e') {
{ if (yych <= '/') {
if (yych <= '/') if (yych == '"') goto json_parser_30;
{ if (yych <= '.') goto json_parser_32;
if (yych == '"') goto json_parser_30;
{ } else {
goto json_parser_30; if (yych <= '\\') {
} if (yych <= '[') goto json_parser_32;
if (yych <= '.') goto json_parser_30;
{ } else {
goto json_parser_32; if (yych == 'b') goto json_parser_30;
} goto json_parser_32;
goto json_parser_30;
}
else
{
if (yych <= '\\')
{
if (yych <= '[')
{
goto json_parser_32;
}
goto json_parser_30;
}
else
{
if (yych == 'b')
{
goto json_parser_30;
}
goto json_parser_32;
}
}
} }
else }
{ } else {
if (yych <= 'q') if (yych <= 'q') {
{ if (yych <= 'f') goto json_parser_30;
if (yych <= 'f') if (yych == 'n') goto json_parser_30;
{ goto json_parser_32;
goto json_parser_30; } else {
} if (yych <= 's') {
if (yych == 'n') if (yych <= 'r') goto json_parser_30;
{ goto json_parser_32;
goto json_parser_30; } else {
} if (yych <= 't') goto json_parser_30;
goto json_parser_32; if (yych <= 'u') goto json_parser_36;
} goto json_parser_32;
else
{
if (yych <= 's')
{
if (yych <= 'r')
{
goto json_parser_30;
}
goto json_parser_32;
}
else
{
if (yych <= 't')
{
goto json_parser_30;
}
if (yych <= 'u')
{
goto json_parser_36;
}
goto json_parser_32;
}
}
} }
}
}
json_parser_34: json_parser_34:
++m_cursor; ++m_cursor;
{ { return token_type::value_string; }
return token_type::value_string;
}
json_parser_36: json_parser_36:
++m_cursor; ++m_cursor;
yych = *m_cursor; yych = *m_cursor;
if (yych <= '@') if (yych <= '@') {
{ if (yych <= '/') goto json_parser_32;
if (yych <= '/') if (yych >= ':') goto json_parser_32;
{ } else {
goto json_parser_32; if (yych <= 'F') goto json_parser_37;
} if (yych <= '`') goto json_parser_32;
if (yych >= ':') if (yych >= 'g') goto json_parser_32;
{ }
goto json_parser_32;
}
}
else
{
if (yych <= 'F')
{
goto json_parser_37;
}
if (yych <= '`')
{
goto json_parser_32;
}
if (yych >= 'g')
{
goto json_parser_32;
}
}
json_parser_37: json_parser_37:
++m_cursor; ++m_cursor;
yych = *m_cursor; yych = *m_cursor;
if (yych <= '@') if (yych <= '@') {
{ if (yych <= '/') goto json_parser_32;
if (yych <= '/') if (yych >= ':') goto json_parser_32;
{ } else {
goto json_parser_32; if (yych <= 'F') goto json_parser_38;
} if (yych <= '`') goto json_parser_32;
if (yych >= ':') if (yych >= 'g') goto json_parser_32;
{ }
goto json_parser_32;
}
}
else
{
if (yych <= 'F')
{
goto json_parser_38;
}
if (yych <= '`')
{
goto json_parser_32;
}
if (yych >= 'g')
{
goto json_parser_32;
}
}
json_parser_38: json_parser_38:
++m_cursor; ++m_cursor;
yych = *m_cursor; yych = *m_cursor;
if (yych <= '@') if (yych <= '@') {
{ if (yych <= '/') goto json_parser_32;
if (yych <= '/') if (yych >= ':') goto json_parser_32;
{ } else {
goto json_parser_32; if (yych <= 'F') goto json_parser_39;
} if (yych <= '`') goto json_parser_32;
if (yych >= ':') if (yych >= 'g') goto json_parser_32;
{ }
goto json_parser_32;
}
}
else
{
if (yych <= 'F')
{
goto json_parser_39;
}
if (yych <= '`')
{
goto json_parser_32;
}
if (yych >= 'g')
{
goto json_parser_32;
}
}
json_parser_39: json_parser_39:
++m_cursor; ++m_cursor;
yych = *m_cursor; yych = *m_cursor;
if (yych <= '@') if (yych <= '@') {
{ if (yych <= '/') goto json_parser_32;
if (yych <= '/') if (yych <= '9') goto json_parser_30;
{ goto json_parser_32;
goto json_parser_32; } else {
} if (yych <= 'F') goto json_parser_30;
if (yych <= '9') if (yych <= '`') goto json_parser_32;
{ if (yych <= 'f') goto json_parser_30;
goto json_parser_30; goto json_parser_32;
} }
goto json_parser_32;
}
else
{
if (yych <= 'F')
{
goto json_parser_30;
}
if (yych <= '`')
{
goto json_parser_32;
}
if (yych <= 'f')
{
goto json_parser_30;
}
goto json_parser_32;
}
json_parser_40: json_parser_40:
yyaccept = 1; yyaccept = 1;
m_marker = ++m_cursor; m_marker = ++m_cursor;
yych = *m_cursor; yych = *m_cursor;
json_parser_41: json_parser_41:
if (yybm[0 + yych] & 128) if (yybm[0+yych] & 128) {
{ goto json_parser_40;
goto json_parser_40; }
} if (yych <= 'D') {
if (yych <= 'D') if (yych != '.') goto json_parser_24;
{ } else {
if (yych != '.') if (yych <= 'E') goto json_parser_43;
{ if (yych == 'e') goto json_parser_43;
goto json_parser_24; goto json_parser_24;
} }
}
else
{
if (yych <= 'E')
{
goto json_parser_43;
}
if (yych == 'e')
{
goto json_parser_43;
}
goto json_parser_24;
}
json_parser_42: json_parser_42:
yych = *++m_cursor; yych = *++m_cursor;
if (yych <= '/') if (yych <= '/') goto json_parser_32;
{ if (yych <= '9') goto json_parser_47;
goto json_parser_32; goto json_parser_32;
}
if (yych <= '9')
{
goto json_parser_47;
}
goto json_parser_32;
json_parser_43: json_parser_43:
yych = *++m_cursor; yych = *++m_cursor;
if (yych <= ',') if (yych <= ',') {
{ if (yych != '+') goto json_parser_32;
if (yych != '+') } else {
{ if (yych <= '-') goto json_parser_44;
goto json_parser_32; if (yych <= '/') goto json_parser_32;
} if (yych <= '9') goto json_parser_45;
} goto json_parser_32;
else }
{
if (yych <= '-')
{
goto json_parser_44;
}
if (yych <= '/')
{
goto json_parser_32;
}
if (yych <= '9')
{
goto json_parser_45;
}
goto json_parser_32;
}
json_parser_44: json_parser_44:
yych = *++m_cursor; yych = *++m_cursor;
if (yych <= '/') if (yych <= '/') goto json_parser_32;
{ if (yych >= ':') goto json_parser_32;
goto json_parser_32;
}
if (yych >= ':')
{
goto json_parser_32;
}
json_parser_45: json_parser_45:
++m_cursor; ++m_cursor;
yych = *m_cursor; yych = *m_cursor;
if (yych <= '/') if (yych <= '/') goto json_parser_24;
{ if (yych <= '9') goto json_parser_45;
goto json_parser_24; goto json_parser_24;
}
if (yych <= '9')
{
goto json_parser_45;
}
goto json_parser_24;
json_parser_47: json_parser_47:
yyaccept = 1; yyaccept = 1;
m_marker = ++m_cursor; m_marker = ++m_cursor;
yych = *m_cursor; yych = *m_cursor;
if (yych <= 'D') if (yych <= 'D') {
{ if (yych <= '/') goto json_parser_24;
if (yych <= '/') if (yych <= '9') goto json_parser_47;
{ goto json_parser_24;
goto json_parser_24; } else {
} if (yych <= 'E') goto json_parser_43;
if (yych <= '9') if (yych == 'e') goto json_parser_43;
{ goto json_parser_24;
goto json_parser_47; }
}
goto json_parser_24;
}
else
{
if (yych <= 'E')
{
goto json_parser_43;
}
if (yych == 'e')
{
goto json_parser_43;
}
goto json_parser_24;
}
json_parser_49: json_parser_49:
yyaccept = 1; yyaccept = 1;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych <= 'D') if (yych <= 'D') {
{ if (yych == '.') goto json_parser_42;
if (yych == '.') goto json_parser_24;
{ } else {
goto json_parser_42; if (yych <= 'E') goto json_parser_43;
} if (yych == 'e') goto json_parser_43;
goto json_parser_24; goto json_parser_24;
} }
else
{
if (yych <= 'E')
{
goto json_parser_43;
}
if (yych == 'e')
{
goto json_parser_43;
}
goto json_parser_24;
}
json_parser_50: json_parser_50:
yych = *++m_cursor; yych = *++m_cursor;
if (yych != 'l') if (yych != 'l') goto json_parser_32;
{ yych = *++m_cursor;
goto json_parser_32; if (yych != 's') goto json_parser_32;
} yych = *++m_cursor;
yych = *++m_cursor; if (yych != 'e') goto json_parser_32;
if (yych != 's') ++m_cursor;
{ { return token_type::literal_false; }
goto json_parser_32;
}
yych = *++m_cursor;
if (yych != 'e')
{
goto json_parser_32;
}
++m_cursor;
{
return token_type::literal_false;
}
json_parser_55: json_parser_55:
yych = *++m_cursor; yych = *++m_cursor;
if (yych != 'u') if (yych != 'u') goto json_parser_32;
{ yych = *++m_cursor;
goto json_parser_32; if (yych != 'e') goto json_parser_32;
} ++m_cursor;
yych = *++m_cursor; { return token_type::literal_true; }
if (yych != 'e')
{
goto json_parser_32;
}
++m_cursor;
{
return token_type::literal_true;
}
json_parser_59: json_parser_59:
yych = *++m_cursor; yych = *++m_cursor;
if (yych != 'l') if (yych != 'l') goto json_parser_32;
{ yych = *++m_cursor;
goto json_parser_32; if (yych != 'l') goto json_parser_32;
} ++m_cursor;
yych = *++m_cursor; { return token_type::literal_null; }
if (yych != 'l') }
{
goto json_parser_32;
}
++m_cursor;
{
return token_type::literal_null;
}
}
} }
......
...@@ -454,7 +454,12 @@ class basic_json ...@@ -454,7 +454,12 @@ class basic_json
} }
/// copy assignment /// copy assignment
inline reference& operator=(basic_json other) noexcept inline reference& operator=(basic_json other) noexcept (
std::is_nothrow_move_constructible<value_t>::value and
std::is_nothrow_move_assignable<value_t>::value and
std::is_nothrow_move_constructible<json_value>::value and
std::is_nothrow_move_assignable<json_value>::value
)
{ {
std::swap(m_type, other.m_type); std::swap(m_type, other.m_type);
std::swap(m_value, other.m_value); std::swap(m_value, other.m_value);
...@@ -1043,7 +1048,12 @@ class basic_json ...@@ -1043,7 +1048,12 @@ class basic_json
} }
/// swaps the contents /// swaps the contents
inline void swap(reference other) noexcept inline void swap(reference other) noexcept (
std::is_nothrow_move_constructible<value_t>::value and
std::is_nothrow_move_assignable<value_t>::value and
std::is_nothrow_move_constructible<json_value>::value and
std::is_nothrow_move_assignable<json_value>::value
)
{ {
std::swap(m_type, other.m_type); std::swap(m_type, other.m_type);
std::swap(m_value, other.m_value); std::swap(m_value, other.m_value);
...@@ -1464,10 +1474,13 @@ class basic_json ...@@ -1464,10 +1474,13 @@ class basic_json
inline string_t dump(const bool prettyPrint, const unsigned int indentStep, inline string_t dump(const bool prettyPrint, const unsigned int indentStep,
unsigned int currentIndent = 0) const noexcept unsigned int currentIndent = 0) const noexcept
{ {
// variable to hold indentation for recursive calls
auto new_indent = currentIndent;
// helper function to return whitespace as indentation // helper function to return whitespace as indentation
const auto indent = [prettyPrint, &currentIndent]() const auto indent = [prettyPrint, &new_indent]()
{ {
return prettyPrint ? string_t(currentIndent, ' ') : string_t(); return prettyPrint ? string_t(new_indent, ' ') : string_t();
}; };
switch (m_type) switch (m_type)
...@@ -1484,7 +1497,7 @@ class basic_json ...@@ -1484,7 +1497,7 @@ class basic_json
// increase indentation // increase indentation
if (prettyPrint) if (prettyPrint)
{ {
currentIndent += indentStep; new_indent += indentStep;
result += "\n"; result += "\n";
} }
...@@ -1495,13 +1508,13 @@ class basic_json ...@@ -1495,13 +1508,13 @@ class basic_json
result += prettyPrint ? ",\n" : ","; result += prettyPrint ? ",\n" : ",";
} }
result += indent() + "\"" + escape_string(i->first) + "\":" + (prettyPrint ? " " : "") result += indent() + "\"" + escape_string(i->first) + "\":" + (prettyPrint ? " " : "")
+ i->second.dump(prettyPrint, indentStep, currentIndent); + i->second.dump(prettyPrint, indentStep, new_indent);
} }
// decrease indentation // decrease indentation
if (prettyPrint) if (prettyPrint)
{ {
currentIndent -= indentStep; new_indent -= indentStep;
result += "\n"; result += "\n";
} }
...@@ -1520,7 +1533,7 @@ class basic_json ...@@ -1520,7 +1533,7 @@ class basic_json
// increase indentation // increase indentation
if (prettyPrint) if (prettyPrint)
{ {
currentIndent += indentStep; new_indent += indentStep;
result += "\n"; result += "\n";
} }
...@@ -1530,13 +1543,13 @@ class basic_json ...@@ -1530,13 +1543,13 @@ class basic_json
{ {
result += prettyPrint ? ",\n" : ","; result += prettyPrint ? ",\n" : ",";
} }
result += indent() + i->dump(prettyPrint, indentStep, currentIndent); result += indent() + i->dump(prettyPrint, indentStep, new_indent);
} }
// decrease indentation // decrease indentation
if (prettyPrint) if (prettyPrint)
{ {
currentIndent -= indentStep; new_indent -= indentStep;
result += "\n"; result += "\n";
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment