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
d2d65bb2
Unverified
Commit
d2d65bb2
authored
Mar 07, 2018
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
♻
refined SFINAE to fix some warnings
parent
476b2e09
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
174 additions
and
154 deletions
+174
-154
include/nlohmann/detail/output/binary_writer.hpp
include/nlohmann/detail/output/binary_writer.hpp
+87
-77
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+87
-77
No files found.
include/nlohmann/detail/output/binary_writer.hpp
View file @
d2d65bb2
...
@@ -704,11 +704,11 @@ class binary_writer
...
@@ -704,11 +704,11 @@ class binary_writer
oa
->
write_characters
(
vec
.
data
(),
sizeof
(
NumberType
));
oa
->
write_characters
(
vec
.
data
(),
sizeof
(
NumberType
));
}
}
template
<
typename
NumberType
>
// UBJSON: write number (floating point)
template
<
typename
NumberType
,
typename
std
::
enable_if
<
std
::
is_floating_point
<
NumberType
>
::
value
,
int
>::
type
=
0
>
void
write_number_with_ubjson_prefix
(
const
NumberType
n
,
void
write_number_with_ubjson_prefix
(
const
NumberType
n
,
const
bool
add_prefix
)
const
bool
add_prefix
)
{
if
(
std
::
is_floating_point
<
NumberType
>::
value
)
{
{
if
(
add_prefix
)
if
(
add_prefix
)
{
{
...
@@ -716,9 +716,14 @@ class binary_writer
...
@@ -716,9 +716,14 @@ class binary_writer
}
}
write_number
(
n
);
write_number
(
n
);
}
}
else
if
(
std
::
is_unsigned
<
NumberType
>::
value
)
// UBJSON: write number (unsigned integer)
template
<
typename
NumberType
,
typename
std
::
enable_if
<
std
::
is_unsigned
<
NumberType
>
::
value
,
int
>::
type
=
0
>
void
write_number_with_ubjson_prefix
(
const
NumberType
n
,
const
bool
add_prefix
)
{
{
if
(
n
<=
(
std
::
numeric_limits
<
int8_t
>::
max
)(
))
if
(
n
<=
static_cast
<
uint64_t
>
((
std
::
numeric_limits
<
int8_t
>::
max
)()
))
{
{
if
(
add_prefix
)
if
(
add_prefix
)
{
{
...
@@ -734,7 +739,7 @@ class binary_writer
...
@@ -734,7 +739,7 @@ class binary_writer
}
}
write_number
(
static_cast
<
uint8_t
>
(
n
));
write_number
(
static_cast
<
uint8_t
>
(
n
));
}
}
else
if
(
n
<=
(
std
::
numeric_limits
<
int16_t
>::
max
)(
))
else
if
(
n
<=
static_cast
<
uint64_t
>
((
std
::
numeric_limits
<
int16_t
>::
max
)()
))
{
{
if
(
add_prefix
)
if
(
add_prefix
)
{
{
...
@@ -742,7 +747,7 @@ class binary_writer
...
@@ -742,7 +747,7 @@ class binary_writer
}
}
write_number
(
static_cast
<
int16_t
>
(
n
));
write_number
(
static_cast
<
int16_t
>
(
n
));
}
}
else
if
(
n
<=
(
std
::
numeric_limits
<
int32_t
>::
max
)(
))
else
if
(
n
<=
static_cast
<
uint64_t
>
((
std
::
numeric_limits
<
int32_t
>::
max
)()
))
{
{
if
(
add_prefix
)
if
(
add_prefix
)
{
{
...
@@ -750,7 +755,7 @@ class binary_writer
...
@@ -750,7 +755,7 @@ class binary_writer
}
}
write_number
(
static_cast
<
int32_t
>
(
n
));
write_number
(
static_cast
<
int32_t
>
(
n
));
}
}
else
if
(
n
<=
(
std
::
numeric_limits
<
int64_t
>::
max
)(
))
else
if
(
n
<=
static_cast
<
uint64_t
>
((
std
::
numeric_limits
<
int64_t
>::
max
)()
))
{
{
if
(
add_prefix
)
if
(
add_prefix
)
{
{
...
@@ -763,7 +768,13 @@ class binary_writer
...
@@ -763,7 +768,13 @@ class binary_writer
JSON_THROW
(
out_of_range
::
create
(
407
,
"number overflow serializing "
+
std
::
to_string
(
n
)));
JSON_THROW
(
out_of_range
::
create
(
407
,
"number overflow serializing "
+
std
::
to_string
(
n
)));
}
}
}
}
else
// UBJSON: write number (signed integer)
template
<
typename
NumberType
,
typename
std
::
enable_if
<
std
::
is_signed
<
NumberType
>
::
value
and
not
std
::
is_floating_point
<
NumberType
>::
value
,
int
>::
type
=
0
>
void
write_number_with_ubjson_prefix
(
const
NumberType
n
,
const
bool
add_prefix
)
{
{
if
((
std
::
numeric_limits
<
int8_t
>::
min
)()
<=
n
and
n
<=
(
std
::
numeric_limits
<
int8_t
>::
max
)())
if
((
std
::
numeric_limits
<
int8_t
>::
min
)()
<=
n
and
n
<=
(
std
::
numeric_limits
<
int8_t
>::
max
)())
{
{
...
@@ -773,7 +784,7 @@ class binary_writer
...
@@ -773,7 +784,7 @@ class binary_writer
}
}
write_number
(
static_cast
<
int8_t
>
(
n
));
write_number
(
static_cast
<
int8_t
>
(
n
));
}
}
else
if
((
std
::
numeric_limits
<
uint8_t
>::
min
)()
<=
n
and
n
<=
(
std
::
numeric_limits
<
uint8_t
>::
max
)(
))
else
if
(
static_cast
<
int64_t
>
((
std
::
numeric_limits
<
uint8_t
>::
min
)())
<=
n
and
n
<=
static_cast
<
int64_t
>
((
std
::
numeric_limits
<
uint8_t
>::
max
)()
))
{
{
if
(
add_prefix
)
if
(
add_prefix
)
{
{
...
@@ -812,7 +823,6 @@ class binary_writer
...
@@ -812,7 +823,6 @@ class binary_writer
}
}
// LCOV_EXCL_STOP
// LCOV_EXCL_STOP
}
}
}
/*!
/*!
@brief determine the type prefix of container values
@brief determine the type prefix of container values
...
...
single_include/nlohmann/json.hpp
View file @
d2d65bb2
...
@@ -6909,11 +6909,11 @@ class binary_writer
...
@@ -6909,11 +6909,11 @@ class binary_writer
oa
->
write_characters
(
vec
.
data
(),
sizeof
(
NumberType
));
oa
->
write_characters
(
vec
.
data
(),
sizeof
(
NumberType
));
}
}
template
<
typename
NumberType
>
// UBJSON: write number (floating point)
template
<
typename
NumberType
,
typename
std
::
enable_if
<
std
::
is_floating_point
<
NumberType
>
::
value
,
int
>::
type
=
0
>
void
write_number_with_ubjson_prefix
(
const
NumberType
n
,
void
write_number_with_ubjson_prefix
(
const
NumberType
n
,
const
bool
add_prefix
)
const
bool
add_prefix
)
{
if
(
std
::
is_floating_point
<
NumberType
>::
value
)
{
{
if
(
add_prefix
)
if
(
add_prefix
)
{
{
...
@@ -6921,9 +6921,14 @@ class binary_writer
...
@@ -6921,9 +6921,14 @@ class binary_writer
}
}
write_number
(
n
);
write_number
(
n
);
}
}
else
if
(
std
::
is_unsigned
<
NumberType
>::
value
)
// UBJSON: write number (unsigned integer)
template
<
typename
NumberType
,
typename
std
::
enable_if
<
std
::
is_unsigned
<
NumberType
>
::
value
,
int
>::
type
=
0
>
void
write_number_with_ubjson_prefix
(
const
NumberType
n
,
const
bool
add_prefix
)
{
{
if
(
n
<=
(
std
::
numeric_limits
<
int8_t
>::
max
)(
))
if
(
n
<=
static_cast
<
uint64_t
>
((
std
::
numeric_limits
<
int8_t
>::
max
)()
))
{
{
if
(
add_prefix
)
if
(
add_prefix
)
{
{
...
@@ -6939,7 +6944,7 @@ class binary_writer
...
@@ -6939,7 +6944,7 @@ class binary_writer
}
}
write_number
(
static_cast
<
uint8_t
>
(
n
));
write_number
(
static_cast
<
uint8_t
>
(
n
));
}
}
else
if
(
n
<=
(
std
::
numeric_limits
<
int16_t
>::
max
)(
))
else
if
(
n
<=
static_cast
<
uint64_t
>
((
std
::
numeric_limits
<
int16_t
>::
max
)()
))
{
{
if
(
add_prefix
)
if
(
add_prefix
)
{
{
...
@@ -6947,7 +6952,7 @@ class binary_writer
...
@@ -6947,7 +6952,7 @@ class binary_writer
}
}
write_number
(
static_cast
<
int16_t
>
(
n
));
write_number
(
static_cast
<
int16_t
>
(
n
));
}
}
else
if
(
n
<=
(
std
::
numeric_limits
<
int32_t
>::
max
)(
))
else
if
(
n
<=
static_cast
<
uint64_t
>
((
std
::
numeric_limits
<
int32_t
>::
max
)()
))
{
{
if
(
add_prefix
)
if
(
add_prefix
)
{
{
...
@@ -6955,7 +6960,7 @@ class binary_writer
...
@@ -6955,7 +6960,7 @@ class binary_writer
}
}
write_number
(
static_cast
<
int32_t
>
(
n
));
write_number
(
static_cast
<
int32_t
>
(
n
));
}
}
else
if
(
n
<=
(
std
::
numeric_limits
<
int64_t
>::
max
)(
))
else
if
(
n
<=
static_cast
<
uint64_t
>
((
std
::
numeric_limits
<
int64_t
>::
max
)()
))
{
{
if
(
add_prefix
)
if
(
add_prefix
)
{
{
...
@@ -6968,7 +6973,13 @@ class binary_writer
...
@@ -6968,7 +6973,13 @@ class binary_writer
JSON_THROW
(
out_of_range
::
create
(
407
,
"number overflow serializing "
+
std
::
to_string
(
n
)));
JSON_THROW
(
out_of_range
::
create
(
407
,
"number overflow serializing "
+
std
::
to_string
(
n
)));
}
}
}
}
else
// UBJSON: write number (signed integer)
template
<
typename
NumberType
,
typename
std
::
enable_if
<
std
::
is_signed
<
NumberType
>
::
value
and
not
std
::
is_floating_point
<
NumberType
>::
value
,
int
>::
type
=
0
>
void
write_number_with_ubjson_prefix
(
const
NumberType
n
,
const
bool
add_prefix
)
{
{
if
((
std
::
numeric_limits
<
int8_t
>::
min
)()
<=
n
and
n
<=
(
std
::
numeric_limits
<
int8_t
>::
max
)())
if
((
std
::
numeric_limits
<
int8_t
>::
min
)()
<=
n
and
n
<=
(
std
::
numeric_limits
<
int8_t
>::
max
)())
{
{
...
@@ -6978,7 +6989,7 @@ class binary_writer
...
@@ -6978,7 +6989,7 @@ class binary_writer
}
}
write_number
(
static_cast
<
int8_t
>
(
n
));
write_number
(
static_cast
<
int8_t
>
(
n
));
}
}
else
if
((
std
::
numeric_limits
<
uint8_t
>::
min
)()
<=
n
and
n
<=
(
std
::
numeric_limits
<
uint8_t
>::
max
)(
))
else
if
(
static_cast
<
int64_t
>
((
std
::
numeric_limits
<
uint8_t
>::
min
)())
<=
n
and
n
<=
static_cast
<
int64_t
>
((
std
::
numeric_limits
<
uint8_t
>::
max
)()
))
{
{
if
(
add_prefix
)
if
(
add_prefix
)
{
{
...
@@ -7017,7 +7028,6 @@ class binary_writer
...
@@ -7017,7 +7028,6 @@ class binary_writer
}
}
// LCOV_EXCL_STOP
// LCOV_EXCL_STOP
}
}
}
/*!
/*!
@brief determine the type prefix of container values
@brief determine the type prefix of container values
...
...
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