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
8d3f4f21
Unverified
Commit
8d3f4f21
authored
Mar 18, 2019
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔨
clean up
parent
9fc093c9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
33 additions
and
67 deletions
+33
-67
to_chars.hpp
include/nlohmann/detail/conversions/to_chars.hpp
+2
-2
binary_reader.hpp
include/nlohmann/detail/input/binary_reader.hpp
+7
-14
input_adapters.hpp
include/nlohmann/detail/input/input_adapters.hpp
+0
-0
json_sax.hpp
include/nlohmann/detail/input/json_sax.hpp
+13
-30
lexer.hpp
include/nlohmann/detail/input/lexer.hpp
+2
-6
parser.hpp
include/nlohmann/detail/input/parser.hpp
+1
-1
json_pointer.hpp
include/nlohmann/detail/json_pointer.hpp
+2
-2
macro_scope.hpp
include/nlohmann/detail/macro_scope.hpp
+2
-2
serializer.hpp
include/nlohmann/detail/output/serializer.hpp
+4
-10
json.hpp
include/nlohmann/json.hpp
+0
-0
json.hpp
single_include/nlohmann/json.hpp
+0
-0
No files found.
include/nlohmann/detail/conversions/to_chars.hpp
View file @
8d3f4f21
...
...
@@ -204,7 +204,7 @@ boundaries compute_boundaries(FloatType value)
const
std
::
uint64_t
E
=
bits
>>
(
kPrecision
-
1
);
const
std
::
uint64_t
F
=
bits
&
(
kHiddenBit
-
1
);
const
bool
is_denormal
=
(
E
==
0
)
;
const
bool
is_denormal
=
E
==
0
;
const
diyfp
v
=
is_denormal
?
diyfp
(
F
,
kMinExp
)
:
diyfp
(
F
+
kHiddenBit
,
static_cast
<
int
>
(
E
)
-
kBias
);
...
...
@@ -230,7 +230,7 @@ boundaries compute_boundaries(FloatType value)
// -----------------+------+------+-------------+-------------+--- (B)
// v- m- v m+ v+
const
bool
lower_boundary_is_closer
=
(
F
==
0
and
E
>
1
)
;
const
bool
lower_boundary_is_closer
=
F
==
0
and
E
>
1
;
const
diyfp
m_plus
=
diyfp
(
2
*
v
.
f
+
1
,
v
.
e
-
1
);
const
diyfp
m_minus
=
lower_boundary_is_closer
?
diyfp
(
4
*
v
.
f
-
1
,
v
.
e
-
2
)
// (B)
...
...
include/nlohmann/detail/input/binary_reader.hpp
View file @
8d3f4f21
...
...
@@ -91,10 +91,8 @@ class binary_reader
result
=
parse_ubjson_internal
();
break
;
// LCOV_EXCL_START
default:
assert
(
false
);
// LCOV_EXCL_STOP
default:
// LCOV_EXCL_LINE
assert
(
false
);
// LCOV_EXCL_LINE
}
// strict mode: next byte must be EOF
...
...
@@ -128,7 +126,7 @@ class binary_reader
*/
static
constexpr
bool
little_endianess
(
int
num
=
1
)
noexcept
{
return
(
*
reinterpret_cast
<
char
*>
(
&
num
)
==
1
)
;
return
*
reinterpret_cast
<
char
*>
(
&
num
)
==
1
;
}
private
:
...
...
@@ -305,13 +303,10 @@ class binary_reader
return
false
;
}
if
(
not
is_array
)
{
if
(
not
sax
->
key
(
key
))
if
(
not
is_array
and
not
sax
->
key
(
key
))
{
return
false
;
}
}
if
(
JSON_UNLIKELY
(
not
parse_bson_element_internal
(
element_type
,
element_type_parse_position
)))
{
...
...
@@ -1818,7 +1813,7 @@ class binary_reader
int
get
()
{
++
chars_read
;
return
(
current
=
ia
->
get_character
()
);
return
current
=
ia
->
get_character
(
);
}
/*!
...
...
@@ -1964,10 +1959,8 @@ class binary_reader
error_msg
+=
"BSON"
;
break
;
// LCOV_EXCL_START
default
:
assert
(
false
);
// LCOV_EXCL_STOP
default
:
// LCOV_EXCL_LINE
assert
(
false
);
// LCOV_EXCL_LINE
}
return
error_msg
+
" "
+
context
+
": "
+
detail
;
...
...
include/nlohmann/detail/input/input_adapters.hpp
View file @
8d3f4f21
include/nlohmann/detail/input/json_sax.hpp
View file @
8d3f4f21
...
...
@@ -303,13 +303,12 @@ class json_sax_dom_parser
ref_stack
.
back
()
->
m_value
.
array
->
emplace_back
(
std
::
forward
<
Value
>
(
v
));
return
&
(
ref_stack
.
back
()
->
m_value
.
array
->
back
());
}
else
{
assert
(
ref_stack
.
back
()
->
is_object
())
assert
(
object_element
);
*
object_element
=
BasicJsonType
(
std
::
forward
<
Value
>
(
v
));
return
object_element
;
}
}
/// the parsed JSON value
BasicJsonType
&
root
;
...
...
@@ -395,13 +394,9 @@ class json_sax_dom_callback_parser
ref_stack
.
push_back
(
val
.
second
);
// check object limit
if
(
ref_stack
.
back
())
if
(
ref_stack
.
back
()
and
JSON_UNLIKELY
(
len
!=
std
::
size_t
(
-
1
)
and
len
>
ref_stack
.
back
()
->
max_size
())
)
{
if
(
JSON_UNLIKELY
(
len
!=
std
::
size_t
(
-
1
)
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive object size: "
+
std
::
to_string
(
len
)));
}
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive object size: "
+
std
::
to_string
(
len
)));
}
return
true
;
...
...
@@ -426,25 +421,20 @@ class json_sax_dom_callback_parser
bool
end_object
()
{
if
(
ref_stack
.
back
())
{
if
(
not
callback
(
static_cast
<
int
>
(
ref_stack
.
size
())
-
1
,
parse_event_t
::
object_end
,
*
ref_stack
.
back
()))
if
(
ref_stack
.
back
()
and
not
callback
(
static_cast
<
int
>
(
ref_stack
.
size
())
-
1
,
parse_event_t
::
object_end
,
*
ref_stack
.
back
()))
{
// discard object
*
ref_stack
.
back
()
=
discarded
;
}
}
assert
(
not
ref_stack
.
empty
());
assert
(
not
keep_stack
.
empty
());
ref_stack
.
pop_back
();
keep_stack
.
pop_back
();
if
(
not
ref_stack
.
empty
()
and
ref_stack
.
back
())
if
(
not
ref_stack
.
empty
()
and
ref_stack
.
back
()
and
ref_stack
.
back
()
->
is_object
()
)
{
// remove discarded value
if
(
ref_stack
.
back
()
->
is_object
())
{
for
(
auto
it
=
ref_stack
.
back
()
->
begin
();
it
!=
ref_stack
.
back
()
->
end
();
++
it
)
{
if
(
it
->
is_discarded
())
...
...
@@ -454,7 +444,6 @@ class json_sax_dom_callback_parser
}
}
}
}
return
true
;
}
...
...
@@ -468,13 +457,9 @@ class json_sax_dom_callback_parser
ref_stack
.
push_back
(
val
.
second
);
// check array limit
if
(
ref_stack
.
back
())
{
if
(
JSON_UNLIKELY
(
len
!=
std
::
size_t
(
-
1
)
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
ref_stack
.
back
()
and
JSON_UNLIKELY
(
len
!=
std
::
size_t
(
-
1
)
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive array size: "
+
std
::
to_string
(
len
)));
}
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive array size: "
+
std
::
to_string
(
len
)));
}
return
true
;
...
...
@@ -500,13 +485,10 @@ class json_sax_dom_callback_parser
keep_stack
.
pop_back
();
// remove discarded value
if
(
not
keep
and
not
ref_stack
.
empty
())
{
if
(
ref_stack
.
back
()
->
is_array
())
if
(
not
keep
and
not
ref_stack
.
empty
()
and
ref_stack
.
back
()
->
is_array
())
{
ref_stack
.
back
()
->
m_value
.
array
->
pop_back
();
}
}
return
true
;
}
...
...
@@ -600,13 +582,15 @@ class json_sax_dom_callback_parser
// we now only expect arrays and objects
assert
(
ref_stack
.
back
()
->
is_array
()
or
ref_stack
.
back
()
->
is_object
());
// array
if
(
ref_stack
.
back
()
->
is_array
())
{
ref_stack
.
back
()
->
m_value
.
array
->
push_back
(
std
::
move
(
value
));
return
{
true
,
&
(
ref_stack
.
back
()
->
m_value
.
array
->
back
())};
}
else
{
// object
assert
(
ref_stack
.
back
()
->
is_object
())
// check if we should store an element for the current key
assert
(
not
key_keep_stack
.
empty
());
const
bool
store_element
=
key_keep_stack
.
back
();
...
...
@@ -621,7 +605,6 @@ class json_sax_dom_callback_parser
*
object_element
=
std
::
move
(
value
);
return
{
true
,
object_element
};
}
}
/// the parsed JSON value
BasicJsonType
&
root
;
...
...
include/nlohmann/detail/input/lexer.hpp
View file @
8d3f4f21
...
...
@@ -908,13 +908,9 @@ class lexer
goto
scan_number_any1
;
}
// LCOV_EXCL_START
default
:
{
// all other characters are rejected outside scan_number()
assert
(
false
);
}
// LCOV_EXCL_STOP
default
:
// LCOV_EXCL_LINE
assert
(
false
);
// LCOV_EXCL_LINE
}
scan_number_minus
:
...
...
include/nlohmann/detail/input/parser.hpp
View file @
8d3f4f21
...
...
@@ -459,7 +459,7 @@ class parser
/// get next token from lexer
token_type
get_token
()
{
return
(
last_token
=
m_lexer
.
scan
()
);
return
last_token
=
m_lexer
.
scan
(
);
}
std
::
string
exception_message
(
const
token_type
expected
,
const
std
::
string
&
context
)
...
...
include/nlohmann/detail/json_pointer.hpp
View file @
8d3f4f21
...
...
@@ -344,7 +344,7 @@ class json_pointer
std
::
all_of
(
reference_token
.
begin
(),
reference_token
.
end
(),
[](
const
char
x
)
{
return
(
x
>=
'0'
and
x
<=
'9'
)
;
return
x
>=
'0'
and
x
<=
'9'
;
});
// change value to array for numbers or "-" or to object otherwise
...
...
@@ -793,7 +793,7 @@ class json_pointer
friend
bool
operator
==
(
json_pointer
const
&
lhs
,
json_pointer
const
&
rhs
)
noexcept
{
return
(
lhs
.
reference_tokens
==
rhs
.
reference_tokens
)
;
return
lhs
.
reference_tokens
==
rhs
.
reference_tokens
;
}
friend
bool
operator
!=
(
json_pointer
const
&
lhs
,
...
...
include/nlohmann/detail/macro_scope.hpp
View file @
8d3f4f21
...
...
@@ -88,8 +88,8 @@
// manual branch prediction
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
#define JSON_LIKELY(x) __builtin_expect(
!!
(x), 1)
#define JSON_UNLIKELY(x) __builtin_expect(
!!
(x), 0)
#define JSON_LIKELY(x) __builtin_expect(
static_cast<bool>
(x), 1)
#define JSON_UNLIKELY(x) __builtin_expect(
static_cast<bool>
(x), 0)
#else
#define JSON_LIKELY(x) x
#define JSON_UNLIKELY(x) x
...
...
include/nlohmann/detail/output/serializer.hpp
View file @
8d3f4f21
...
...
@@ -279,12 +279,10 @@ class serializer
return
;
}
default:
{
default:
// LCOV_EXCL_LINE
assert
(
false
);
// LCOV_EXCL_LINE
}
}
}
private
:
/*!
...
...
@@ -480,11 +478,9 @@ class serializer
break
;
}
default
:
{
default
:
// LCOV_EXCL_LINE
assert
(
false
);
// LCOV_EXCL_LINE
}
}
break
;
}
...
...
@@ -545,13 +541,11 @@ class serializer
break
;
}
default
:
{
default
:
// LCOV_EXCL_LINE
assert
(
false
);
// LCOV_EXCL_LINE
}
}
}
}
/*!
@brief count digits
...
...
@@ -755,7 +749,7 @@ class serializer
std
::
none_of
(
number_buffer
.
begin
(),
number_buffer
.
begin
()
+
len
+
1
,
[](
char
c
)
{
return
(
c
==
'.'
or
c
==
'e'
)
;
return
c
==
'.'
or
c
==
'e'
;
});
if
(
value_is_int_like
)
...
...
include/nlohmann/json.hpp
View file @
8d3f4f21
This diff is collapsed.
Click to expand it.
single_include/nlohmann/json.hpp
View file @
8d3f4f21
This diff is collapsed.
Click to expand it.
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