cleanup
This commit is contained in:
parent
94c16b2c31
commit
59c8343851
3 changed files with 55 additions and 52 deletions
48
src/json.hpp
48
src/json.hpp
|
@ -7836,7 +7836,7 @@ class basic_json
|
|||
};
|
||||
if ((m_limit - m_cursor) < 5)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(5); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yybm[0 + yych] & 32)
|
||||
|
@ -7966,7 +7966,7 @@ basic_json_parser_6:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yybm[0 + yych] & 32)
|
||||
|
@ -8048,7 +8048,7 @@ basic_json_parser_15:
|
|||
m_marker = ++m_cursor;
|
||||
if ((m_limit - m_cursor) < 3)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(3); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yybm[0 + yych] & 64)
|
||||
|
@ -8133,7 +8133,7 @@ basic_json_parser_30:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
basic_json_parser_31:
|
||||
|
@ -8214,7 +8214,7 @@ basic_json_parser_35:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= 'e')
|
||||
|
@ -8293,7 +8293,7 @@ basic_json_parser_36:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= 0x7F)
|
||||
|
@ -8309,7 +8309,7 @@ basic_json_parser_37:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= 0x9F)
|
||||
|
@ -8325,7 +8325,7 @@ basic_json_parser_38:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= 0x7F)
|
||||
|
@ -8341,7 +8341,7 @@ basic_json_parser_39:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= 0x7F)
|
||||
|
@ -8357,7 +8357,7 @@ basic_json_parser_40:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= 0x8F)
|
||||
|
@ -8373,7 +8373,7 @@ basic_json_parser_41:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= 0x7F)
|
||||
|
@ -8389,7 +8389,7 @@ basic_json_parser_42:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= 0x7F)
|
||||
|
@ -8463,7 +8463,7 @@ basic_json_parser_48:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= '@')
|
||||
|
@ -8499,7 +8499,7 @@ basic_json_parser_49:
|
|||
m_marker = ++m_cursor;
|
||||
if ((m_limit - m_cursor) < 3)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(3); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= 'D')
|
||||
|
@ -8540,7 +8540,7 @@ basic_json_parser_52:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= '/')
|
||||
|
@ -8577,7 +8577,7 @@ basic_json_parser_57:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= '@')
|
||||
|
@ -8631,7 +8631,7 @@ basic_json_parser_63:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= '@')
|
||||
|
@ -8672,7 +8672,7 @@ basic_json_parser_66:
|
|||
++m_cursor;
|
||||
if (m_limit <= m_cursor)
|
||||
{
|
||||
fill_line_buffer(); // LCOV_EXCL_LINE;
|
||||
fill_line_buffer(1); // LCOV_EXCL_LINE
|
||||
}
|
||||
yych = *m_cursor;
|
||||
if (yych <= '@')
|
||||
|
@ -8738,7 +8738,7 @@ basic_json_parser_66:
|
|||
m_start
|
||||
m_content
|
||||
*/
|
||||
void fill_line_buffer()
|
||||
void fill_line_buffer(size_t n = 0)
|
||||
{
|
||||
// number of processed characters (p)
|
||||
const auto offset_start = m_start - m_content;
|
||||
|
@ -8761,10 +8761,10 @@ basic_json_parser_66:
|
|||
}
|
||||
}
|
||||
|
||||
// append 5 characters (size of longest keyword "false") to
|
||||
// make sure that there is sufficient space between m_cursor
|
||||
// and m_limit
|
||||
m_line_buffer.append(5, '\0');
|
||||
// append n characters to make sure that there is sufficient
|
||||
// space between m_cursor and m_limit
|
||||
m_line_buffer.append(1, '\x00');
|
||||
m_line_buffer.append(n - 1, '\x01');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8772,7 +8772,7 @@ basic_json_parser_66:
|
|||
m_line_buffer.erase(0, static_cast<size_t>(offset_start));
|
||||
// read next line from input stream
|
||||
std::string line;
|
||||
std::getline(*m_stream, line);
|
||||
std::getline(*m_stream, line, '\n');
|
||||
// add line with newline symbol to the line buffer
|
||||
m_line_buffer += line + "\n";
|
||||
}
|
||||
|
|
|
@ -7796,15 +7796,15 @@ class basic_json
|
|||
assert(m_start != nullptr);
|
||||
|
||||
/*!re2c
|
||||
re2c:define:YYCTYPE = lexer_char_t;
|
||||
re2c:define:YYCURSOR = m_cursor;
|
||||
re2c:define:YYLIMIT = m_limit;
|
||||
re2c:define:YYMARKER = m_marker;
|
||||
re2c:define:YYFILL = "fill_line_buffer(); // LCOV_EXCL_LINE";
|
||||
re2c:yyfill:parameter = 0;
|
||||
re2c:indent:string = " ";
|
||||
re2c:indent:top = 1;
|
||||
re2c:labelprefix = "basic_json_parser_";
|
||||
re2c:define:YYCTYPE = lexer_char_t;
|
||||
re2c:define:YYCURSOR = m_cursor;
|
||||
re2c:define:YYLIMIT = m_limit;
|
||||
re2c:define:YYMARKER = m_marker;
|
||||
re2c:define:YYFILL = "fill_line_buffer(@@); // LCOV_EXCL_LINE";
|
||||
re2c:define:YYFILL:naked = 1;
|
||||
re2c:indent:string = " ";
|
||||
re2c:indent:top = 1;
|
||||
re2c:labelprefix = "basic_json_parser_";
|
||||
|
||||
// ignore whitespace
|
||||
ws = [ \t\n\r]+;
|
||||
|
@ -7849,7 +7849,7 @@ class basic_json
|
|||
string { last_token_type = token_type::value_string; break; }
|
||||
|
||||
// end of file
|
||||
"\000" { last_token_type = token_type::end_of_input; break; }
|
||||
"\x00" { last_token_type = token_type::end_of_input; break; }
|
||||
|
||||
// anything else is an error
|
||||
* { last_token_type = token_type::parse_error; break; }
|
||||
|
@ -7887,7 +7887,7 @@ class basic_json
|
|||
m_start
|
||||
m_content
|
||||
*/
|
||||
void fill_line_buffer()
|
||||
void fill_line_buffer(size_t n = 0)
|
||||
{
|
||||
// number of processed characters (p)
|
||||
const auto offset_start = m_start - m_content;
|
||||
|
@ -7910,10 +7910,10 @@ class basic_json
|
|||
}
|
||||
}
|
||||
|
||||
// append 5 characters (size of longest keyword "false") to
|
||||
// make sure that there is sufficient space between m_cursor
|
||||
// and m_limit
|
||||
m_line_buffer.append(5, '\0');
|
||||
// append n characters to make sure that there is sufficient
|
||||
// space between m_cursor and m_limit
|
||||
m_line_buffer.append(1, '\x00');
|
||||
m_line_buffer.append(n - 1, '\x01');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -7921,7 +7921,7 @@ class basic_json
|
|||
m_line_buffer.erase(0, static_cast<size_t>(offset_start));
|
||||
// read next line from input stream
|
||||
std::string line;
|
||||
std::getline(*m_stream, line);
|
||||
std::getline(*m_stream, line, '\n');
|
||||
// add line with newline symbol to the line buffer
|
||||
m_line_buffer += line + "\n";
|
||||
}
|
||||
|
|
|
@ -87,10 +87,11 @@ TEST_CASE("deserialization")
|
|||
{
|
||||
SECTION("stream")
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "[\"foo\",1,2,3,false,{\"one\":1}";
|
||||
CHECK_THROWS_AS(json::parse(ss), std::invalid_argument);
|
||||
CHECK_THROWS_WITH(json::parse(ss), "parse error - unexpected end of input");
|
||||
std::stringstream ss1, ss2;
|
||||
ss1 << "[\"foo\",1,2,3,false,{\"one\":1}";
|
||||
ss2 << "[\"foo\",1,2,3,false,{\"one\":1}";
|
||||
CHECK_THROWS_AS(json::parse(ss1), std::invalid_argument);
|
||||
CHECK_THROWS_WITH(json::parse(ss2), "parse error - unexpected end of input; expected ']'");
|
||||
}
|
||||
|
||||
SECTION("string")
|
||||
|
@ -102,20 +103,22 @@ TEST_CASE("deserialization")
|
|||
|
||||
SECTION("operator<<")
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "[\"foo\",1,2,3,false,{\"one\":1}";
|
||||
std::stringstream ss1, ss2;
|
||||
ss1 << "[\"foo\",1,2,3,false,{\"one\":1}";
|
||||
ss2 << "[\"foo\",1,2,3,false,{\"one\":1}";
|
||||
json j;
|
||||
CHECK_THROWS_AS(j << ss, std::invalid_argument);
|
||||
CHECK_THROWS_WITH(j << ss, "parse error - unexpected end of input");
|
||||
CHECK_THROWS_AS(j << ss1, std::invalid_argument);
|
||||
CHECK_THROWS_WITH(j << ss2, "parse error - unexpected end of input; expected ']'");
|
||||
}
|
||||
|
||||
SECTION("operator>>")
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "[\"foo\",1,2,3,false,{\"one\":1}";
|
||||
std::stringstream ss1, ss2;
|
||||
ss1 << "[\"foo\",1,2,3,false,{\"one\":1}";
|
||||
ss2 << "[\"foo\",1,2,3,false,{\"one\":1}";
|
||||
json j;
|
||||
CHECK_THROWS_AS(ss >> j, std::invalid_argument);
|
||||
CHECK_THROWS_WITH(ss >> j, "parse error - unexpected end of input");
|
||||
CHECK_THROWS_AS(ss1 >> j, std::invalid_argument);
|
||||
CHECK_THROWS_WITH(ss2 >> j, "parse error - unexpected end of input; expected ']'");
|
||||
}
|
||||
|
||||
SECTION("user-defined string literal")
|
||||
|
|
Loading…
Reference in a new issue