Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
3abb7881
Unverified
Commit
3abb7881
authored
Oct 07, 2018
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚨
fixed some more clang-tidy warnings
parent
858e75c4
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
42 deletions
+22
-42
json_sax.hpp
include/nlohmann/detail/input/json_sax.hpp
+5
-6
lexer.hpp
include/nlohmann/detail/input/lexer.hpp
+1
-3
parser.hpp
include/nlohmann/detail/input/parser.hpp
+0
-3
binary_writer.hpp
include/nlohmann/detail/output/binary_writer.hpp
+8
-12
json.hpp
include/nlohmann/json.hpp
+1
-3
json.hpp
single_include/nlohmann/json.hpp
+7
-15
No files found.
include/nlohmann/detail/input/json_sax.hpp
View file @
3abb7881
...
@@ -286,9 +286,9 @@ class json_sax_dom_parser
...
@@ -286,9 +286,9 @@ class json_sax_dom_parser
root
=
BasicJsonType
(
std
::
forward
<
Value
>
(
v
));
root
=
BasicJsonType
(
std
::
forward
<
Value
>
(
v
));
return
&
root
;
return
&
root
;
}
}
else
{
assert
(
ref_stack
.
back
()
->
is_array
()
or
ref_stack
.
back
()
->
is_object
());
assert
(
ref_stack
.
back
()
->
is_array
()
or
ref_stack
.
back
()
->
is_object
());
if
(
ref_stack
.
back
()
->
is_array
())
if
(
ref_stack
.
back
()
->
is_array
())
{
{
ref_stack
.
back
()
->
m_value
.
array
->
emplace_back
(
std
::
forward
<
Value
>
(
v
));
ref_stack
.
back
()
->
m_value
.
array
->
emplace_back
(
std
::
forward
<
Value
>
(
v
));
...
@@ -301,7 +301,6 @@ class json_sax_dom_parser
...
@@ -301,7 +301,6 @@ class json_sax_dom_parser
return
object_element
;
return
object_element
;
}
}
}
}
}
/// the parsed JSON value
/// the parsed JSON value
BasicJsonType
&
root
;
BasicJsonType
&
root
;
...
@@ -574,8 +573,7 @@ class json_sax_dom_callback_parser
...
@@ -574,8 +573,7 @@ class json_sax_dom_callback_parser
root
=
std
::
move
(
value
);
root
=
std
::
move
(
value
);
return
{
true
,
&
root
};
return
{
true
,
&
root
};
}
}
else
{
// skip this value if we already decided to skip the parent
// skip this value if we already decided to skip the parent
// (https://github.com/nlohmann/json/issues/971#issuecomment-413678360)
// (https://github.com/nlohmann/json/issues/971#issuecomment-413678360)
if
(
not
ref_stack
.
back
())
if
(
not
ref_stack
.
back
())
...
@@ -583,7 +581,9 @@ class json_sax_dom_callback_parser
...
@@ -583,7 +581,9 @@ class json_sax_dom_callback_parser
return
{
false
,
nullptr
};
return
{
false
,
nullptr
};
}
}
// we now only expect arrays and objects
assert
(
ref_stack
.
back
()
->
is_array
()
or
ref_stack
.
back
()
->
is_object
());
assert
(
ref_stack
.
back
()
->
is_array
()
or
ref_stack
.
back
()
->
is_object
());
if
(
ref_stack
.
back
()
->
is_array
())
if
(
ref_stack
.
back
()
->
is_array
())
{
{
ref_stack
.
back
()
->
m_value
.
array
->
push_back
(
std
::
move
(
value
));
ref_stack
.
back
()
->
m_value
.
array
->
push_back
(
std
::
move
(
value
));
...
@@ -606,7 +606,6 @@ class json_sax_dom_callback_parser
...
@@ -606,7 +606,6 @@ class json_sax_dom_callback_parser
return
{
true
,
object_element
};
return
{
true
,
object_element
};
}
}
}
}
}
/// the parsed JSON value
/// the parsed JSON value
BasicJsonType
&
root
;
BasicJsonType
&
root
;
...
...
include/nlohmann/detail/input/lexer.hpp
View file @
3abb7881
...
@@ -1214,14 +1214,12 @@ scan_number_done:
...
@@ -1214,14 +1214,12 @@ scan_number_done:
// check if we completely parse the BOM
// check if we completely parse the BOM
return
get
()
==
0xBB
and
get
()
==
0xBF
;
return
get
()
==
0xBB
and
get
()
==
0xBF
;
}
}
else
{
// the first character is not the beginning of the BOM; unget it to
// the first character is not the beginning of the BOM; unget it to
// process is later
// process is later
unget
();
unget
();
return
true
;
return
true
;
}
}
}
token_type
scan
()
token_type
scan
()
{
{
...
...
include/nlohmann/detail/input/parser.hpp
View file @
3abb7881
...
@@ -201,13 +201,10 @@ class parser
...
@@ -201,13 +201,10 @@ class parser
m_lexer
.
get_token_string
(),
m_lexer
.
get_token_string
(),
parse_error
::
create
(
101
,
m_lexer
.
get_position
(),
exception_message
(
token_type
::
value_string
)));
parse_error
::
create
(
101
,
m_lexer
.
get_position
(),
exception_message
(
token_type
::
value_string
)));
}
}
else
{
if
(
JSON_UNLIKELY
(
not
sax
->
key
(
m_lexer
.
get_string
())))
if
(
JSON_UNLIKELY
(
not
sax
->
key
(
m_lexer
.
get_string
())))
{
{
return
false
;
return
false
;
}
}
}
// parse separator (:)
// parse separator (:)
if
(
JSON_UNLIKELY
(
get_token
()
!=
token_type
::
name_separator
))
if
(
JSON_UNLIKELY
(
get_token
()
!=
token_type
::
name_separator
))
...
...
include/nlohmann/detail/output/binary_writer.hpp
View file @
3abb7881
...
@@ -851,23 +851,21 @@ class binary_writer
...
@@ -851,23 +851,21 @@ class binary_writer
{
{
return
'i'
;
return
'i'
;
}
}
else
if
((
std
::
numeric_limits
<
uint8_t
>::
min
)()
<=
j
.
m_value
.
number_integer
and
j
.
m_value
.
number_integer
<=
(
std
::
numeric_limits
<
uint8_t
>::
max
)())
if
((
std
::
numeric_limits
<
uint8_t
>::
min
)()
<=
j
.
m_value
.
number_integer
and
j
.
m_value
.
number_integer
<=
(
std
::
numeric_limits
<
uint8_t
>::
max
)())
{
{
return
'U'
;
return
'U'
;
}
}
else
if
((
std
::
numeric_limits
<
int16_t
>::
min
)()
<=
j
.
m_value
.
number_integer
and
j
.
m_value
.
number_integer
<=
(
std
::
numeric_limits
<
int16_t
>::
max
)())
if
((
std
::
numeric_limits
<
int16_t
>::
min
)()
<=
j
.
m_value
.
number_integer
and
j
.
m_value
.
number_integer
<=
(
std
::
numeric_limits
<
int16_t
>::
max
)())
{
{
return
'I'
;
return
'I'
;
}
}
else
if
((
std
::
numeric_limits
<
int32_t
>::
min
)()
<=
j
.
m_value
.
number_integer
and
j
.
m_value
.
number_integer
<=
(
std
::
numeric_limits
<
int32_t
>::
max
)())
if
((
std
::
numeric_limits
<
int32_t
>::
min
)()
<=
j
.
m_value
.
number_integer
and
j
.
m_value
.
number_integer
<=
(
std
::
numeric_limits
<
int32_t
>::
max
)())
{
{
return
'l'
;
return
'l'
;
}
}
else
// no check and assume int64_t (see note above)
// no check and assume int64_t (see note above)
{
return
'L'
;
return
'L'
;
}
}
}
case
value_t
:
:
number_unsigned
:
case
value_t
:
:
number_unsigned
:
{
{
...
@@ -875,23 +873,21 @@ class binary_writer
...
@@ -875,23 +873,21 @@ class binary_writer
{
{
return
'i'
;
return
'i'
;
}
}
else
if
(
j
.
m_value
.
number_unsigned
<=
(
std
::
numeric_limits
<
uint8_t
>::
max
)())
if
(
j
.
m_value
.
number_unsigned
<=
(
std
::
numeric_limits
<
uint8_t
>::
max
)())
{
{
return
'U'
;
return
'U'
;
}
}
else
if
(
j
.
m_value
.
number_unsigned
<=
(
std
::
numeric_limits
<
int16_t
>::
max
)())
if
(
j
.
m_value
.
number_unsigned
<=
(
std
::
numeric_limits
<
int16_t
>::
max
)())
{
{
return
'I'
;
return
'I'
;
}
}
else
if
(
j
.
m_value
.
number_unsigned
<=
(
std
::
numeric_limits
<
int32_t
>::
max
)())
if
(
j
.
m_value
.
number_unsigned
<=
(
std
::
numeric_limits
<
int32_t
>::
max
)())
{
{
return
'l'
;
return
'l'
;
}
}
else
// no check and assume int64_t (see note above)
// no check and assume int64_t (see note above)
{
return
'L'
;
return
'L'
;
}
}
}
case
value_t
:
:
number_float
:
case
value_t
:
:
number_float
:
return
get_ubjson_float_prefix
(
j
.
m_value
.
number_float
);
return
get_ubjson_float_prefix
(
j
.
m_value
.
number_float
);
...
...
include/nlohmann/json.hpp
View file @
3abb7881
...
@@ -7289,12 +7289,10 @@ class basic_json
...
@@ -7289,12 +7289,10 @@ class basic_json
// avoid undefined behavior
// avoid undefined behavior
JSON_THROW
(
out_of_range
::
create
(
401
,
"array index "
+
std
::
to_string
(
idx
)
+
" is out of range"
));
JSON_THROW
(
out_of_range
::
create
(
401
,
"array index "
+
std
::
to_string
(
idx
)
+
" is out of range"
));
}
}
else
{
// default case: insert add offset
// default case: insert add offset
parent
.
insert
(
parent
.
begin
()
+
static_cast
<
difference_type
>
(
idx
),
val
);
parent
.
insert
(
parent
.
begin
()
+
static_cast
<
difference_type
>
(
idx
),
val
);
}
}
}
break
;
break
;
}
}
...
...
single_include/nlohmann/json.hpp
View file @
3abb7881
...
@@ -3483,14 +3483,12 @@ scan_number_done:
...
@@ -3483,14 +3483,12 @@ scan_number_done:
// check if we completely parse the BOM
// check if we completely parse the BOM
return
get
()
==
0xBB
and
get
()
==
0xBF
;
return
get
()
==
0xBB
and
get
()
==
0xBF
;
}
}
else
{
// the first character is not the beginning of the BOM; unget it to
// the first character is not the beginning of the BOM; unget it to
// process is later
// process is later
unget
();
unget
();
return
true
;
return
true
;
}
}
}
token_type
scan
()
token_type
scan
()
{
{
...
@@ -4048,9 +4046,9 @@ class json_sax_dom_parser
...
@@ -4048,9 +4046,9 @@ class json_sax_dom_parser
root
=
BasicJsonType
(
std
::
forward
<
Value
>
(
v
));
root
=
BasicJsonType
(
std
::
forward
<
Value
>
(
v
));
return
&
root
;
return
&
root
;
}
}
else
{
assert
(
ref_stack
.
back
()
->
is_array
()
or
ref_stack
.
back
()
->
is_object
());
assert
(
ref_stack
.
back
()
->
is_array
()
or
ref_stack
.
back
()
->
is_object
());
if
(
ref_stack
.
back
()
->
is_array
())
if
(
ref_stack
.
back
()
->
is_array
())
{
{
ref_stack
.
back
()
->
m_value
.
array
->
emplace_back
(
std
::
forward
<
Value
>
(
v
));
ref_stack
.
back
()
->
m_value
.
array
->
emplace_back
(
std
::
forward
<
Value
>
(
v
));
...
@@ -4063,7 +4061,6 @@ class json_sax_dom_parser
...
@@ -4063,7 +4061,6 @@ class json_sax_dom_parser
return
object_element
;
return
object_element
;
}
}
}
}
}
/// the parsed JSON value
/// the parsed JSON value
BasicJsonType
&
root
;
BasicJsonType
&
root
;
...
@@ -4336,8 +4333,7 @@ class json_sax_dom_callback_parser
...
@@ -4336,8 +4333,7 @@ class json_sax_dom_callback_parser
root
=
std
::
move
(
value
);
root
=
std
::
move
(
value
);
return
{
true
,
&
root
};
return
{
true
,
&
root
};
}
}
else
{
// skip this value if we already decided to skip the parent
// skip this value if we already decided to skip the parent
// (https://github.com/nlohmann/json/issues/971#issuecomment-413678360)
// (https://github.com/nlohmann/json/issues/971#issuecomment-413678360)
if
(
not
ref_stack
.
back
())
if
(
not
ref_stack
.
back
())
...
@@ -4345,7 +4341,9 @@ class json_sax_dom_callback_parser
...
@@ -4345,7 +4341,9 @@ class json_sax_dom_callback_parser
return
{
false
,
nullptr
};
return
{
false
,
nullptr
};
}
}
// we now only expect arrays and objects
assert
(
ref_stack
.
back
()
->
is_array
()
or
ref_stack
.
back
()
->
is_object
());
assert
(
ref_stack
.
back
()
->
is_array
()
or
ref_stack
.
back
()
->
is_object
());
if
(
ref_stack
.
back
()
->
is_array
())
if
(
ref_stack
.
back
()
->
is_array
())
{
{
ref_stack
.
back
()
->
m_value
.
array
->
push_back
(
std
::
move
(
value
));
ref_stack
.
back
()
->
m_value
.
array
->
push_back
(
std
::
move
(
value
));
...
@@ -4368,7 +4366,6 @@ class json_sax_dom_callback_parser
...
@@ -4368,7 +4366,6 @@ class json_sax_dom_callback_parser
return
{
true
,
object_element
};
return
{
true
,
object_element
};
}
}
}
}
}
/// the parsed JSON value
/// the parsed JSON value
BasicJsonType
&
root
;
BasicJsonType
&
root
;
...
@@ -4654,13 +4651,10 @@ class parser
...
@@ -4654,13 +4651,10 @@ class parser
m_lexer
.
get_token_string
(),
m_lexer
.
get_token_string
(),
parse_error
::
create
(
101
,
m_lexer
.
get_position
(),
exception_message
(
token_type
::
value_string
)));
parse_error
::
create
(
101
,
m_lexer
.
get_position
(),
exception_message
(
token_type
::
value_string
)));
}
}
else
{
if
(
JSON_UNLIKELY
(
not
sax
->
key
(
m_lexer
.
get_string
())))
if
(
JSON_UNLIKELY
(
not
sax
->
key
(
m_lexer
.
get_string
())))
{
{
return
false
;
return
false
;
}
}
}
// parse separator (:)
// parse separator (:)
if
(
JSON_UNLIKELY
(
get_token
()
!=
token_type
::
name_separator
))
if
(
JSON_UNLIKELY
(
get_token
()
!=
token_type
::
name_separator
))
...
@@ -18392,12 +18386,10 @@ class basic_json
...
@@ -18392,12 +18386,10 @@ class basic_json
// avoid undefined behavior
// avoid undefined behavior
JSON_THROW
(
out_of_range
::
create
(
401
,
"array index "
+
std
::
to_string
(
idx
)
+
" is out of range"
));
JSON_THROW
(
out_of_range
::
create
(
401
,
"array index "
+
std
::
to_string
(
idx
)
+
" is out of range"
));
}
}
else
{
// default case: insert add offset
// default case: insert add offset
parent
.
insert
(
parent
.
begin
()
+
static_cast
<
difference_type
>
(
idx
),
val
);
parent
.
insert
(
parent
.
begin
()
+
static_cast
<
difference_type
>
(
idx
),
val
);
}
}
}
break
;
break
;
}
}
...
...
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