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
e830bc50
Unverified
Commit
e830bc50
authored
Jun 01, 2018
by
Niels Lohmann
Committed by
GitHub
Jun 01, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1117 from TinyTinni/develop
remove stringstream dependency
parents
8efbf8d7
ecadcdb5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
22 deletions
+14
-22
include/nlohmann/detail/input/binary_reader.hpp
include/nlohmann/detail/input/binary_reader.hpp
+4
-6
include/nlohmann/detail/input/lexer.hpp
include/nlohmann/detail/input/lexer.hpp
+4
-7
include/nlohmann/detail/output/serializer.hpp
include/nlohmann/detail/output/serializer.hpp
+6
-9
No files found.
include/nlohmann/detail/input/binary_reader.hpp
View file @
e830bc50
...
@@ -6,12 +6,10 @@
...
@@ -6,12 +6,10 @@
#include <cmath> // ldexp
#include <cmath> // ldexp
#include <cstddef> // size_t
#include <cstddef> // size_t
#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
#include <cstdio> // snprintf
#include <cstring> // memcpy
#include <cstring> // memcpy
#include <iomanip> // setw, setfill
#include <ios> // hex
#include <iterator> // back_inserter
#include <iterator> // back_inserter
#include <limits> // numeric_limits
#include <limits> // numeric_limits
#include <sstream> // stringstream
#include <string> // char_traits, string
#include <string> // char_traits, string
#include <utility> // make_pair, move
#include <utility> // make_pair, move
...
@@ -1665,9 +1663,9 @@ class binary_reader
...
@@ -1665,9 +1663,9 @@ class binary_reader
*/
*/
std
::
string
get_token_string
()
const
std
::
string
get_token_string
()
const
{
{
std
::
stringstream
ss
;
char
cr
[
3
]
;
s
s
<<
std
::
setw
(
2
)
<<
std
::
uppercase
<<
std
::
setfill
(
'0'
)
<<
std
::
hex
<<
current
;
s
nprintf
(
cr
,
3
,
"%.2X"
,
current
)
;
return
s
s
.
str
()
;
return
s
td
::
string
{
cr
}
;
}
}
private:
private:
...
...
include/nlohmann/detail/input/lexer.hpp
View file @
e830bc50
...
@@ -3,10 +3,8 @@
...
@@ -3,10 +3,8 @@
#include <clocale> // localeconv
#include <clocale> // localeconv
#include <cstddef> // size_t
#include <cstddef> // size_t
#include <cstdlib> // strtof, strtod, strtold, strtoll, strtoull
#include <cstdlib> // strtof, strtod, strtold, strtoll, strtoull
#include <cstdio> // snprintf
#include <initializer_list> // initializer_list
#include <initializer_list> // initializer_list
#include <ios> // hex, uppercase
#include <iomanip> // setw, setfill
#include <sstream> // stringstream
#include <string> // char_traits, string
#include <string> // char_traits, string
#include <vector> // vector
#include <vector> // vector
...
@@ -1174,10 +1172,9 @@ scan_number_done:
...
@@ -1174,10 +1172,9 @@ scan_number_done:
if
(
'\x00'
<=
c
and
c
<=
'\x1F'
)
if
(
'\x00'
<=
c
and
c
<=
'\x1F'
)
{
{
// escape control characters
// escape control characters
std
::
stringstream
ss
;
char
cs
[
9
];
ss
<<
"<U+"
<<
std
::
setw
(
4
)
<<
std
::
uppercase
<<
std
::
setfill
(
'0'
)
snprintf
(
cs
,
9
,
"<U+%.4X>"
,
c
);
<<
std
::
hex
<<
static_cast
<
int
>
(
c
)
<<
">"
;
result
+=
cs
;
result
+=
ss
.
str
();
}
}
else
else
{
{
...
...
include/nlohmann/detail/output/serializer.hpp
View file @
e830bc50
...
@@ -9,11 +9,8 @@
...
@@ -9,11 +9,8 @@
#include <cstddef> // size_t, ptrdiff_t
#include <cstddef> // size_t, ptrdiff_t
#include <cstdint> // uint8_t
#include <cstdint> // uint8_t
#include <cstdio> // snprintf
#include <cstdio> // snprintf
#include <iomanip> // setfill
#include <iterator> // next
#include <limits> // numeric_limits
#include <limits> // numeric_limits
#include <string> // string
#include <string> // string
#include <sstream> // stringstream
#include <type_traits> // is_same
#include <type_traits> // is_same
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/exceptions.hpp>
...
@@ -389,9 +386,9 @@ class serializer
...
@@ -389,9 +386,9 @@ class serializer
case
UTF8_REJECT
:
// decode found invalid UTF-8 byte
case
UTF8_REJECT
:
// decode found invalid UTF-8 byte
{
{
std
::
string
stream
ss
;
std
::
string
sn
(
3
,
'\0'
)
;
s
s
<<
std
::
setw
(
2
)
<<
std
::
uppercase
<<
std
::
setfill
(
'0'
)
<<
std
::
hex
<<
static_cast
<
int
>
(
byte
);
s
nprintf
(
&
sn
[
0
],
sn
.
size
(),
"%.2X"
,
byte
);
JSON_THROW
(
type_error
::
create
(
316
,
"invalid UTF-8 byte at index "
+
std
::
to_string
(
i
)
+
": 0x"
+
s
s
.
str
()
));
JSON_THROW
(
type_error
::
create
(
316
,
"invalid UTF-8 byte at index "
+
std
::
to_string
(
i
)
+
": 0x"
+
s
n
));
}
}
default:
// decode found yet incomplete multi-byte code point
default:
// decode found yet incomplete multi-byte code point
...
@@ -417,9 +414,9 @@ class serializer
...
@@ -417,9 +414,9 @@ class serializer
else
else
{
{
// we finish reading, but do not accept: string was incomplete
// we finish reading, but do not accept: string was incomplete
std
::
string
stream
ss
;
std
::
string
sn
(
3
,
'\0'
)
;
s
s
<<
std
::
setw
(
2
)
<<
std
::
uppercase
<<
std
::
setfill
(
'0'
)
<<
std
::
hex
<<
static_cast
<
int
>
(
static_cast
<
uint8_t
>
(
s
.
back
()));
s
nprintf
(
&
sn
[
0
],
sn
.
size
(),
"%.2X"
,
static_cast
<
uint8_t
>
(
s
.
back
()));
JSON_THROW
(
type_error
::
create
(
316
,
"incomplete UTF-8 string; last byte: 0x"
+
s
s
.
str
()
));
JSON_THROW
(
type_error
::
create
(
316
,
"incomplete UTF-8 string; last byte: 0x"
+
s
n
));
}
}
}
}
...
...
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