some fixes and cleanup

This commit is contained in:
Niels 2015-02-13 21:46:33 +01:00
parent 36e36bf84a
commit 005a5c2858
5 changed files with 395 additions and 775 deletions

View file

@ -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

View file

@ -1,32 +0,0 @@
.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

View file

@ -1,14 +0,0 @@
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

View file

@ -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
} }
/// 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
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
// increase indentation // increase indentation
if (prettyPrint) if (prettyPrint)
{ {
currentIndent += indentStep; new_indent += indentStep;
result += "\n"; result += "\n";
} }
@ -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
// increase indentation // increase indentation
if (prettyPrint) if (prettyPrint)
{ {
currentIndent += indentStep; new_indent += indentStep;
result += "\n"; result += "\n";
} }
@ -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";
} }
@ -2481,8 +2494,7 @@ class basic_json
{ {
char yych; char yych;
unsigned int yyaccept = 0; unsigned int yyaccept = 0;
static const unsigned char yybm[] = static const unsigned char yybm[] = {
{
0, 64, 64, 64, 64, 64, 64, 64, 0, 64, 64, 64, 64, 64, 64, 64,
64, 96, 96, 64, 64, 96, 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,
@ -2518,132 +2530,55 @@ class basic_json
}; };
yych = *m_cursor; yych = *m_cursor;
if (yych <= '9') if (yych <= '9') {
{ if (yych <= ' ') {
if (yych <= ' ') if (yych <= '\n') {
{ if (yych <= 0x00) goto json_parser_27;
if (yych <= '\n') if (yych <= 0x08) goto json_parser_29;
{ if (yych <= '\t') goto json_parser_3;
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; goto json_parser_4;
} } else {
else if (yych == '\r') goto json_parser_3;
{ if (yych <= 0x1F) goto json_parser_29;
if (yych == '\r')
{
goto json_parser_3; goto json_parser_3;
} }
if (yych <= 0x1F) } else {
{ if (yych <= ',') {
goto json_parser_29; if (yych == '"') goto json_parser_26;
} if (yych <= '+') 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; goto json_parser_14;
} } else {
else if (yych <= '-') goto json_parser_22;
{ if (yych <= '/') goto json_parser_29;
if (yych <= '-') if (yych <= '0') goto json_parser_23;
{
goto json_parser_22;
}
if (yych <= '/')
{
goto json_parser_29;
}
if (yych <= '0')
{
goto json_parser_23;
}
goto json_parser_25; goto json_parser_25;
} }
} }
} } else {
else if (yych <= 'm') {
{ if (yych <= '\\') {
if (yych <= 'm') if (yych <= ':') goto json_parser_16;
{ if (yych == '[') goto json_parser_6;
if (yych <= '\\') goto json_parser_29;
{ } else {
if (yych <= ':') if (yych <= ']') goto json_parser_8;
{ if (yych == 'f') goto json_parser_21;
goto json_parser_16;
}
if (yych == '[')
{
goto json_parser_6;
}
goto json_parser_29; goto json_parser_29;
} }
else } else {
{ if (yych <= 'z') {
if (yych <= ']') if (yych <= 'n') goto json_parser_18;
{ if (yych == 't') goto json_parser_20;
goto json_parser_8;
}
if (yych == 'f')
{
goto json_parser_21;
}
goto json_parser_29; goto json_parser_29;
} } else {
} if (yych <= '{') goto json_parser_10;
else if (yych == '}') goto json_parser_12;
{
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; 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;
@ -2651,108 +2586,61 @@ 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_55;
}
goto json_parser_19; 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_50;
}
goto json_parser_19; 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;
}
if (yych <= '0')
{
goto json_parser_49;
}
if (yych <= '9')
{
goto json_parser_40;
}
goto json_parser_19; 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);
@ -2760,16 +2648,11 @@ json_parser_25:
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_19;
}
goto json_parser_31; 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;
@ -2777,225 +2660,99 @@ 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) if (yych <= 0x00) goto json_parser_32;
{ if (yych <= '"') goto json_parser_34;
goto json_parser_32;
}
if (yych <= '"')
{
goto json_parser_34;
}
goto json_parser_33; 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 {
else
{
goto json_parser_24; 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; goto json_parser_30;
} } else {
if (yych <= '.') if (yych <= '\\') {
{ if (yych <= '[') goto json_parser_32;
goto json_parser_32;
}
goto json_parser_30; goto json_parser_30;
} } else {
else if (yych == 'b') goto json_parser_30;
{
if (yych <= '\\')
{
if (yych <= '[')
{
goto json_parser_32;
}
goto json_parser_30;
}
else
{
if (yych == 'b')
{
goto json_parser_30;
}
goto json_parser_32; goto json_parser_32;
} }
} }
} } else {
else if (yych <= 'q') {
{ if (yych <= 'f') goto json_parser_30;
if (yych <= 'q') if (yych == 'n') goto json_parser_30;
{
if (yych <= 'f')
{
goto json_parser_30;
}
if (yych == 'n')
{
goto json_parser_30;
}
goto json_parser_32; goto json_parser_32;
} } else {
else if (yych <= 's') {
{ if (yych <= 'r') goto json_parser_30;
if (yych <= 's')
{
if (yych <= 'r')
{
goto json_parser_30;
}
goto json_parser_32; goto json_parser_32;
} } else {
else if (yych <= 't') goto json_parser_30;
{ if (yych <= 'u') goto json_parser_36;
if (yych <= 't')
{
goto json_parser_30;
}
if (yych <= 'u')
{
goto json_parser_36;
}
goto json_parser_32; 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 <= '9') if (yych <= 'F') goto json_parser_30;
{ if (yych <= '`') goto json_parser_32;
goto json_parser_30; if (yych <= 'f') goto json_parser_30;
}
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; goto json_parser_32;
} }
json_parser_40: json_parser_40:
@ -3003,188 +2760,88 @@ json_parser_40:
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;
if (yych != '.') } else {
{ if (yych <= 'E') goto json_parser_43;
goto json_parser_24; if (yych == 'e') goto json_parser_43;
}
}
else
{
if (yych <= 'E')
{
goto json_parser_43;
}
if (yych == 'e')
{
goto json_parser_43;
}
goto json_parser_24; 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;
}
if (yych <= '9')
{
goto json_parser_47;
}
goto json_parser_32; 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;
}
else
{
if (yych <= '-')
{
goto json_parser_44;
}
if (yych <= '/')
{
goto json_parser_32;
}
if (yych <= '9')
{
goto json_parser_45;
}
goto json_parser_32; 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;
}
if (yych <= '9')
{
goto json_parser_45;
}
goto json_parser_24; 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 <= '9') if (yych <= 'E') goto json_parser_43;
{ if (yych == 'e') goto json_parser_43;
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; 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_42;
}
goto json_parser_24; goto json_parser_24;
} } else {
else if (yych <= 'E') goto json_parser_43;
{ if (yych == 'e') goto json_parser_43;
if (yych <= 'E')
{
goto json_parser_43;
}
if (yych == 'e')
{
goto json_parser_43;
}
goto json_parser_24; 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;
{
goto json_parser_32;
}
yych = *++m_cursor; yych = *++m_cursor;
if (yych != 's') if (yych != 's') goto json_parser_32;
{
goto json_parser_32;
}
yych = *++m_cursor; yych = *++m_cursor;
if (yych != 'e') if (yych != 'e') goto json_parser_32;
{
goto json_parser_32;
}
++m_cursor; ++m_cursor;
{ { return token_type::literal_false; }
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;
{
goto json_parser_32;
}
yych = *++m_cursor; yych = *++m_cursor;
if (yych != 'e') if (yych != 'e') goto json_parser_32;
{
goto json_parser_32;
}
++m_cursor; ++m_cursor;
{ { return token_type::literal_true; }
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;
{
goto json_parser_32;
}
yych = *++m_cursor; yych = *++m_cursor;
if (yych != 'l') if (yych != 'l') goto json_parser_32;
{
goto json_parser_32;
}
++m_cursor; ++m_cursor;
{ { return token_type::literal_null; }
return token_type::literal_null;
}
} }
} }

View file

@ -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
} }
/// 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
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
// increase indentation // increase indentation
if (prettyPrint) if (prettyPrint)
{ {
currentIndent += indentStep; new_indent += indentStep;
result += "\n"; result += "\n";
} }
@ -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
// increase indentation // increase indentation
if (prettyPrint) if (prettyPrint)
{ {
currentIndent += indentStep; new_indent += indentStep;
result += "\n"; result += "\n";
} }
@ -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";
} }