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
c7282d5b
Commit
c7282d5b
authored
Feb 20, 2020
by
Francois Chabot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simpler endian detection for older gcc versions
parent
770ae6e9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
26 deletions
+30
-26
binary_reader.hpp
include/nlohmann/detail/input/binary_reader.hpp
+14
-12
binary_writer.hpp
include/nlohmann/detail/output/binary_writer.hpp
+1
-1
json.hpp
single_include/nlohmann/json.hpp
+15
-13
No files found.
include/nlohmann/detail/input/binary_reader.hpp
View file @
c7282d5b
...
@@ -24,6 +24,20 @@ namespace nlohmann
...
@@ -24,6 +24,20 @@ namespace nlohmann
{
{
namespace
detail
namespace
detail
{
{
/*!
@brief determine system byte order
@return true if and only if system's byte order is little endian
@note from https://stackoverflow.com/a/1001328/266378
*/
static
bool
little_endianess
(
int
num
=
1
)
noexcept
{
return
*
reinterpret_cast
<
char
*>
(
&
num
)
==
1
;
}
///////////////////
///////////////////
// binary reader //
// binary reader //
///////////////////
///////////////////
...
@@ -117,18 +131,6 @@ class binary_reader
...
@@ -117,18 +131,6 @@ class binary_reader
return
result
;
return
result
;
}
}
/*!
@brief determine system byte order
@return true if and only if system's byte order is little endian
@note from https://stackoverflow.com/a/1001328/266378
*/
static
constexpr
bool
little_endianess
(
int
num
=
1
)
noexcept
{
return
*
reinterpret_cast
<
char
*>
(
&
num
)
==
1
;
}
private
:
private
:
//////////
//////////
// BSON //
// BSON //
...
...
include/nlohmann/detail/output/binary_writer.hpp
View file @
c7282d5b
...
@@ -1326,7 +1326,7 @@ class binary_writer
...
@@ -1326,7 +1326,7 @@ class binary_writer
private
:
private
:
/// whether we can assume little endianess
/// whether we can assume little endianess
const
bool
is_little_endian
=
binary_reader
<
BasicJsonType
,
input_buffer_adapter
>::
little_endianess
();
const
bool
is_little_endian
=
little_endianess
();
/// the output
/// the output
output_adapter_t
<
CharType
>
oa
=
nullptr
;
output_adapter_t
<
CharType
>
oa
=
nullptr
;
...
...
single_include/nlohmann/json.hpp
View file @
c7282d5b
...
@@ -5214,6 +5214,20 @@ namespace nlohmann
...
@@ -5214,6 +5214,20 @@ namespace nlohmann
{
{
namespace
detail
namespace
detail
{
{
/*!
@brief determine system byte order
@return true if and only if system's byte order is little endian
@note from https://stackoverflow.com/a/1001328/266378
*/
static
bool
little_endianess
(
int
num
=
1
)
noexcept
{
return
*
reinterpret_cast
<
char
*>
(
&
num
)
==
1
;
}
///////////////////
///////////////////
// binary reader //
// binary reader //
///////////////////
///////////////////
...
@@ -5307,18 +5321,6 @@ class binary_reader
...
@@ -5307,18 +5321,6 @@ class binary_reader
return
result
;
return
result
;
}
}
/*!
@brief determine system byte order
@return true if and only if system's byte order is little endian
@note from https://stackoverflow.com/a/1001328/266378
*/
static
constexpr
bool
little_endianess
(
int
num
=
1
)
noexcept
{
return
*
reinterpret_cast
<
char
*>
(
&
num
)
==
1
;
}
private
:
private
:
//////////
//////////
// BSON //
// BSON //
...
@@ -12674,7 +12676,7 @@ class binary_writer
...
@@ -12674,7 +12676,7 @@ class binary_writer
private
:
private
:
/// whether we can assume little endianess
/// whether we can assume little endianess
const
bool
is_little_endian
=
binary_reader
<
BasicJsonType
,
input_buffer_adapter
>::
little_endianess
();
const
bool
is_little_endian
=
little_endianess
();
/// the output
/// the output
output_adapter_t
<
CharType
>
oa
=
nullptr
;
output_adapter_t
<
CharType
>
oa
=
nullptr
;
...
...
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