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
421a0843
Unverified
Commit
421a0843
authored
May 06, 2020
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
add convenience function to create binary value with given subtype
parent
2b39efd5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
8 deletions
+100
-8
include/nlohmann/json.hpp
include/nlohmann/json.hpp
+50
-4
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+50
-4
No files found.
include/nlohmann/json.hpp
View file @
421a0843
...
...
@@ -889,9 +889,25 @@ class basic_json
struct
internal_binary_t
:
public
BinaryType
{
using
BinaryType
::
BinaryType
;
internal_binary_t
()
noexcept
(
noexcept
(
BinaryType
()))
:
BinaryType
()
{}
internal_binary_t
(
BinaryType
const
&
bint
)
noexcept
(
noexcept
(
BinaryType
(
bint
)))
:
BinaryType
(
bint
)
{}
internal_binary_t
(
BinaryType
&&
bint
)
noexcept
(
noexcept
(
BinaryType
(
std
::
move
(
bint
))))
:
BinaryType
(
std
::
move
(
bint
))
{}
internal_binary_t
()
noexcept
(
noexcept
(
BinaryType
()))
:
BinaryType
()
{}
internal_binary_t
(
const
BinaryType
&
bint
)
noexcept
(
noexcept
(
BinaryType
(
bint
)))
:
BinaryType
(
bint
)
{}
internal_binary_t
(
BinaryType
&&
bint
)
noexcept
(
noexcept
(
BinaryType
(
std
::
move
(
bint
))))
:
BinaryType
(
std
::
move
(
bint
))
{}
internal_binary_t
(
const
BinaryType
&
bint
,
std
::
uint8_t
st
)
noexcept
(
noexcept
(
BinaryType
(
bint
)))
:
BinaryType
(
bint
)
,
subtype
(
st
)
,
has_subtype
(
true
)
{}
internal_binary_t
(
BinaryType
&&
bint
,
std
::
uint8_t
st
)
noexcept
(
noexcept
(
BinaryType
(
std
::
move
(
bint
))))
:
BinaryType
(
std
::
move
(
bint
))
,
subtype
(
st
)
,
has_subtype
(
true
)
{}
// TOOD: If minimum C++ version is ever bumped to C++17, this field
// deserves to be a std::optional
...
...
@@ -1098,6 +1114,18 @@ class basic_json
binary
=
create
<
internal_binary_t
>
(
std
::
move
(
value
));
}
/// constructor for binary arrays (internal type)
json_value
(
const
internal_binary_t
&
value
)
{
binary
=
create
<
internal_binary_t
>
(
value
);
}
/// constructor for rvalue binary arrays (internal type)
json_value
(
internal_binary_t
&&
value
)
{
binary
=
create
<
internal_binary_t
>
(
std
::
move
(
value
));
}
void
destroy
(
value_t
t
)
noexcept
{
// flatten the current json_value to a heap-allocated stack
...
...
@@ -1655,7 +1683,7 @@ class basic_json
@since version 3.8.0
*/
JSON_HEDLEY_WARN_UNUSED_RESULT
static
basic_json
binary_array
(
binary_t
cons
t
&
init
)
static
basic_json
binary_array
(
const
binary_
t
&
init
)
{
auto
res
=
basic_json
();
res
.
m_type
=
value_t
::
binary
;
...
...
@@ -1663,6 +1691,15 @@ class basic_json
return
res
;
}
JSON_HEDLEY_WARN_UNUSED_RESULT
static
basic_json
binary_array
(
const
binary_t
&
init
,
std
::
uint8_t
subtype
)
{
auto
res
=
basic_json
();
res
.
m_type
=
value_t
::
binary
;
res
.
m_value
=
internal_binary_t
(
init
,
subtype
);
return
res
;
}
/*!
@brief explicitly create a binary array from an already constructed rvalue
copy of its base type
...
...
@@ -1699,6 +1736,15 @@ class basic_json
return
res
;
}
JSON_HEDLEY_WARN_UNUSED_RESULT
static
basic_json
binary_array
(
binary_t
&&
init
,
std
::
uint8_t
subtype
)
{
auto
res
=
basic_json
();
res
.
m_type
=
value_t
::
binary
;
res
.
m_value
=
internal_binary_t
(
std
::
move
(
init
),
subtype
);
return
res
;
}
/*!
@brief explicitly create an array from an initializer list
...
...
single_include/nlohmann/json.hpp
View file @
421a0843
...
...
@@ -16396,9 +16396,25 @@ class basic_json
struct
internal_binary_t
:
public
BinaryType
{
using
BinaryType
::
BinaryType
;
internal_binary_t
()
noexcept
(
noexcept
(
BinaryType
()))
:
BinaryType
()
{}
internal_binary_t
(
BinaryType
const
&
bint
)
noexcept
(
noexcept
(
BinaryType
(
bint
)))
:
BinaryType
(
bint
)
{}
internal_binary_t
(
BinaryType
&&
bint
)
noexcept
(
noexcept
(
BinaryType
(
std
::
move
(
bint
))))
:
BinaryType
(
std
::
move
(
bint
))
{}
internal_binary_t
()
noexcept
(
noexcept
(
BinaryType
()))
:
BinaryType
()
{}
internal_binary_t
(
const
BinaryType
&
bint
)
noexcept
(
noexcept
(
BinaryType
(
bint
)))
:
BinaryType
(
bint
)
{}
internal_binary_t
(
BinaryType
&&
bint
)
noexcept
(
noexcept
(
BinaryType
(
std
::
move
(
bint
))))
:
BinaryType
(
std
::
move
(
bint
))
{}
internal_binary_t
(
const
BinaryType
&
bint
,
std
::
uint8_t
st
)
noexcept
(
noexcept
(
BinaryType
(
bint
)))
:
BinaryType
(
bint
)
,
subtype
(
st
)
,
has_subtype
(
true
)
{}
internal_binary_t
(
BinaryType
&&
bint
,
std
::
uint8_t
st
)
noexcept
(
noexcept
(
BinaryType
(
std
::
move
(
bint
))))
:
BinaryType
(
std
::
move
(
bint
))
,
subtype
(
st
)
,
has_subtype
(
true
)
{}
// TOOD: If minimum C++ version is ever bumped to C++17, this field
// deserves to be a std::optional
...
...
@@ -16605,6 +16621,18 @@ class basic_json
binary
=
create
<
internal_binary_t
>
(
std
::
move
(
value
));
}
/// constructor for binary arrays (internal type)
json_value
(
const
internal_binary_t
&
value
)
{
binary
=
create
<
internal_binary_t
>
(
value
);
}
/// constructor for rvalue binary arrays (internal type)
json_value
(
internal_binary_t
&&
value
)
{
binary
=
create
<
internal_binary_t
>
(
std
::
move
(
value
));
}
void
destroy
(
value_t
t
)
noexcept
{
// flatten the current json_value to a heap-allocated stack
...
...
@@ -17162,7 +17190,7 @@ class basic_json
@since version 3.8.0
*/
JSON_HEDLEY_WARN_UNUSED_RESULT
static
basic_json
binary_array
(
binary_t
cons
t
&
init
)
static
basic_json
binary_array
(
const
binary_
t
&
init
)
{
auto
res
=
basic_json
();
res
.
m_type
=
value_t
::
binary
;
...
...
@@ -17170,6 +17198,15 @@ class basic_json
return
res
;
}
JSON_HEDLEY_WARN_UNUSED_RESULT
static
basic_json
binary_array
(
const
binary_t
&
init
,
std
::
uint8_t
subtype
)
{
auto
res
=
basic_json
();
res
.
m_type
=
value_t
::
binary
;
res
.
m_value
=
internal_binary_t
(
init
,
subtype
);
return
res
;
}
/*!
@brief explicitly create a binary array from an already constructed rvalue
copy of its base type
...
...
@@ -17206,6 +17243,15 @@ class basic_json
return
res
;
}
JSON_HEDLEY_WARN_UNUSED_RESULT
static
basic_json
binary_array
(
binary_t
&&
init
,
std
::
uint8_t
subtype
)
{
auto
res
=
basic_json
();
res
.
m_type
=
value_t
::
binary
;
res
.
m_value
=
internal_binary_t
(
std
::
move
(
init
),
subtype
);
return
res
;
}
/*!
@brief explicitly create an array from an initializer list
...
...
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