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
b02ee167
Unverified
Commit
b02ee167
authored
6 years ago
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed warnings
parent
8d6c033f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
100 deletions
+100
-100
include/nlohmann/detail/input/binary_reader.hpp
include/nlohmann/detail/input/binary_reader.hpp
+10
-10
include/nlohmann/detail/input/input_adapters.hpp
include/nlohmann/detail/input/input_adapters.hpp
+22
-22
include/nlohmann/detail/input/lexer.hpp
include/nlohmann/detail/input/lexer.hpp
+17
-17
include/nlohmann/detail/json_ref.hpp
include/nlohmann/detail/json_ref.hpp
+1
-1
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+50
-50
No files found.
include/nlohmann/detail/input/binary_reader.hpp
View file @
b02ee167
...
@@ -522,7 +522,7 @@ class binary_reader
...
@@ -522,7 +522,7 @@ class binary_reader
case
0x95
:
case
0x95
:
case
0x96
:
case
0x96
:
case
0x97
:
case
0x97
:
return
get_cbor_array
(
static_cast
<
std
::
size_t
>
(
current
&
0x1F
));
return
get_cbor_array
(
static_cast
<
std
::
size_t
>
(
static_cast
<
unsigned
int
>
(
current
)
&
0x1Fu
));
case
0x98
:
// array (one-byte uint8_t for n follows)
case
0x98
:
// array (one-byte uint8_t for n follows)
{
{
...
@@ -576,7 +576,7 @@ class binary_reader
...
@@ -576,7 +576,7 @@ class binary_reader
case
0xB5
:
case
0xB5
:
case
0xB6
:
case
0xB6
:
case
0xB7
:
case
0xB7
:
return
get_cbor_object
(
static_cast
<
std
::
size_t
>
(
current
&
0x1F
));
return
get_cbor_object
(
static_cast
<
std
::
size_t
>
(
static_cast
<
unsigned
int
>
(
current
)
&
0x1Fu
));
case
0xB8
:
// map (one-byte uint8_t for n follows)
case
0xB8
:
// map (one-byte uint8_t for n follows)
{
{
...
@@ -638,11 +638,11 @@ class binary_reader
...
@@ -638,11 +638,11 @@ class binary_reader
// without such support. An example of a small decoder for
// without such support. An example of a small decoder for
// half-precision floating-point numbers in the C language
// half-precision floating-point numbers in the C language
// is shown in Fig. 3.
// is shown in Fig. 3.
const
int
half
=
(
byte1
<<
8
)
+
byte2
;
const
unsigned
int
half
=
(
byte1
<<
8u
)
+
byte2
;
const
double
val
=
[
&
half
]
const
double
val
=
[
&
half
]
{
{
const
int
exp
=
(
half
>>
10
)
&
0x1F
;
const
unsigned
int
exp
=
(
half
>>
10u
)
&
0x1Fu
;
const
int
mant
=
half
&
0x3FF
;
const
unsigned
int
mant
=
half
&
0x3FFu
;
assert
(
0
<=
exp
and
exp
<=
32
);
assert
(
0
<=
exp
and
exp
<=
32
);
assert
(
0
<=
mant
and
mant
<=
1024
);
assert
(
0
<=
mant
and
mant
<=
1024
);
switch
(
exp
)
switch
(
exp
)
...
@@ -657,7 +657,7 @@ class binary_reader
...
@@ -657,7 +657,7 @@ class binary_reader
return
std
::
ldexp
(
mant
+
1024
,
exp
-
25
);
return
std
::
ldexp
(
mant
+
1024
,
exp
-
25
);
}
}
}();
}();
return
sax
->
number_float
((
half
&
0x8000
)
!=
0
return
sax
->
number_float
((
half
&
0x8000
u
)
!=
0
?
static_cast
<
number_float_t
>
(
-
val
)
?
static_cast
<
number_float_t
>
(
-
val
)
:
static_cast
<
number_float_t
>
(
val
),
""
);
:
static_cast
<
number_float_t
>
(
val
),
""
);
}
}
...
@@ -728,7 +728,7 @@ class binary_reader
...
@@ -728,7 +728,7 @@ class binary_reader
case
0x76
:
case
0x76
:
case
0x77
:
case
0x77
:
{
{
return
get_string
(
input_format_t
::
cbor
,
current
&
0x1F
,
result
);
return
get_string
(
input_format_t
::
cbor
,
static_cast
<
unsigned
int
>
(
current
)
&
0x1Fu
,
result
);
}
}
case
0x78
:
// UTF-8 string (one-byte uint8_t for n follows)
case
0x78
:
// UTF-8 string (one-byte uint8_t for n follows)
...
@@ -1026,7 +1026,7 @@ class binary_reader
...
@@ -1026,7 +1026,7 @@ class binary_reader
case
0x8D
:
case
0x8D
:
case
0x8E
:
case
0x8E
:
case
0x8F
:
case
0x8F
:
return
get_msgpack_object
(
static_cast
<
std
::
size_t
>
(
current
&
0x0F
));
return
get_msgpack_object
(
static_cast
<
std
::
size_t
>
(
static_cast
<
unsigned
int
>
(
current
)
&
0x0Fu
));
// fixarray
// fixarray
case
0x90
:
case
0x90
:
...
@@ -1045,7 +1045,7 @@ class binary_reader
...
@@ -1045,7 +1045,7 @@ class binary_reader
case
0x9D
:
case
0x9D
:
case
0x9E
:
case
0x9E
:
case
0x9F
:
case
0x9F
:
return
get_msgpack_array
(
static_cast
<
std
::
size_t
>
(
current
&
0x0F
));
return
get_msgpack_array
(
static_cast
<
std
::
size_t
>
(
static_cast
<
unsigned
int
>
(
current
)
&
0x0Fu
));
// fixstr
// fixstr
case
0xA0
:
case
0xA0
:
...
@@ -1282,7 +1282,7 @@ class binary_reader
...
@@ -1282,7 +1282,7 @@ class binary_reader
case
0xBE
:
case
0xBE
:
case
0xBF
:
case
0xBF
:
{
{
return
get_string
(
input_format_t
::
msgpack
,
current
&
0x1F
,
result
);
return
get_string
(
input_format_t
::
msgpack
,
static_cast
<
unsigned
int
>
(
current
)
&
0x1Fu
,
result
);
}
}
case
0xD9
:
// str 8
case
0xD9
:
// str 8
...
...
This diff is collapsed.
Click to expand it.
include/nlohmann/detail/input/input_adapters.hpp
View file @
b02ee167
...
@@ -165,7 +165,7 @@ struct wide_string_input_helper
...
@@ -165,7 +165,7 @@ struct wide_string_input_helper
else
else
{
{
// get the current character
// get the current character
const
auto
wc
=
static_cast
<
int
>
(
str
[
current_wchar
++
]);
const
auto
wc
=
static_cast
<
unsigned
int
>
(
str
[
current_wchar
++
]);
// UTF-32 to UTF-8 encoding
// UTF-32 to UTF-8 encoding
if
(
wc
<
0x80
)
if
(
wc
<
0x80
)
...
@@ -175,23 +175,23 @@ struct wide_string_input_helper
...
@@ -175,23 +175,23 @@ struct wide_string_input_helper
}
}
else
if
(
wc
<=
0x7FF
)
else
if
(
wc
<=
0x7FF
)
{
{
utf8_bytes
[
0
]
=
0xC0
|
((
wc
>>
6
)
&
0x1F
);
utf8_bytes
[
0
]
=
0xC0
u
|
((
wc
>>
6u
)
&
0x1Fu
);
utf8_bytes
[
1
]
=
0x80
|
(
wc
&
0x3F
);
utf8_bytes
[
1
]
=
0x80
u
|
(
wc
&
0x3Fu
);
utf8_bytes_filled
=
2
;
utf8_bytes_filled
=
2
;
}
}
else
if
(
wc
<=
0xFFFF
)
else
if
(
wc
<=
0xFFFF
)
{
{
utf8_bytes
[
0
]
=
0xE0
|
((
wc
>>
12
)
&
0x0F
);
utf8_bytes
[
0
]
=
0xE0
u
|
((
wc
>>
12u
)
&
0x0Fu
);
utf8_bytes
[
1
]
=
0x80
|
((
wc
>>
6
)
&
0x3F
);
utf8_bytes
[
1
]
=
0x80
u
|
((
wc
>>
6u
)
&
0x3Fu
);
utf8_bytes
[
2
]
=
0x80
|
(
wc
&
0x3F
);
utf8_bytes
[
2
]
=
0x80
u
|
(
wc
&
0x3Fu
);
utf8_bytes_filled
=
3
;
utf8_bytes_filled
=
3
;
}
}
else
if
(
wc
<=
0x10FFFF
)
else
if
(
wc
<=
0x10FFFF
)
{
{
utf8_bytes
[
0
]
=
0xF0
|
((
wc
>>
18
)
&
0x07
);
utf8_bytes
[
0
]
=
0xF0
u
|
((
wc
>>
18u
)
&
0x07u
);
utf8_bytes
[
1
]
=
0x80
|
((
wc
>>
12
)
&
0x3F
);
utf8_bytes
[
1
]
=
0x80
u
|
((
wc
>>
12u
)
&
0x3Fu
);
utf8_bytes
[
2
]
=
0x80
|
((
wc
>>
6
)
&
0x3F
);
utf8_bytes
[
2
]
=
0x80
u
|
((
wc
>>
6u
)
&
0x3Fu
);
utf8_bytes
[
3
]
=
0x80
|
(
wc
&
0x3F
);
utf8_bytes
[
3
]
=
0x80
u
|
(
wc
&
0x3Fu
);
utf8_bytes_filled
=
4
;
utf8_bytes_filled
=
4
;
}
}
else
else
...
@@ -220,7 +220,7 @@ struct wide_string_input_helper<WideStringType, 2>
...
@@ -220,7 +220,7 @@ struct wide_string_input_helper<WideStringType, 2>
else
else
{
{
// get the current character
// get the current character
const
auto
wc
=
static_cast
<
int
>
(
str
[
current_wchar
++
]);
const
auto
wc
=
static_cast
<
unsigned
int
>
(
str
[
current_wchar
++
]);
// UTF-16 to UTF-8 encoding
// UTF-16 to UTF-8 encoding
if
(
wc
<
0x80
)
if
(
wc
<
0x80
)
...
@@ -230,27 +230,27 @@ struct wide_string_input_helper<WideStringType, 2>
...
@@ -230,27 +230,27 @@ struct wide_string_input_helper<WideStringType, 2>
}
}
else
if
(
wc
<=
0x7FF
)
else
if
(
wc
<=
0x7FF
)
{
{
utf8_bytes
[
0
]
=
0xC0
|
((
wc
>>
6
));
utf8_bytes
[
0
]
=
0xC0
u
|
((
wc
>>
6u
));
utf8_bytes
[
1
]
=
0x80
|
(
wc
&
0x3F
);
utf8_bytes
[
1
]
=
0x80
u
|
(
wc
&
0x3Fu
);
utf8_bytes_filled
=
2
;
utf8_bytes_filled
=
2
;
}
}
else
if
(
0xD800
>
wc
or
wc
>=
0xE000
)
else
if
(
0xD800
>
wc
or
wc
>=
0xE000
)
{
{
utf8_bytes
[
0
]
=
0xE0
|
((
wc
>>
12
));
utf8_bytes
[
0
]
=
0xE0
u
|
((
wc
>>
12u
));
utf8_bytes
[
1
]
=
0x80
|
((
wc
>>
6
)
&
0x3F
);
utf8_bytes
[
1
]
=
0x80
u
|
((
wc
>>
6u
)
&
0x3Fu
);
utf8_bytes
[
2
]
=
0x80
|
(
wc
&
0x3F
);
utf8_bytes
[
2
]
=
0x80
u
|
(
wc
&
0x3Fu
);
utf8_bytes_filled
=
3
;
utf8_bytes_filled
=
3
;
}
}
else
else
{
{
if
(
current_wchar
<
str
.
size
())
if
(
current_wchar
<
str
.
size
())
{
{
const
auto
wc2
=
static_cast
<
int
>
(
str
[
current_wchar
++
]);
const
auto
wc2
=
static_cast
<
unsigned
int
>
(
str
[
current_wchar
++
]);
const
int
charcode
=
0x10000
+
(((
wc
&
0x3FF
)
<<
10
)
|
(
wc2
&
0x3FF
));
const
auto
charcode
=
0x10000u
+
(((
wc
&
0x3FFu
)
<<
10u
)
|
(
wc2
&
0x3FFu
));
utf8_bytes
[
0
]
=
0x
f0
|
(
charcode
>>
18
);
utf8_bytes
[
0
]
=
0x
F0u
|
(
charcode
>>
18u
);
utf8_bytes
[
1
]
=
0x80
|
((
charcode
>>
12
)
&
0x3F
);
utf8_bytes
[
1
]
=
0x80
u
|
((
charcode
>>
12u
)
&
0x3Fu
);
utf8_bytes
[
2
]
=
0x80
|
((
charcode
>>
6
)
&
0x3F
);
utf8_bytes
[
2
]
=
0x80
u
|
((
charcode
>>
6u
)
&
0x3Fu
);
utf8_bytes
[
3
]
=
0x80
|
(
charcode
&
0x3F
);
utf8_bytes
[
3
]
=
0x80
u
|
(
charcode
&
0x3Fu
);
utf8_bytes_filled
=
4
;
utf8_bytes_filled
=
4
;
}
}
else
else
...
...
This diff is collapsed.
Click to expand it.
include/nlohmann/detail/input/lexer.hpp
View file @
b02ee167
...
@@ -149,22 +149,22 @@ class lexer
...
@@ -149,22 +149,22 @@ class lexer
assert
(
current
==
'u'
);
assert
(
current
==
'u'
);
int
codepoint
=
0
;
int
codepoint
=
0
;
const
auto
factors
=
{
12
,
8
,
4
,
0
};
const
auto
factors
=
{
12
u
,
8u
,
4u
,
0u
};
for
(
const
auto
factor
:
factors
)
for
(
const
auto
factor
:
factors
)
{
{
get
();
get
();
if
(
current
>=
'0'
and
current
<=
'9'
)
if
(
current
>=
'0'
and
current
<=
'9'
)
{
{
codepoint
+=
((
current
-
0x30
)
<<
factor
);
codepoint
+=
((
static_cast
<
unsigned
int
>
(
current
)
-
0x30u
)
<<
factor
);
}
}
else
if
(
current
>=
'A'
and
current
<=
'F'
)
else
if
(
current
>=
'A'
and
current
<=
'F'
)
{
{
codepoint
+=
((
current
-
0x37
)
<<
factor
);
codepoint
+=
((
static_cast
<
unsigned
int
>
(
current
)
-
0x37u
)
<<
factor
);
}
}
else
if
(
current
>=
'a'
and
current
<=
'f'
)
else
if
(
current
>=
'a'
and
current
<=
'f'
)
{
{
codepoint
+=
((
current
-
0x57
)
<<
factor
);
codepoint
+=
((
static_cast
<
unsigned
int
>
(
current
)
-
0x57u
)
<<
factor
);
}
}
else
else
{
{
...
@@ -324,13 +324,13 @@ class lexer
...
@@ -324,13 +324,13 @@ class lexer
// overwrite codepoint
// overwrite codepoint
codepoint
=
codepoint
=
// high surrogate occupies the most significant 22 bits
// high surrogate occupies the most significant 22 bits
(
codepoint1
<<
10
)
(
static_cast
<
unsigned
int
>
(
codepoint1
)
<<
10u
)
// low surrogate occupies the least significant 15 bits
// low surrogate occupies the least significant 15 bits
+
codepoint2
+
static_cast
<
unsigned
int
>
(
codepoint2
)
// there is still the 0xD800, 0xDC00 and 0x10000 noise
// there is still the 0xD800, 0xDC00 and 0x10000 noise
// in the result so we have to subtract with:
// in the result so we have to subtract with:
// (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
// (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
-
0x35FDC00
;
-
0x35FDC00
u
;
}
}
else
else
{
{
...
@@ -365,23 +365,23 @@ class lexer
...
@@ -365,23 +365,23 @@ class lexer
else
if
(
codepoint
<=
0x7FF
)
else
if
(
codepoint
<=
0x7FF
)
{
{
// 2-byte characters: 110xxxxx 10xxxxxx
// 2-byte characters: 110xxxxx 10xxxxxx
add
(
0xC0
|
(
codepoint
>>
6
));
add
(
0xC0
u
|
(
static_cast
<
unsigned
int
>
(
codepoint
)
>>
6u
));
add
(
0x80
|
(
codepoint
&
0x3F
));
add
(
0x80
u
|
(
static_cast
<
unsigned
int
>
(
codepoint
)
&
0x3Fu
));
}
}
else
if
(
codepoint
<=
0xFFFF
)
else
if
(
codepoint
<=
0xFFFF
)
{
{
// 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
// 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
add
(
0xE0
|
(
codepoint
>>
12
));
add
(
0xE0
u
|
(
static_cast
<
unsigned
int
>
(
codepoint
)
>>
12u
));
add
(
0x80
|
((
codepoint
>>
6
)
&
0x3F
));
add
(
0x80
u
|
((
static_cast
<
unsigned
int
>
(
codepoint
)
>>
6u
)
&
0x3Fu
));
add
(
0x80
|
(
codepoint
&
0x3F
));
add
(
0x80
u
|
(
static_cast
<
unsigned
int
>
(
codepoint
)
&
0x3Fu
));
}
}
else
else
{
{
// 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
// 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
add
(
0xF0
|
(
codepoint
>>
18
));
add
(
0xF0
u
|
(
static_cast
<
unsigned
int
>
(
codepoint
)
>>
18u
));
add
(
0x80
|
((
codepoint
>>
12
)
&
0x3F
));
add
(
0x80
u
|
((
static_cast
<
unsigned
int
>
(
codepoint
)
>>
12u
)
&
0x3Fu
));
add
(
0x80
|
((
codepoint
>>
6
)
&
0x3F
));
add
(
0x80
u
|
((
static_cast
<
unsigned
int
>
(
codepoint
)
>>
6u
)
&
0x3Fu
));
add
(
0x80
|
(
codepoint
&
0x3F
));
add
(
0x80
u
|
(
static_cast
<
unsigned
int
>
(
codepoint
)
&
0x3Fu
));
}
}
break
;
break
;
...
@@ -1298,7 +1298,7 @@ scan_number_done:
...
@@ -1298,7 +1298,7 @@ scan_number_done:
if
(
JSON_LIKELY
(
current
!=
std
::
char_traits
<
char
>::
eof
()))
if
(
JSON_LIKELY
(
current
!=
std
::
char_traits
<
char
>::
eof
()))
{
{
assert
(
token_string
.
size
()
!=
0
);
assert
(
not
token_string
.
empty
()
);
token_string
.
pop_back
();
token_string
.
pop_back
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
include/nlohmann/detail/json_ref.hpp
View file @
b02ee167
...
@@ -35,7 +35,7 @@ class json_ref
...
@@ -35,7 +35,7 @@ class json_ref
is_rvalue
(
true
)
{}
is_rvalue
(
true
)
{}
// class should be movable only
// class should be movable only
json_ref
(
json_ref
&&
)
=
default
;
json_ref
(
json_ref
&&
)
noexcept
=
default
;
json_ref
(
const
json_ref
&
)
=
delete
;
json_ref
(
const
json_ref
&
)
=
delete
;
json_ref
&
operator
=
(
const
json_ref
&
)
=
delete
;
json_ref
&
operator
=
(
const
json_ref
&
)
=
delete
;
json_ref
&
operator
=
(
json_ref
&&
)
=
delete
;
json_ref
&
operator
=
(
json_ref
&&
)
=
delete
;
...
...
This diff is collapsed.
Click to expand it.
single_include/nlohmann/json.hpp
View file @
b02ee167
...
@@ -2337,7 +2337,7 @@ struct wide_string_input_helper
...
@@ -2337,7 +2337,7 @@ struct wide_string_input_helper
else
else
{
{
// get the current character
// get the current character
const
auto
wc
=
static_cast
<
int
>
(
str
[
current_wchar
++
]);
const
auto
wc
=
static_cast
<
unsigned
int
>
(
str
[
current_wchar
++
]);
// UTF-32 to UTF-8 encoding
// UTF-32 to UTF-8 encoding
if
(
wc
<
0x80
)
if
(
wc
<
0x80
)
...
@@ -2347,23 +2347,23 @@ struct wide_string_input_helper
...
@@ -2347,23 +2347,23 @@ struct wide_string_input_helper
}
}
else
if
(
wc
<=
0x7FF
)
else
if
(
wc
<=
0x7FF
)
{
{
utf8_bytes
[
0
]
=
0xC0
|
((
wc
>>
6
)
&
0x1F
);
utf8_bytes
[
0
]
=
0xC0
u
|
((
wc
>>
6u
)
&
0x1Fu
);
utf8_bytes
[
1
]
=
0x80
|
(
wc
&
0x3F
);
utf8_bytes
[
1
]
=
0x80
u
|
(
wc
&
0x3Fu
);
utf8_bytes_filled
=
2
;
utf8_bytes_filled
=
2
;
}
}
else
if
(
wc
<=
0xFFFF
)
else
if
(
wc
<=
0xFFFF
)
{
{
utf8_bytes
[
0
]
=
0xE0
|
((
wc
>>
12
)
&
0x0F
);
utf8_bytes
[
0
]
=
0xE0
u
|
((
wc
>>
12u
)
&
0x0Fu
);
utf8_bytes
[
1
]
=
0x80
|
((
wc
>>
6
)
&
0x3F
);
utf8_bytes
[
1
]
=
0x80
u
|
((
wc
>>
6u
)
&
0x3Fu
);
utf8_bytes
[
2
]
=
0x80
|
(
wc
&
0x3F
);
utf8_bytes
[
2
]
=
0x80
u
|
(
wc
&
0x3Fu
);
utf8_bytes_filled
=
3
;
utf8_bytes_filled
=
3
;
}
}
else
if
(
wc
<=
0x10FFFF
)
else
if
(
wc
<=
0x10FFFF
)
{
{
utf8_bytes
[
0
]
=
0xF0
|
((
wc
>>
18
)
&
0x07
);
utf8_bytes
[
0
]
=
0xF0
u
|
((
wc
>>
18u
)
&
0x07u
);
utf8_bytes
[
1
]
=
0x80
|
((
wc
>>
12
)
&
0x3F
);
utf8_bytes
[
1
]
=
0x80
u
|
((
wc
>>
12u
)
&
0x3Fu
);
utf8_bytes
[
2
]
=
0x80
|
((
wc
>>
6
)
&
0x3F
);
utf8_bytes
[
2
]
=
0x80
u
|
((
wc
>>
6u
)
&
0x3Fu
);
utf8_bytes
[
3
]
=
0x80
|
(
wc
&
0x3F
);
utf8_bytes
[
3
]
=
0x80
u
|
(
wc
&
0x3Fu
);
utf8_bytes_filled
=
4
;
utf8_bytes_filled
=
4
;
}
}
else
else
...
@@ -2392,7 +2392,7 @@ struct wide_string_input_helper<WideStringType, 2>
...
@@ -2392,7 +2392,7 @@ struct wide_string_input_helper<WideStringType, 2>
else
else
{
{
// get the current character
// get the current character
const
auto
wc
=
static_cast
<
int
>
(
str
[
current_wchar
++
]);
const
auto
wc
=
static_cast
<
unsigned
int
>
(
str
[
current_wchar
++
]);
// UTF-16 to UTF-8 encoding
// UTF-16 to UTF-8 encoding
if
(
wc
<
0x80
)
if
(
wc
<
0x80
)
...
@@ -2402,27 +2402,27 @@ struct wide_string_input_helper<WideStringType, 2>
...
@@ -2402,27 +2402,27 @@ struct wide_string_input_helper<WideStringType, 2>
}
}
else
if
(
wc
<=
0x7FF
)
else
if
(
wc
<=
0x7FF
)
{
{
utf8_bytes
[
0
]
=
0xC0
|
((
wc
>>
6
));
utf8_bytes
[
0
]
=
0xC0
u
|
((
wc
>>
6u
));
utf8_bytes
[
1
]
=
0x80
|
(
wc
&
0x3F
);
utf8_bytes
[
1
]
=
0x80
u
|
(
wc
&
0x3Fu
);
utf8_bytes_filled
=
2
;
utf8_bytes_filled
=
2
;
}
}
else
if
(
0xD800
>
wc
or
wc
>=
0xE000
)
else
if
(
0xD800
>
wc
or
wc
>=
0xE000
)
{
{
utf8_bytes
[
0
]
=
0xE0
|
((
wc
>>
12
));
utf8_bytes
[
0
]
=
0xE0
u
|
((
wc
>>
12u
));
utf8_bytes
[
1
]
=
0x80
|
((
wc
>>
6
)
&
0x3F
);
utf8_bytes
[
1
]
=
0x80
u
|
((
wc
>>
6u
)
&
0x3Fu
);
utf8_bytes
[
2
]
=
0x80
|
(
wc
&
0x3F
);
utf8_bytes
[
2
]
=
0x80
u
|
(
wc
&
0x3Fu
);
utf8_bytes_filled
=
3
;
utf8_bytes_filled
=
3
;
}
}
else
else
{
{
if
(
current_wchar
<
str
.
size
())
if
(
current_wchar
<
str
.
size
())
{
{
const
auto
wc2
=
static_cast
<
int
>
(
str
[
current_wchar
++
]);
const
auto
wc2
=
static_cast
<
unsigned
int
>
(
str
[
current_wchar
++
]);
const
int
charcode
=
0x10000
+
(((
wc
&
0x3FF
)
<<
10
)
|
(
wc2
&
0x3FF
));
const
auto
charcode
=
0x10000u
+
(((
wc
&
0x3FFu
)
<<
10u
)
|
(
wc2
&
0x3FFu
));
utf8_bytes
[
0
]
=
0x
f0
|
(
charcode
>>
18
);
utf8_bytes
[
0
]
=
0x
F0u
|
(
charcode
>>
18u
);
utf8_bytes
[
1
]
=
0x80
|
((
charcode
>>
12
)
&
0x3F
);
utf8_bytes
[
1
]
=
0x80
u
|
((
charcode
>>
12u
)
&
0x3Fu
);
utf8_bytes
[
2
]
=
0x80
|
((
charcode
>>
6
)
&
0x3F
);
utf8_bytes
[
2
]
=
0x80
u
|
((
charcode
>>
6u
)
&
0x3Fu
);
utf8_bytes
[
3
]
=
0x80
|
(
charcode
&
0x3F
);
utf8_bytes
[
3
]
=
0x80
u
|
(
charcode
&
0x3Fu
);
utf8_bytes_filled
=
4
;
utf8_bytes_filled
=
4
;
}
}
else
else
...
@@ -2748,22 +2748,22 @@ class lexer
...
@@ -2748,22 +2748,22 @@ class lexer
assert
(
current
==
'u'
);
assert
(
current
==
'u'
);
int
codepoint
=
0
;
int
codepoint
=
0
;
const
auto
factors
=
{
12
,
8
,
4
,
0
};
const
auto
factors
=
{
12
u
,
8u
,
4u
,
0u
};
for
(
const
auto
factor
:
factors
)
for
(
const
auto
factor
:
factors
)
{
{
get
();
get
();
if
(
current
>=
'0'
and
current
<=
'9'
)
if
(
current
>=
'0'
and
current
<=
'9'
)
{
{
codepoint
+=
((
current
-
0x30
)
<<
factor
);
codepoint
+=
((
static_cast
<
unsigned
int
>
(
current
)
-
0x30u
)
<<
factor
);
}
}
else
if
(
current
>=
'A'
and
current
<=
'F'
)
else
if
(
current
>=
'A'
and
current
<=
'F'
)
{
{
codepoint
+=
((
current
-
0x37
)
<<
factor
);
codepoint
+=
((
static_cast
<
unsigned
int
>
(
current
)
-
0x37u
)
<<
factor
);
}
}
else
if
(
current
>=
'a'
and
current
<=
'f'
)
else
if
(
current
>=
'a'
and
current
<=
'f'
)
{
{
codepoint
+=
((
current
-
0x57
)
<<
factor
);
codepoint
+=
((
static_cast
<
unsigned
int
>
(
current
)
-
0x57u
)
<<
factor
);
}
}
else
else
{
{
...
@@ -2923,13 +2923,13 @@ class lexer
...
@@ -2923,13 +2923,13 @@ class lexer
// overwrite codepoint
// overwrite codepoint
codepoint
=
codepoint
=
// high surrogate occupies the most significant 22 bits
// high surrogate occupies the most significant 22 bits
(
codepoint1
<<
10
)
(
static_cast
<
unsigned
int
>
(
codepoint1
)
<<
10u
)
// low surrogate occupies the least significant 15 bits
// low surrogate occupies the least significant 15 bits
+
codepoint2
+
static_cast
<
unsigned
int
>
(
codepoint2
)
// there is still the 0xD800, 0xDC00 and 0x10000 noise
// there is still the 0xD800, 0xDC00 and 0x10000 noise
// in the result so we have to subtract with:
// in the result so we have to subtract with:
// (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
// (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
-
0x35FDC00
;
-
0x35FDC00
u
;
}
}
else
else
{
{
...
@@ -2964,23 +2964,23 @@ class lexer
...
@@ -2964,23 +2964,23 @@ class lexer
else
if
(
codepoint
<=
0x7FF
)
else
if
(
codepoint
<=
0x7FF
)
{
{
// 2-byte characters: 110xxxxx 10xxxxxx
// 2-byte characters: 110xxxxx 10xxxxxx
add
(
0xC0
|
(
codepoint
>>
6
));
add
(
0xC0
u
|
(
static_cast
<
unsigned
int
>
(
codepoint
)
>>
6u
));
add
(
0x80
|
(
codepoint
&
0x3F
));
add
(
0x80
u
|
(
static_cast
<
unsigned
int
>
(
codepoint
)
&
0x3Fu
));
}
}
else
if
(
codepoint
<=
0xFFFF
)
else
if
(
codepoint
<=
0xFFFF
)
{
{
// 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
// 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
add
(
0xE0
|
(
codepoint
>>
12
));
add
(
0xE0
u
|
(
static_cast
<
unsigned
int
>
(
codepoint
)
>>
12u
));
add
(
0x80
|
((
codepoint
>>
6
)
&
0x3F
));
add
(
0x80
u
|
((
static_cast
<
unsigned
int
>
(
codepoint
)
>>
6u
)
&
0x3Fu
));
add
(
0x80
|
(
codepoint
&
0x3F
));
add
(
0x80
u
|
(
static_cast
<
unsigned
int
>
(
codepoint
)
&
0x3Fu
));
}
}
else
else
{
{
// 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
// 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
add
(
0xF0
|
(
codepoint
>>
18
));
add
(
0xF0
u
|
(
static_cast
<
unsigned
int
>
(
codepoint
)
>>
18u
));
add
(
0x80
|
((
codepoint
>>
12
)
&
0x3F
));
add
(
0x80
u
|
((
static_cast
<
unsigned
int
>
(
codepoint
)
>>
12u
)
&
0x3Fu
));
add
(
0x80
|
((
codepoint
>>
6
)
&
0x3F
));
add
(
0x80
u
|
((
static_cast
<
unsigned
int
>
(
codepoint
)
>>
6u
)
&
0x3Fu
));
add
(
0x80
|
(
codepoint
&
0x3F
));
add
(
0x80
u
|
(
static_cast
<
unsigned
int
>
(
codepoint
)
&
0x3Fu
));
}
}
break
;
break
;
...
@@ -3897,7 +3897,7 @@ scan_number_done:
...
@@ -3897,7 +3897,7 @@ scan_number_done:
if
(
JSON_LIKELY
(
current
!=
std
::
char_traits
<
char
>::
eof
()))
if
(
JSON_LIKELY
(
current
!=
std
::
char_traits
<
char
>::
eof
()))
{
{
assert
(
token_string
.
size
()
!=
0
);
assert
(
not
token_string
.
empty
()
);
token_string
.
pop_back
();
token_string
.
pop_back
();
}
}
}
}
...
@@ -7014,7 +7014,7 @@ class binary_reader
...
@@ -7014,7 +7014,7 @@ class binary_reader
case
0x95
:
case
0x95
:
case
0x96
:
case
0x96
:
case
0x97
:
case
0x97
:
return
get_cbor_array
(
static_cast
<
std
::
size_t
>
(
current
&
0x1F
));
return
get_cbor_array
(
static_cast
<
std
::
size_t
>
(
static_cast
<
unsigned
int
>
(
current
)
&
0x1Fu
));
case
0x98
:
// array (one-byte uint8_t for n follows)
case
0x98
:
// array (one-byte uint8_t for n follows)
{
{
...
@@ -7068,7 +7068,7 @@ class binary_reader
...
@@ -7068,7 +7068,7 @@ class binary_reader
case
0xB5
:
case
0xB5
:
case
0xB6
:
case
0xB6
:
case
0xB7
:
case
0xB7
:
return
get_cbor_object
(
static_cast
<
std
::
size_t
>
(
current
&
0x1F
));
return
get_cbor_object
(
static_cast
<
std
::
size_t
>
(
static_cast
<
unsigned
int
>
(
current
)
&
0x1Fu
));
case
0xB8
:
// map (one-byte uint8_t for n follows)
case
0xB8
:
// map (one-byte uint8_t for n follows)
{
{
...
@@ -7130,11 +7130,11 @@ class binary_reader
...
@@ -7130,11 +7130,11 @@ class binary_reader
// without such support. An example of a small decoder for
// without such support. An example of a small decoder for
// half-precision floating-point numbers in the C language
// half-precision floating-point numbers in the C language
// is shown in Fig. 3.
// is shown in Fig. 3.
const
int
half
=
(
byte1
<<
8
)
+
byte2
;
const
unsigned
int
half
=
(
byte1
<<
8u
)
+
byte2
;
const
double
val
=
[
&
half
]
const
double
val
=
[
&
half
]
{
{
const
int
exp
=
(
half
>>
10
)
&
0x1F
;
const
unsigned
int
exp
=
(
half
>>
10u
)
&
0x1Fu
;
const
int
mant
=
half
&
0x3FF
;
const
unsigned
int
mant
=
half
&
0x3FFu
;
assert
(
0
<=
exp
and
exp
<=
32
);
assert
(
0
<=
exp
and
exp
<=
32
);
assert
(
0
<=
mant
and
mant
<=
1024
);
assert
(
0
<=
mant
and
mant
<=
1024
);
switch
(
exp
)
switch
(
exp
)
...
@@ -7149,7 +7149,7 @@ class binary_reader
...
@@ -7149,7 +7149,7 @@ class binary_reader
return
std
::
ldexp
(
mant
+
1024
,
exp
-
25
);
return
std
::
ldexp
(
mant
+
1024
,
exp
-
25
);
}
}
}();
}();
return
sax
->
number_float
((
half
&
0x8000
)
!=
0
return
sax
->
number_float
((
half
&
0x8000
u
)
!=
0
?
static_cast
<
number_float_t
>
(
-
val
)
?
static_cast
<
number_float_t
>
(
-
val
)
:
static_cast
<
number_float_t
>
(
val
),
""
);
:
static_cast
<
number_float_t
>
(
val
),
""
);
}
}
...
@@ -7220,7 +7220,7 @@ class binary_reader
...
@@ -7220,7 +7220,7 @@ class binary_reader
case
0x76
:
case
0x76
:
case
0x77
:
case
0x77
:
{
{
return
get_string
(
input_format_t
::
cbor
,
current
&
0x1F
,
result
);
return
get_string
(
input_format_t
::
cbor
,
static_cast
<
unsigned
int
>
(
current
)
&
0x1Fu
,
result
);
}
}
case
0x78
:
// UTF-8 string (one-byte uint8_t for n follows)
case
0x78
:
// UTF-8 string (one-byte uint8_t for n follows)
...
@@ -7518,7 +7518,7 @@ class binary_reader
...
@@ -7518,7 +7518,7 @@ class binary_reader
case
0x8D
:
case
0x8D
:
case
0x8E
:
case
0x8E
:
case
0x8F
:
case
0x8F
:
return
get_msgpack_object
(
static_cast
<
std
::
size_t
>
(
current
&
0x0F
));
return
get_msgpack_object
(
static_cast
<
std
::
size_t
>
(
static_cast
<
unsigned
int
>
(
current
)
&
0x0Fu
));
// fixarray
// fixarray
case
0x90
:
case
0x90
:
...
@@ -7537,7 +7537,7 @@ class binary_reader
...
@@ -7537,7 +7537,7 @@ class binary_reader
case
0x9D
:
case
0x9D
:
case
0x9E
:
case
0x9E
:
case
0x9F
:
case
0x9F
:
return
get_msgpack_array
(
static_cast
<
std
::
size_t
>
(
current
&
0x0F
));
return
get_msgpack_array
(
static_cast
<
std
::
size_t
>
(
static_cast
<
unsigned
int
>
(
current
)
&
0x0Fu
));
// fixstr
// fixstr
case
0xA0
:
case
0xA0
:
...
@@ -7774,7 +7774,7 @@ class binary_reader
...
@@ -7774,7 +7774,7 @@ class binary_reader
case
0xBE
:
case
0xBE
:
case
0xBF
:
case
0xBF
:
{
{
return
get_string
(
input_format_t
::
msgpack
,
current
&
0x1F
,
result
);
return
get_string
(
input_format_t
::
msgpack
,
static_cast
<
unsigned
int
>
(
current
)
&
0x1Fu
,
result
);
}
}
case
0xD9
:
// str 8
case
0xD9
:
// str 8
...
@@ -11794,7 +11794,7 @@ class json_ref
...
@@ -11794,7 +11794,7 @@ class json_ref
is_rvalue
(
true
)
{}
is_rvalue
(
true
)
{}
// class should be movable only
// class should be movable only
json_ref
(
json_ref
&&
)
=
default
;
json_ref
(
json_ref
&&
)
noexcept
=
default
;
json_ref
(
const
json_ref
&
)
=
delete
;
json_ref
(
const
json_ref
&
)
=
delete
;
json_ref
&
operator
=
(
const
json_ref
&
)
=
delete
;
json_ref
&
operator
=
(
const
json_ref
&
)
=
delete
;
json_ref
&
operator
=
(
json_ref
&&
)
=
delete
;
json_ref
&
operator
=
(
json_ref
&&
)
=
delete
;
...
...
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