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
266399d8
Commit
266399d8
authored
Jun 04, 2015
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed MinGW compilation (#81 and #80)
parent
5f4fd0b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
8 deletions
+22
-8
src/json.hpp
src/json.hpp
+11
-4
src/json.hpp.re2c
src/json.hpp.re2c
+11
-4
No files found.
src/json.hpp
View file @
266399d8
...
...
@@ -29,6 +29,13 @@
#include <utility>
#include <vector>
// enable ssize_t on MinGW
#ifdef __GNUC__
#ifdef __MINGW32__
#include <sys/types.h>
#endif
#endif
/*!
@brief namespace for Niels Lohmann
@see https://github.com/nlohmann
...
...
@@ -2159,8 +2166,7 @@ class basic_json
recursively. Note that
- strings and object keys are escaped using escape_string()
- integer numbers are converted to a string before output using
std::to_string()
- integer numbers are converted implictly via operator<<
- floating-point numbers are converted to a string using "%g" format
@param o stream to write to
...
...
@@ -2278,9 +2284,10 @@ class basic_json
{
// 15 digits of precision allows round-trip IEEE 754
// string->double->string
const
auto
sz
=
static_cast
<
unsigned
int
>
(
std
::
snprintf
(
nullptr
,
0
,
"%.15g"
,
m_value
.
number_float
));
using
std
::
snprintf
;
const
auto
sz
=
static_cast
<
unsigned
int
>
(
snprintf
(
nullptr
,
0
,
"%.15g"
,
m_value
.
number_float
));
std
::
vector
<
typename
string_t
::
value_type
>
buf
(
sz
+
1
);
s
td
::
s
nprintf
(
&
buf
[
0
],
buf
.
size
(),
"%.15g"
,
m_value
.
number_float
);
snprintf
(
&
buf
[
0
],
buf
.
size
(),
"%.15g"
,
m_value
.
number_float
);
o
<<
buf
.
data
();
return
;
}
...
...
src/json.hpp.re2c
View file @
266399d8
...
...
@@ -29,6 +29,13 @@
#include <utility>
#include <vector>
// enable ssize_t on MinGW
#ifdef __GNUC__
#ifdef __MINGW32__
#include <sys/types.h>
#endif
#endif
/*!
@brief namespace for Niels Lohmann
@see https://github.com/nlohmann
...
...
@@ -2159,8 +2166,7 @@ class basic_json
recursively. Note that
- strings and object keys are escaped using escape_string()
- integer numbers are converted to a string before output using
std::to_string()
- integer numbers are converted implictly via operator<<
- floating-point numbers are converted to a string using "%g" format
@param o stream to write to
...
...
@@ -2278,9 +2284,10 @@ class basic_json
{
// 15 digits of precision allows round-trip IEEE 754
// string->double->string
const auto sz = static_cast<unsigned int>(std::snprintf(nullptr, 0, "%.15g", m_value.number_float));
using std::snprintf;
const auto sz = static_cast<unsigned int>(snprintf(nullptr, 0, "%.15g", m_value.number_float));
std::vector<typename string_t::value_type> buf(sz + 1);
s
td::s
nprintf(&buf[0], buf.size(), "%.15g", m_value.number_float);
snprintf(&buf[0], buf.size(), "%.15g", m_value.number_float);
o << buf.data();
return;
}
...
...
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