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