Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
9bbb1330
Unverified
Commit
9bbb1330
authored
Jul 24, 2018
by
Théo DELRIEU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove no_limit constant and default values
parent
442886d0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
36 deletions
+30
-36
include/nlohmann/detail/input/json_sax.hpp
include/nlohmann/detail/input/json_sax.hpp
+12
-15
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+12
-15
test/src/unit-class_parser.cpp
test/src/unit-class_parser.cpp
+4
-4
test/src/unit-ubjson.cpp
test/src/unit-ubjson.cpp
+2
-2
No files found.
include/nlohmann/detail/input/json_sax.hpp
View file @
9bbb1330
...
...
@@ -25,9 +25,6 @@ struct json_sax
/// type for strings
using
string_t
=
typename
BasicJsonType
::
string_t
;
/// constant to indicate that no size limit is given for array or object
static
constexpr
auto
no_limit
=
std
::
size_t
(
-
1
);
/*!
@brief a null value was read
@return whether parsing should proceed
...
...
@@ -72,11 +69,11 @@ struct json_sax
/*!
@brief the beginning of an object was read
@param[in] elements number of object elements or
no_limit
if unknown
@param[in] elements number of object elements or
-1
if unknown
@return whether parsing should proceed
@note binary formats may report the number of elements
*/
virtual
bool
start_object
(
std
::
size_t
elements
=
no_limit
)
=
0
;
virtual
bool
start_object
(
std
::
size_t
elements
)
=
0
;
/*!
@brief an object key was read
...
...
@@ -93,11 +90,11 @@ struct json_sax
/*!
@brief the beginning of an array was read
@param[in] elements number of array elements or
no_limit
if unknown
@param[in] elements number of array elements or
-1
if unknown
@return whether parsing should proceed
@note binary formats may report the number of elements
*/
virtual
bool
start_array
(
std
::
size_t
elements
=
no_limit
)
=
0
;
virtual
bool
start_array
(
std
::
size_t
elements
)
=
0
;
/*!
@brief the end of an array was read
...
...
@@ -189,11 +186,11 @@ class json_sax_dom_parser
return
true
;
}
bool
start_object
(
std
::
size_t
len
=
-
1
)
bool
start_object
(
std
::
size_t
len
)
{
ref_stack
.
push_back
(
handle_value
(
BasicJsonType
::
value_t
::
object
));
if
(
JSON_UNLIKELY
(
len
!=
json_sax
<
BasicJsonType
>::
no_limit
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive object size: "
+
std
::
to_string
(
len
)));
...
...
@@ -215,11 +212,11 @@ class json_sax_dom_parser
return
true
;
}
bool
start_array
(
std
::
size_t
len
=
-
1
)
bool
start_array
(
std
::
size_t
len
)
{
ref_stack
.
push_back
(
handle_value
(
BasicJsonType
::
value_t
::
array
));
if
(
JSON_UNLIKELY
(
len
!=
json_sax
<
BasicJsonType
>::
no_limit
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive array size: "
+
std
::
to_string
(
len
)));
...
...
@@ -364,7 +361,7 @@ class json_sax_dom_callback_parser
return
true
;
}
bool
start_object
(
std
::
size_t
len
=
-
1
)
bool
start_object
(
std
::
size_t
len
)
{
// check callback for object start
const
bool
keep
=
callback
(
static_cast
<
int
>
(
ref_stack
.
size
()),
parse_event_t
::
object_start
,
discarded
);
...
...
@@ -376,7 +373,7 @@ class json_sax_dom_callback_parser
// check object limit
if
(
ref_stack
.
back
())
{
if
(
JSON_UNLIKELY
(
len
!=
json_sax
<
BasicJsonType
>::
no_limit
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive object size: "
+
std
::
to_string
(
len
)));
...
...
@@ -438,7 +435,7 @@ class json_sax_dom_callback_parser
return
true
;
}
bool
start_array
(
std
::
size_t
len
=
-
1
)
bool
start_array
(
std
::
size_t
len
)
{
const
bool
keep
=
callback
(
static_cast
<
int
>
(
ref_stack
.
size
()),
parse_event_t
::
array_start
,
discarded
);
keep_stack
.
push_back
(
keep
);
...
...
@@ -449,7 +446,7 @@ class json_sax_dom_callback_parser
// check array limit
if
(
ref_stack
.
back
())
{
if
(
JSON_UNLIKELY
(
len
!=
json_sax
<
BasicJsonType
>::
no_limit
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive array size: "
+
std
::
to_string
(
len
)));
...
...
single_include/nlohmann/json.hpp
View file @
9bbb1330
...
...
@@ -3589,9 +3589,6 @@ struct json_sax
/// type for strings
using
string_t
=
typename
BasicJsonType
::
string_t
;
/// constant to indicate that no size limit is given for array or object
static
constexpr
auto
no_limit
=
std
::
size_t
(
-
1
);
/*!
@brief a null value was read
@return whether parsing should proceed
...
...
@@ -3636,11 +3633,11 @@ struct json_sax
/*!
@brief the beginning of an object was read
@param[in] elements number of object elements or
no_limit
if unknown
@param[in] elements number of object elements or
-1
if unknown
@return whether parsing should proceed
@note binary formats may report the number of elements
*/
virtual
bool
start_object
(
std
::
size_t
elements
=
no_limit
)
=
0
;
virtual
bool
start_object
(
std
::
size_t
elements
)
=
0
;
/*!
@brief an object key was read
...
...
@@ -3657,11 +3654,11 @@ struct json_sax
/*!
@brief the beginning of an array was read
@param[in] elements number of array elements or
no_limit
if unknown
@param[in] elements number of array elements or
-1
if unknown
@return whether parsing should proceed
@note binary formats may report the number of elements
*/
virtual
bool
start_array
(
std
::
size_t
elements
=
no_limit
)
=
0
;
virtual
bool
start_array
(
std
::
size_t
elements
)
=
0
;
/*!
@brief the end of an array was read
...
...
@@ -3753,11 +3750,11 @@ class json_sax_dom_parser
return
true
;
}
bool
start_object
(
std
::
size_t
len
=
-
1
)
bool
start_object
(
std
::
size_t
len
)
{
ref_stack
.
push_back
(
handle_value
(
BasicJsonType
::
value_t
::
object
));
if
(
JSON_UNLIKELY
(
len
!=
json_sax
<
BasicJsonType
>::
no_limit
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive object size: "
+
std
::
to_string
(
len
)));
...
...
@@ -3779,11 +3776,11 @@ class json_sax_dom_parser
return
true
;
}
bool
start_array
(
std
::
size_t
len
=
-
1
)
bool
start_array
(
std
::
size_t
len
)
{
ref_stack
.
push_back
(
handle_value
(
BasicJsonType
::
value_t
::
array
));
if
(
JSON_UNLIKELY
(
len
!=
json_sax
<
BasicJsonType
>::
no_limit
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive array size: "
+
std
::
to_string
(
len
)));
...
...
@@ -3928,7 +3925,7 @@ class json_sax_dom_callback_parser
return
true
;
}
bool
start_object
(
std
::
size_t
len
=
-
1
)
bool
start_object
(
std
::
size_t
len
)
{
// check callback for object start
const
bool
keep
=
callback
(
static_cast
<
int
>
(
ref_stack
.
size
()),
parse_event_t
::
object_start
,
discarded
);
...
...
@@ -3940,7 +3937,7 @@ class json_sax_dom_callback_parser
// check object limit
if
(
ref_stack
.
back
())
{
if
(
JSON_UNLIKELY
(
len
!=
json_sax
<
BasicJsonType
>::
no_limit
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive object size: "
+
std
::
to_string
(
len
)));
...
...
@@ -4002,7 +3999,7 @@ class json_sax_dom_callback_parser
return
true
;
}
bool
start_array
(
std
::
size_t
len
=
-
1
)
bool
start_array
(
std
::
size_t
len
)
{
const
bool
keep
=
callback
(
static_cast
<
int
>
(
ref_stack
.
size
()),
parse_event_t
::
array_start
,
discarded
);
keep_stack
.
push_back
(
keep
);
...
...
@@ -4013,7 +4010,7 @@ class json_sax_dom_callback_parser
// check array limit
if
(
ref_stack
.
back
())
{
if
(
JSON_UNLIKELY
(
len
!=
json_sax
<
BasicJsonType
>::
no_limit
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive array size: "
+
std
::
to_string
(
len
)));
...
...
test/src/unit-class_parser.cpp
View file @
9bbb1330
...
...
@@ -74,7 +74,7 @@ class SaxEventLogger
return
true
;
}
bool
start_object
(
std
::
size_t
elements
=
-
1
)
bool
start_object
(
std
::
size_t
elements
)
{
if
(
elements
==
std
::
size_t
(
-
1
))
{
...
...
@@ -99,7 +99,7 @@ class SaxEventLogger
return
true
;
}
bool
start_array
(
std
::
size_t
elements
=
-
1
)
bool
start_array
(
std
::
size_t
elements
)
{
if
(
elements
==
std
::
size_t
(
-
1
))
{
...
...
@@ -165,7 +165,7 @@ class SaxCountdown
return
events_left
--
>
0
;
}
bool
start_object
(
std
::
size_t
=
-
1
)
bool
start_object
(
std
::
size_t
)
{
return
events_left
--
>
0
;
}
...
...
@@ -180,7 +180,7 @@ class SaxCountdown
return
events_left
--
>
0
;
}
bool
start_array
(
std
::
size_t
=
-
1
)
bool
start_array
(
std
::
size_t
)
{
return
events_left
--
>
0
;
}
...
...
test/src/unit-ubjson.cpp
View file @
9bbb1330
...
...
@@ -70,7 +70,7 @@ class SaxCountdown
return
events_left
--
>
0
;
}
bool
start_object
(
std
::
size_t
=
-
1
)
bool
start_object
(
std
::
size_t
)
{
return
events_left
--
>
0
;
}
...
...
@@ -85,7 +85,7 @@ class SaxCountdown
return
events_left
--
>
0
;
}
bool
start_array
(
std
::
size_t
=
-
1
)
bool
start_array
(
std
::
size_t
)
{
return
events_left
--
>
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment