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
2c325932
Commit
2c325932
authored
Aug 04, 2015
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addressed locale-issues #107
parent
c9108533
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
json.hpp
src/json.hpp
+9
-8
json.hpp.re2c
src/json.hpp.re2c
+9
-8
No files found.
src/json.hpp
View file @
2c325932
...
...
@@ -49,6 +49,7 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation.
#include <iostream>
#include <iterator>
#include <limits>
#include <locale>
#include <map>
#include <memory>
#include <sstream>
...
...
@@ -6932,18 +6933,18 @@ basic_json_parser_59:
read past the current token. The latter case needs to be treated by the
caller function.
@note This function is locale-independent, see
http://stackoverflow.com/a/1333899/266378
@throw std::range_error if passed value is out of range
*/
long
double
get_number
()
const
{
// conversion
typename
string_t
::
value_type
*
endptr
;
const
auto
float_val
=
std
::
strtold
(
reinterpret_cast
<
typename
string_t
::
const_pointer
>
(
m_start
),
&
endptr
);
// return float_val if the whole number was translated and NAN
// otherwise
return
(
reinterpret_cast
<
lexer_char_t
*>
(
endptr
)
==
m_cursor
)
?
float_val
:
NAN
;
long
double
f
=
NAN
;
std
::
stringstream
ss
(
get_token
());
ss
.
imbue
(
std
::
locale
(
"C"
));
ss
>>
f
;
return
f
;
}
private
:
...
...
src/json.hpp.re2c
View file @
2c325932
...
...
@@ -49,6 +49,7 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation.
#include <iostream>
#include <iterator>
#include <limits>
#include <locale>
#include <map>
#include <memory>
#include <sstream>
...
...
@@ -6238,18 +6239,18 @@ class basic_json
read past the current token. The latter case needs to be treated by the
caller function.
@note This function is locale-independent, see
http://stackoverflow.com/a/1333899/266378
@throw std::range_error if passed value is out of range
*/
long double get_number() const
{
// conversion
typename string_t::value_type* endptr;
const auto float_val = std::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start),
&endptr);
// return float_val if the whole number was translated and NAN
// otherwise
return (reinterpret_cast<lexer_char_t*>(endptr) == m_cursor) ? float_val : NAN;
long double f = NAN;
std::stringstream ss(get_token());
ss.imbue(std::locale("C"));
ss >> f;
return f;
}
private:
...
...
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