diff --git a/Doxyfile b/Doxyfile
index 9d827589..cbf2bb99 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -83,7 +83,7 @@ GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = NO
-SHOW_FILES = YES
+SHOW_FILES = NO
SHOW_NAMESPACES = NO
FILE_VERSION_FILTER =
LAYOUT_FILE =
@@ -153,11 +153,11 @@ HTML_COLORSTYLE_GAMMA = 80
HTML_TIMESTAMP = YES
HTML_DYNAMIC_SECTIONS = NO
HTML_INDEX_NUM_ENTRIES = 100
-GENERATE_DOCSET = NO
+GENERATE_DOCSET = YES
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_BUNDLE_ID = me.nlohmann.json
DOCSET_PUBLISHER_ID = me.nlohmann
-DOCSET_PUBLISHER_NAME = Publisher
+DOCSET_PUBLISHER_NAME = Niels Lohmann
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
diff --git a/Makefile b/Makefile
index 7b043f95..c927a511 100644
--- a/Makefile
+++ b/Makefile
@@ -15,6 +15,24 @@ clean:
json_unit: test/unit.cpp src/json.hpp test/catch.hpp
$(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src -I test $< $(LDFLAGS) -o $@
+check: json_unit
+ ./json_unit "*"
+ make check -C docs/examples
+
+docset:
+ cp Doxyfile Doxyfile_docset
+ gsed -i 's/DISABLE_INDEX = NO/DISABLE_INDEX = YES/' Doxyfile_docset
+ gsed -i 's/SEARCHENGINE = YES/SEARCHENGINE = NO/' Doxyfile_docset
+ gsed -i 's/GENERATE_TREEVIEW = YES/GENERATE_TREEVIEW = NO/' Doxyfile_docset
+ gsed -i 's/SEPARATE_MEMBER_PAGES = NO/SEPARATE_MEMBER_PAGES = YES/' Doxyfile_docset
+ gsed -i 's/BINARY_TOC = YES/BINARY_TOC = NO/' Doxyfile_docset
+ rm -fr html *.docset
+ doxygen Doxyfile_docset
+ make -C html
+ mv html/*.docset .
+ gsed -i 's@doxygen@json@' me.nlohmann.json.docset/Contents/Info.plist
+ rm -fr Doxyfile_docset html
+
# create scanner with re2c
re2c: src/json.hpp.re2c
$(RE2C) -b -s -i --no-generation-date $< | $(SED) '1d' > src/json.hpp
diff --git a/docs/examples/back.cpp b/docs/examples/back.cpp
new file mode 100644
index 00000000..581d376d
--- /dev/null
+++ b/docs/examples/back.cpp
@@ -0,0 +1,28 @@
+#include
+
+using namespace nlohmann;
+
+int main()
+{
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_object_empty(json::value_t::object);
+ json j_array = {1, 2, 4, 8, 16};
+ json j_array_empty(json::value_t::array);
+ json j_string = "Hello, world";
+
+ // call back()
+ //std::cout << j_null.back() << '\n'; // would throw
+ std::cout << j_boolean.back() << '\n';
+ std::cout << j_number_integer.back() << '\n';
+ std::cout << j_number_float.back() << '\n';
+ std::cout << j_object.back() << '\n';
+ //std::cout << j_object_empty.back() << '\n'; // would throw
+ std::cout << j_array.back() << '\n';
+ //std::cout << j_array_empty.back() << '\n'; // would throw
+ std::cout << j_string.back() << '\n';
+}
diff --git a/docs/examples/back.output b/docs/examples/back.output
new file mode 100644
index 00000000..159ba0fc
--- /dev/null
+++ b/docs/examples/back.output
@@ -0,0 +1,6 @@
+true
+17
+23.42
+2
+16
+"Hello, world"
diff --git a/docs/examples/front.cpp b/docs/examples/front.cpp
new file mode 100644
index 00000000..8ed35764
--- /dev/null
+++ b/docs/examples/front.cpp
@@ -0,0 +1,28 @@
+#include
+
+using namespace nlohmann;
+
+int main()
+{
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_object_empty(json::value_t::object);
+ json j_array = {1, 2, 4, 8, 16};
+ json j_array_empty(json::value_t::array);
+ json j_string = "Hello, world";
+
+ // call front()
+ //std::cout << j_null.front() << '\n'; // would throw
+ std::cout << j_boolean.front() << '\n';
+ std::cout << j_number_integer.front() << '\n';
+ std::cout << j_number_float.front() << '\n';
+ std::cout << j_object.front() << '\n';
+ //std::cout << j_object_empty.front() << '\n'; // would throw
+ std::cout << j_array.front() << '\n';
+ //std::cout << j_array_empty.front() << '\n'; // would throw
+ std::cout << j_string.front() << '\n';
+}
diff --git a/docs/examples/front.output b/docs/examples/front.output
new file mode 100644
index 00000000..6301db53
--- /dev/null
+++ b/docs/examples/front.output
@@ -0,0 +1,6 @@
+true
+17
+23.42
+1
+1
+"Hello, world"
diff --git a/src/json.hpp b/src/json.hpp
index 262552e7..3e018944 100644
--- a/src/json.hpp
+++ b/src/json.hpp
@@ -1548,19 +1548,56 @@ class basic_json
return m_value.object->operator[](key);
}
- /// access the first element
+ /*!
+ @brief access the first element
+
+ Returns a reference to the first element in the container. For a JSON
+ container `c`, the expression `c.front()` is equivalent to `*c.begin()`.
+
+ @return In case of a compound value (array or object), a reference to the
+ first element is returned. In cast of number, string, or boolean values, a
+ reference to the value is returned.
+
+ @complexity Constant.
+
+ @note Calling `front` on an empty container is undefined.
+
+ @throw std::out_of_range when called on null value.
+
+ @liveexample{The following code shows an example for @ref front.,front}
+ */
reference front()
{
return *begin();
}
- /// access the first element
+ /*!
+ @copydoc basic_json::front()
+ */
const_reference front() const
{
return *cbegin();
}
- /// access the last element
+ /*!
+ @brief access the last element
+
+ Returns a reference to the last element in the container. For a JSON
+ container `c`, the expression `c.back()` is equivalent to `{ auto tmp =
+ c.end(); --tmp; return *tmp; }`.
+
+ @return In case of a compound value (array or object), a reference to the
+ last element is returned. In cast of number, string, or boolean values, a
+ reference to the value is returned.
+
+ @complexity Constant.
+
+ @note Calling `back` on an empty container is undefined.
+
+ @throw std::out_of_range when called on null value.
+
+ @liveexample{The following code shows an example for @ref back.,back}
+ */
reference back()
{
auto tmp = end();
@@ -1568,7 +1605,9 @@ class basic_json
return *tmp;
}
- /// access the last element
+ /*!
+ @copydoc basic_json::back()
+ */
const_reference back() const
{
auto tmp = cend();
@@ -4107,369 +4146,758 @@ class basic_json
// remember the begin of the token
m_start = m_cursor;
-
- {
- 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,
- 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,
- };
- if ((m_limit - m_cursor) < 5) yyfill(); // LCOV_EXCL_LINE;
- yych = *m_cursor;
- if (yych <= '9') {
- if (yych <= ' ') {
- if (yych <= '\n') {
- if (yych <= 0x00) goto basic_json_parser_27;
- if (yych <= 0x08) goto basic_json_parser_29;
- if (yych >= '\n') goto basic_json_parser_4;
- } else {
- if (yych == '\r') goto basic_json_parser_2;
- if (yych <= 0x1F) goto basic_json_parser_29;
+ {
+ 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,
+ 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,
+ };
+
+ if ((m_limit - m_cursor) < 5)
+ {
+ yyfill(); // LCOV_EXCL_LINE;
}
- } else {
- if (yych <= ',') {
- if (yych == '"') goto basic_json_parser_26;
- if (yych <= '+') goto basic_json_parser_29;
- goto basic_json_parser_14;
- } else {
- if (yych <= '-') goto basic_json_parser_22;
- if (yych <= '/') goto basic_json_parser_29;
- if (yych <= '0') goto basic_json_parser_23;
- goto basic_json_parser_25;
+ yych = *m_cursor;
+ if (yych <= '9')
+ {
+ if (yych <= ' ')
+ {
+ if (yych <= '\n')
+ {
+ if (yych <= 0x00)
+ {
+ goto basic_json_parser_27;
+ }
+ if (yych <= 0x08)
+ {
+ goto basic_json_parser_29;
+ }
+ if (yych >= '\n')
+ {
+ goto basic_json_parser_4;
+ }
+ }
+ else
+ {
+ if (yych == '\r')
+ {
+ goto basic_json_parser_2;
+ }
+ if (yych <= 0x1F)
+ {
+ goto basic_json_parser_29;
+ }
+ }
+ }
+ else
+ {
+ if (yych <= ',')
+ {
+ if (yych == '"')
+ {
+ goto basic_json_parser_26;
+ }
+ if (yych <= '+')
+ {
+ goto basic_json_parser_29;
+ }
+ goto basic_json_parser_14;
+ }
+ else
+ {
+ if (yych <= '-')
+ {
+ goto basic_json_parser_22;
+ }
+ if (yych <= '/')
+ {
+ goto basic_json_parser_29;
+ }
+ if (yych <= '0')
+ {
+ goto basic_json_parser_23;
+ }
+ goto basic_json_parser_25;
+ }
+ }
}
- }
- } else {
- if (yych <= 'm') {
- if (yych <= '\\') {
- if (yych <= ':') goto basic_json_parser_16;
- if (yych == '[') goto basic_json_parser_6;
- goto basic_json_parser_29;
- } else {
- if (yych <= ']') goto basic_json_parser_8;
- if (yych == 'f') goto basic_json_parser_21;
- goto basic_json_parser_29;
+ else
+ {
+ if (yych <= 'm')
+ {
+ if (yych <= '\\')
+ {
+ if (yych <= ':')
+ {
+ goto basic_json_parser_16;
+ }
+ if (yych == '[')
+ {
+ goto basic_json_parser_6;
+ }
+ goto basic_json_parser_29;
+ }
+ else
+ {
+ if (yych <= ']')
+ {
+ goto basic_json_parser_8;
+ }
+ if (yych == 'f')
+ {
+ goto basic_json_parser_21;
+ }
+ goto basic_json_parser_29;
+ }
+ }
+ else
+ {
+ if (yych <= 'z')
+ {
+ if (yych <= 'n')
+ {
+ goto basic_json_parser_18;
+ }
+ if (yych == 't')
+ {
+ goto basic_json_parser_20;
+ }
+ goto basic_json_parser_29;
+ }
+ else
+ {
+ if (yych <= '{')
+ {
+ goto basic_json_parser_10;
+ }
+ if (yych == '}')
+ {
+ goto basic_json_parser_12;
+ }
+ goto basic_json_parser_29;
+ }
+ }
}
- } else {
- if (yych <= 'z') {
- if (yych <= 'n') goto basic_json_parser_18;
- if (yych == 't') goto basic_json_parser_20;
- goto basic_json_parser_29;
- } else {
- if (yych <= '{') goto basic_json_parser_10;
- if (yych == '}') goto basic_json_parser_12;
- goto basic_json_parser_29;
- }
- }
- }
basic_json_parser_2:
- ++m_cursor;
- yych = *m_cursor;
- goto basic_json_parser_5;
+ ++m_cursor;
+ yych = *m_cursor;
+ goto basic_json_parser_5;
basic_json_parser_3:
- { return scan(); }
+ {
+ return scan();
+ }
basic_json_parser_4:
- ++m_cursor;
- if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
- yych = *m_cursor;
+ ++m_cursor;
+ if (m_limit <= m_cursor)
+ {
+ yyfill(); // LCOV_EXCL_LINE;
+ }
+ yych = *m_cursor;
basic_json_parser_5:
- if (yybm[0+yych] & 32) {
- goto basic_json_parser_4;
- }
- goto basic_json_parser_3;
+ if (yybm[0 + yych] & 32)
+ {
+ goto basic_json_parser_4;
+ }
+ goto basic_json_parser_3;
basic_json_parser_6:
- ++m_cursor;
- { return token_type::begin_array; }
+ ++m_cursor;
+ {
+ return token_type::begin_array;
+ }
basic_json_parser_8:
- ++m_cursor;
- { return token_type::end_array; }
+ ++m_cursor;
+ {
+ return token_type::end_array;
+ }
basic_json_parser_10:
- ++m_cursor;
- { return token_type::begin_object; }
+ ++m_cursor;
+ {
+ return token_type::begin_object;
+ }
basic_json_parser_12:
- ++m_cursor;
- { return token_type::end_object; }
+ ++m_cursor;
+ {
+ return token_type::end_object;
+ }
basic_json_parser_14:
- ++m_cursor;
- { return token_type::value_separator; }
+ ++m_cursor;
+ {
+ return token_type::value_separator;
+ }
basic_json_parser_16:
- ++m_cursor;
- { return token_type::name_separator; }
+ ++m_cursor;
+ {
+ return token_type::name_separator;
+ }
basic_json_parser_18:
- yyaccept = 0;
- yych = *(m_marker = ++m_cursor);
- if (yych == 'u') goto basic_json_parser_59;
+ yyaccept = 0;
+ yych = *(m_marker = ++m_cursor);
+ if (yych == 'u')
+ {
+ goto basic_json_parser_59;
+ }
basic_json_parser_19:
- { return token_type::parse_error; }
+ {
+ return token_type::parse_error;
+ }
basic_json_parser_20:
- yyaccept = 0;
- yych = *(m_marker = ++m_cursor);
- if (yych == 'r') goto basic_json_parser_55;
- goto basic_json_parser_19;
+ yyaccept = 0;
+ yych = *(m_marker = ++m_cursor);
+ if (yych == 'r')
+ {
+ goto basic_json_parser_55;
+ }
+ goto basic_json_parser_19;
basic_json_parser_21:
- yyaccept = 0;
- yych = *(m_marker = ++m_cursor);
- if (yych == 'a') goto basic_json_parser_50;
- goto basic_json_parser_19;
+ yyaccept = 0;
+ yych = *(m_marker = ++m_cursor);
+ if (yych == 'a')
+ {
+ goto basic_json_parser_50;
+ }
+ goto basic_json_parser_19;
basic_json_parser_22:
- yych = *++m_cursor;
- if (yych <= '/') goto basic_json_parser_19;
- if (yych <= '0') goto basic_json_parser_49;
- if (yych <= '9') goto basic_json_parser_40;
- goto basic_json_parser_19;
+ yych = *++m_cursor;
+ if (yych <= '/')
+ {
+ goto basic_json_parser_19;
+ }
+ if (yych <= '0')
+ {
+ goto basic_json_parser_49;
+ }
+ if (yych <= '9')
+ {
+ goto basic_json_parser_40;
+ }
+ goto basic_json_parser_19;
basic_json_parser_23:
- yyaccept = 1;
- yych = *(m_marker = ++m_cursor);
- if (yych <= 'D') {
- if (yych == '.') goto basic_json_parser_42;
- } else {
- if (yych <= 'E') goto basic_json_parser_43;
- if (yych == 'e') goto basic_json_parser_43;
- }
+ yyaccept = 1;
+ yych = *(m_marker = ++m_cursor);
+ if (yych <= 'D')
+ {
+ if (yych == '.')
+ {
+ goto basic_json_parser_42;
+ }
+ }
+ else
+ {
+ if (yych <= 'E')
+ {
+ goto basic_json_parser_43;
+ }
+ if (yych == 'e')
+ {
+ goto basic_json_parser_43;
+ }
+ }
basic_json_parser_24:
- { return token_type::value_number; }
+ {
+ return token_type::value_number;
+ }
basic_json_parser_25:
- yyaccept = 1;
- yych = *(m_marker = ++m_cursor);
- goto basic_json_parser_41;
+ yyaccept = 1;
+ yych = *(m_marker = ++m_cursor);
+ goto basic_json_parser_41;
basic_json_parser_26:
- yyaccept = 0;
- yych = *(m_marker = ++m_cursor);
- if (yych <= 0x0F) goto basic_json_parser_19;
- goto basic_json_parser_31;
+ yyaccept = 0;
+ yych = *(m_marker = ++m_cursor);
+ if (yych <= 0x0F)
+ {
+ goto basic_json_parser_19;
+ }
+ goto basic_json_parser_31;
basic_json_parser_27:
- ++m_cursor;
- { return token_type::end_of_input; }
+ ++m_cursor;
+ {
+ return token_type::end_of_input;
+ }
basic_json_parser_29:
- yych = *++m_cursor;
- goto basic_json_parser_19;
+ yych = *++m_cursor;
+ goto basic_json_parser_19;
basic_json_parser_30:
- ++m_cursor;
- if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
- yych = *m_cursor;
+ ++m_cursor;
+ if (m_limit <= m_cursor)
+ {
+ yyfill(); // LCOV_EXCL_LINE;
+ }
+ yych = *m_cursor;
basic_json_parser_31:
- if (yybm[0+yych] & 64) {
- goto basic_json_parser_30;
- }
- if (yych <= 0x0F) goto basic_json_parser_32;
- if (yych <= '"') goto basic_json_parser_34;
- goto basic_json_parser_33;
-basic_json_parser_32:
- m_cursor = m_marker;
- if (yyaccept == 0) {
- goto basic_json_parser_19;
- } else {
- goto basic_json_parser_24;
- }
-basic_json_parser_33:
- ++m_cursor;
- if (m_limit <= m_cursor) yyfill(); // 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 (yybm[0 + yych] & 64)
+ {
goto basic_json_parser_30;
- } else {
- if (yych == 'b') goto basic_json_parser_30;
+ }
+ if (yych <= 0x0F)
+ {
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;
- 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_36;
- goto basic_json_parser_32;
+ if (yych <= '"')
+ {
+ goto basic_json_parser_34;
+ }
+ goto basic_json_parser_33;
+basic_json_parser_32:
+ m_cursor = m_marker;
+ if (yyaccept == 0)
+ {
+ goto basic_json_parser_19;
+ }
+ else
+ {
+ goto basic_json_parser_24;
+ }
+basic_json_parser_33:
+ ++m_cursor;
+ if (m_limit <= m_cursor)
+ {
+ yyfill(); // 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;
+ }
+ 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;
+ }
+ 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_36;
+ }
+ goto basic_json_parser_32;
+ }
+ }
}
- }
- }
basic_json_parser_34:
- ++m_cursor;
- { return token_type::value_string; }
+ ++m_cursor;
+ {
+ return token_type::value_string;
+ }
basic_json_parser_36:
- ++m_cursor;
- if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
- yych = *m_cursor;
- if (yych <= '@') {
- if (yych <= '/') goto basic_json_parser_32;
- if (yych >= ':') goto basic_json_parser_32;
- } else {
- if (yych <= 'F') goto basic_json_parser_37;
- if (yych <= '`') goto basic_json_parser_32;
- if (yych >= 'g') goto basic_json_parser_32;
- }
+ ++m_cursor;
+ if (m_limit <= m_cursor)
+ {
+ yyfill(); // LCOV_EXCL_LINE;
+ }
+ yych = *m_cursor;
+ if (yych <= '@')
+ {
+ if (yych <= '/')
+ {
+ goto basic_json_parser_32;
+ }
+ if (yych >= ':')
+ {
+ goto basic_json_parser_32;
+ }
+ }
+ else
+ {
+ if (yych <= 'F')
+ {
+ goto basic_json_parser_37;
+ }
+ if (yych <= '`')
+ {
+ goto basic_json_parser_32;
+ }
+ if (yych >= 'g')
+ {
+ goto basic_json_parser_32;
+ }
+ }
basic_json_parser_37:
- ++m_cursor;
- if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
- yych = *m_cursor;
- if (yych <= '@') {
- if (yych <= '/') goto basic_json_parser_32;
- if (yych >= ':') goto basic_json_parser_32;
- } else {
- if (yych <= 'F') goto basic_json_parser_38;
- if (yych <= '`') goto basic_json_parser_32;
- if (yych >= 'g') goto basic_json_parser_32;
- }
+ ++m_cursor;
+ if (m_limit <= m_cursor)
+ {
+ yyfill(); // LCOV_EXCL_LINE;
+ }
+ yych = *m_cursor;
+ if (yych <= '@')
+ {
+ if (yych <= '/')
+ {
+ goto basic_json_parser_32;
+ }
+ if (yych >= ':')
+ {
+ goto basic_json_parser_32;
+ }
+ }
+ else
+ {
+ if (yych <= 'F')
+ {
+ goto basic_json_parser_38;
+ }
+ if (yych <= '`')
+ {
+ goto basic_json_parser_32;
+ }
+ if (yych >= 'g')
+ {
+ goto basic_json_parser_32;
+ }
+ }
basic_json_parser_38:
- ++m_cursor;
- if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
- yych = *m_cursor;
- if (yych <= '@') {
- if (yych <= '/') goto basic_json_parser_32;
- if (yych >= ':') goto basic_json_parser_32;
- } else {
- if (yych <= 'F') goto basic_json_parser_39;
- if (yych <= '`') goto basic_json_parser_32;
- if (yych >= 'g') goto basic_json_parser_32;
- }
+ ++m_cursor;
+ if (m_limit <= m_cursor)
+ {
+ yyfill(); // LCOV_EXCL_LINE;
+ }
+ yych = *m_cursor;
+ if (yych <= '@')
+ {
+ if (yych <= '/')
+ {
+ goto basic_json_parser_32;
+ }
+ if (yych >= ':')
+ {
+ goto basic_json_parser_32;
+ }
+ }
+ else
+ {
+ if (yych <= 'F')
+ {
+ goto basic_json_parser_39;
+ }
+ if (yych <= '`')
+ {
+ goto basic_json_parser_32;
+ }
+ if (yych >= 'g')
+ {
+ goto basic_json_parser_32;
+ }
+ }
basic_json_parser_39:
- ++m_cursor;
- if (m_limit <= m_cursor) yyfill(); // 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;
- }
+ ++m_cursor;
+ if (m_limit <= m_cursor)
+ {
+ yyfill(); // 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;
+ }
basic_json_parser_40:
- yyaccept = 1;
- m_marker = ++m_cursor;
- if ((m_limit - m_cursor) < 3) yyfill(); // LCOV_EXCL_LINE;
- yych = *m_cursor;
+ yyaccept = 1;
+ m_marker = ++m_cursor;
+ if ((m_limit - m_cursor) < 3)
+ {
+ yyfill(); // LCOV_EXCL_LINE;
+ }
+ yych = *m_cursor;
basic_json_parser_41:
- if (yybm[0+yych] & 128) {
- goto basic_json_parser_40;
- }
- if (yych <= 'D') {
- if (yych != '.') goto basic_json_parser_24;
- } else {
- if (yych <= 'E') goto basic_json_parser_43;
- if (yych == 'e') goto basic_json_parser_43;
- goto basic_json_parser_24;
- }
+ if (yybm[0 + yych] & 128)
+ {
+ goto basic_json_parser_40;
+ }
+ if (yych <= 'D')
+ {
+ if (yych != '.')
+ {
+ goto basic_json_parser_24;
+ }
+ }
+ else
+ {
+ if (yych <= 'E')
+ {
+ goto basic_json_parser_43;
+ }
+ if (yych == 'e')
+ {
+ goto basic_json_parser_43;
+ }
+ goto basic_json_parser_24;
+ }
basic_json_parser_42:
- yych = *++m_cursor;
- if (yych <= '/') goto basic_json_parser_32;
- if (yych <= '9') goto basic_json_parser_47;
- goto basic_json_parser_32;
+ yych = *++m_cursor;
+ if (yych <= '/')
+ {
+ goto basic_json_parser_32;
+ }
+ if (yych <= '9')
+ {
+ goto basic_json_parser_47;
+ }
+ goto basic_json_parser_32;
basic_json_parser_43:
- yych = *++m_cursor;
- if (yych <= ',') {
- if (yych != '+') goto basic_json_parser_32;
- } else {
- if (yych <= '-') goto basic_json_parser_44;
- if (yych <= '/') goto basic_json_parser_32;
- if (yych <= '9') goto basic_json_parser_45;
- goto basic_json_parser_32;
- }
+ yych = *++m_cursor;
+ if (yych <= ',')
+ {
+ if (yych != '+')
+ {
+ goto basic_json_parser_32;
+ }
+ }
+ else
+ {
+ if (yych <= '-')
+ {
+ goto basic_json_parser_44;
+ }
+ if (yych <= '/')
+ {
+ goto basic_json_parser_32;
+ }
+ if (yych <= '9')
+ {
+ goto basic_json_parser_45;
+ }
+ goto basic_json_parser_32;
+ }
basic_json_parser_44:
- yych = *++m_cursor;
- if (yych <= '/') goto basic_json_parser_32;
- if (yych >= ':') goto basic_json_parser_32;
+ yych = *++m_cursor;
+ if (yych <= '/')
+ {
+ goto basic_json_parser_32;
+ }
+ if (yych >= ':')
+ {
+ goto basic_json_parser_32;
+ }
basic_json_parser_45:
- ++m_cursor;
- if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
- yych = *m_cursor;
- if (yych <= '/') goto basic_json_parser_24;
- if (yych <= '9') goto basic_json_parser_45;
- goto basic_json_parser_24;
+ ++m_cursor;
+ if (m_limit <= m_cursor)
+ {
+ yyfill(); // LCOV_EXCL_LINE;
+ }
+ yych = *m_cursor;
+ if (yych <= '/')
+ {
+ goto basic_json_parser_24;
+ }
+ if (yych <= '9')
+ {
+ goto basic_json_parser_45;
+ }
+ goto basic_json_parser_24;
basic_json_parser_47:
- yyaccept = 1;
- m_marker = ++m_cursor;
- if ((m_limit - m_cursor) < 3) yyfill(); // LCOV_EXCL_LINE;
- yych = *m_cursor;
- if (yych <= 'D') {
- if (yych <= '/') goto basic_json_parser_24;
- if (yych <= '9') goto basic_json_parser_47;
- goto basic_json_parser_24;
- } else {
- if (yych <= 'E') goto basic_json_parser_43;
- if (yych == 'e') goto basic_json_parser_43;
- goto basic_json_parser_24;
- }
+ yyaccept = 1;
+ m_marker = ++m_cursor;
+ if ((m_limit - m_cursor) < 3)
+ {
+ yyfill(); // LCOV_EXCL_LINE;
+ }
+ yych = *m_cursor;
+ if (yych <= 'D')
+ {
+ if (yych <= '/')
+ {
+ goto basic_json_parser_24;
+ }
+ if (yych <= '9')
+ {
+ goto basic_json_parser_47;
+ }
+ goto basic_json_parser_24;
+ }
+ else
+ {
+ if (yych <= 'E')
+ {
+ goto basic_json_parser_43;
+ }
+ if (yych == 'e')
+ {
+ goto basic_json_parser_43;
+ }
+ goto basic_json_parser_24;
+ }
basic_json_parser_49:
- yyaccept = 1;
- yych = *(m_marker = ++m_cursor);
- if (yych <= 'D') {
- if (yych == '.') goto basic_json_parser_42;
- goto basic_json_parser_24;
- } else {
- if (yych <= 'E') goto basic_json_parser_43;
- if (yych == 'e') goto basic_json_parser_43;
- goto basic_json_parser_24;
- }
+ yyaccept = 1;
+ yych = *(m_marker = ++m_cursor);
+ if (yych <= 'D')
+ {
+ if (yych == '.')
+ {
+ goto basic_json_parser_42;
+ }
+ goto basic_json_parser_24;
+ }
+ else
+ {
+ if (yych <= 'E')
+ {
+ goto basic_json_parser_43;
+ }
+ if (yych == 'e')
+ {
+ goto basic_json_parser_43;
+ }
+ goto basic_json_parser_24;
+ }
basic_json_parser_50:
- yych = *++m_cursor;
- if (yych != 'l') goto basic_json_parser_32;
- yych = *++m_cursor;
- if (yych != 's') goto basic_json_parser_32;
- yych = *++m_cursor;
- if (yych != 'e') goto basic_json_parser_32;
- ++m_cursor;
- { return token_type::literal_false; }
+ yych = *++m_cursor;
+ if (yych != 'l')
+ {
+ goto basic_json_parser_32;
+ }
+ yych = *++m_cursor;
+ if (yych != 's')
+ {
+ goto basic_json_parser_32;
+ }
+ yych = *++m_cursor;
+ if (yych != 'e')
+ {
+ goto basic_json_parser_32;
+ }
+ ++m_cursor;
+ {
+ return token_type::literal_false;
+ }
basic_json_parser_55:
- yych = *++m_cursor;
- if (yych != 'u') goto basic_json_parser_32;
- yych = *++m_cursor;
- if (yych != 'e') goto basic_json_parser_32;
- ++m_cursor;
- { return token_type::literal_true; }
+ yych = *++m_cursor;
+ if (yych != 'u')
+ {
+ goto basic_json_parser_32;
+ }
+ yych = *++m_cursor;
+ if (yych != 'e')
+ {
+ goto basic_json_parser_32;
+ }
+ ++m_cursor;
+ {
+ return token_type::literal_true;
+ }
basic_json_parser_59:
- yych = *++m_cursor;
- if (yych != 'l') goto basic_json_parser_32;
- yych = *++m_cursor;
- if (yych != 'l') goto basic_json_parser_32;
- ++m_cursor;
- { return token_type::literal_null; }
- }
+ yych = *++m_cursor;
+ if (yych != 'l')
+ {
+ goto basic_json_parser_32;
+ }
+ yych = *++m_cursor;
+ if (yych != 'l')
+ {
+ goto basic_json_parser_32;
+ }
+ ++m_cursor;
+ {
+ return token_type::literal_null;
+ }
+ }
}
diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c
index b1de4494..fafef9b2 100644
--- a/src/json.hpp.re2c
+++ b/src/json.hpp.re2c
@@ -1548,19 +1548,56 @@ class basic_json
return m_value.object->operator[](key);
}
- /// access the first element
+ /*!
+ @brief access the first element
+
+ Returns a reference to the first element in the container. For a JSON
+ container `c`, the expression `c.front()` is equivalent to `*c.begin()`.
+
+ @return In case of a compound value (array or object), a reference to the
+ first element is returned. In cast of number, string, or boolean values, a
+ reference to the value is returned.
+
+ @complexity Constant.
+
+ @note Calling `front` on an empty container is undefined.
+
+ @throw std::out_of_range when called on null value.
+
+ @liveexample{The following code shows an example for @ref front.,front}
+ */
reference front()
{
return *begin();
}
- /// access the first element
+ /*!
+ @copydoc basic_json::front()
+ */
const_reference front() const
{
return *cbegin();
}
- /// access the last element
+ /*!
+ @brief access the last element
+
+ Returns a reference to the last element in the container. For a JSON
+ container `c`, the expression `c.back()` is equivalent to `{ auto tmp =
+ c.end(); --tmp; return *tmp; }`.
+
+ @return In case of a compound value (array or object), a reference to the
+ last element is returned. In cast of number, string, or boolean values, a
+ reference to the value is returned.
+
+ @complexity Constant.
+
+ @note Calling `back` on an empty container is undefined.
+
+ @throw std::out_of_range when called on null value.
+
+ @liveexample{The following code shows an example for @ref back.,back}
+ */
reference back()
{
auto tmp = end();
@@ -1568,7 +1605,9 @@ class basic_json
return *tmp;
}
- /// access the last element
+ /*!
+ @copydoc basic_json::back()
+ */
const_reference back() const
{
auto tmp = cend();