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
83f1d2c8
Unverified
Commit
83f1d2c8
authored
Feb 19, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
added start index for from_cbor and from_msgpack (#462)
parent
4151f2d2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
23 deletions
+57
-23
src/json.hpp
src/json.hpp
+24
-11
src/json.hpp.re2c
src/json.hpp.re2c
+24
-11
test/src/unit-cbor.cpp
test/src/unit-cbor.cpp
+4
-0
test/src/unit-msgpack.cpp
test/src/unit-msgpack.cpp
+4
-0
test/src/unit-regression.cpp
test/src/unit-regression.cpp
+1
-1
No files found.
src/json.hpp
View file @
83f1d2c8
...
...
@@ -7917,9 +7917,11 @@ class basic_json
vector in MessagePack format.,to_msgpack}
@sa http://msgpack.org
@sa @ref from_msgpack(const std::vector<uint8_t>&
) for the analogous
deserialization
@sa @ref from_msgpack(const std::vector<uint8_t>&
, const size_t) for the
analogous
deserialization
@sa @ref to_cbor(const basic_json& for the related CBOR format
@since version 2.0.9
*/
static
std
::
vector
<
uint8_t
>
to_msgpack
(
const
basic_json
&
j
)
{
...
...
@@ -7935,6 +7937,7 @@ class basic_json
serialization format.
@param[in] v a byte vector in MessagePack format
@param[in] start_index the index to start reading from @a v (0 by default)
@return deserialized JSON value
@throw std::invalid_argument if unsupported features from MessagePack were
...
...
@@ -7948,11 +7951,15 @@ class basic_json
@sa http://msgpack.org
@sa @ref to_msgpack(const basic_json&) for the analogous serialization
@sa @ref from_cbor(const std::vector<uint8_t>&) for the related CBOR format
@sa @ref from_cbor(const std::vector<uint8_t>&, const size_t) for the
related CBOR format
@since version 2.0.9, parameter @a start_index since 2.0.11
*/
static
basic_json
from_msgpack
(
const
std
::
vector
<
uint8_t
>&
v
)
static
basic_json
from_msgpack
(
const
std
::
vector
<
uint8_t
>&
v
,
const
size_t
start_index
=
0
)
{
size_t
i
=
0
;
size_t
i
=
start_index
;
return
from_msgpack_internal
(
v
,
i
);
}
...
...
@@ -7973,9 +7980,11 @@ class basic_json
vector in CBOR format.,to_cbor}
@sa http://cbor.io
@sa @ref from_cbor(const std::vector<uint8_t>&
) for the analogous
deserialization
@sa @ref from_cbor(const std::vector<uint8_t>&
, const size_t) for the
analogous
deserialization
@sa @ref to_msgpack(const basic_json& for the related MessagePack format
@since version 2.0.9
*/
static
std
::
vector
<
uint8_t
>
to_cbor
(
const
basic_json
&
j
)
{
...
...
@@ -7991,6 +8000,7 @@ class basic_json
(Concise Binary Object Representation) serialization format.
@param[in] v a byte vector in CBOR format
@param[in] start_index the index to start reading from @a v (0 by default)
@return deserialized JSON value
@throw std::invalid_argument if unsupported features from CBOR were used in
...
...
@@ -8004,12 +8014,15 @@ class basic_json
@sa http://cbor.io
@sa @ref to_cbor(const basic_json&) for the analogous serialization
@sa @ref from_msgpack(const std::vector<uint8_t>&) for the related
MessagePack format
@sa @ref from_msgpack(const std::vector<uint8_t>&, const size_t) for the
related MessagePack format
@since version 2.0.9, parameter @a start_index since 2.0.11
*/
static
basic_json
from_cbor
(
const
std
::
vector
<
uint8_t
>&
v
)
static
basic_json
from_cbor
(
const
std
::
vector
<
uint8_t
>&
v
,
const
size_t
start_index
=
0
)
{
size_t
i
=
0
;
size_t
i
=
start_index
;
return
from_cbor_internal
(
v
,
i
);
}
...
...
src/json.hpp.re2c
View file @
83f1d2c8
...
...
@@ -7917,9 +7917,11 @@ class basic_json
vector in MessagePack format.,to_msgpack}
@sa http://msgpack.org
@sa @ref from_msgpack(const std::vector<uint8_t>&
) for the analogous
deserialization
@sa @ref from_msgpack(const std::vector<uint8_t>&
, const size_t) for the
analogous
deserialization
@sa @ref to_cbor(const basic_json& for the related CBOR format
@since version 2.0.9
*/
static std::vector<uint8_t> to_msgpack(const basic_json& j)
{
...
...
@@ -7935,6 +7937,7 @@ class basic_json
serialization format.
@param[in] v a byte vector in MessagePack format
@param[in] start_index the index to start reading from @a v (0 by default)
@return deserialized JSON value
@throw std::invalid_argument if unsupported features from MessagePack were
...
...
@@ -7948,11 +7951,15 @@ class basic_json
@sa http://msgpack.org
@sa @ref to_msgpack(const basic_json&) for the analogous serialization
@sa @ref from_cbor(const std::vector<uint8_t>&) for the related CBOR format
@sa @ref from_cbor(const std::vector<uint8_t>&, const size_t) for the
related CBOR format
@since version 2.0.9, parameter @a start_index since 2.0.11
*/
static basic_json from_msgpack(const std::vector<uint8_t>& v)
static basic_json from_msgpack(const std::vector<uint8_t>& v,
const size_t start_index = 0)
{
size_t i =
0
;
size_t i =
start_index
;
return from_msgpack_internal(v, i);
}
...
...
@@ -7973,9 +7980,11 @@ class basic_json
vector in CBOR format.,to_cbor}
@sa http://cbor.io
@sa @ref from_cbor(const std::vector<uint8_t>&
) for the analogous
deserialization
@sa @ref from_cbor(const std::vector<uint8_t>&
, const size_t) for the
analogous
deserialization
@sa @ref to_msgpack(const basic_json& for the related MessagePack format
@since version 2.0.9
*/
static std::vector<uint8_t> to_cbor(const basic_json& j)
{
...
...
@@ -7991,6 +8000,7 @@ class basic_json
(Concise Binary Object Representation) serialization format.
@param[in] v a byte vector in CBOR format
@param[in] start_index the index to start reading from @a v (0 by default)
@return deserialized JSON value
@throw std::invalid_argument if unsupported features from CBOR were used in
...
...
@@ -8004,12 +8014,15 @@ class basic_json
@sa http://cbor.io
@sa @ref to_cbor(const basic_json&) for the analogous serialization
@sa @ref from_msgpack(const std::vector<uint8_t>&) for the related
MessagePack format
@sa @ref from_msgpack(const std::vector<uint8_t>&, const size_t) for the
related MessagePack format
@since version 2.0.9, parameter @a start_index since 2.0.11
*/
static basic_json from_cbor(const std::vector<uint8_t>& v)
static basic_json from_cbor(const std::vector<uint8_t>& v,
const size_t start_index = 0)
{
size_t i =
0
;
size_t i =
start_index
;
return from_cbor_internal(v, i);
}
...
...
test/src/unit-cbor.cpp
View file @
83f1d2c8
...
...
@@ -1184,6 +1184,10 @@ TEST_CASE("single CBOR roundtrip")
// compare parsed JSON values
CHECK
(
j1
==
j2
);
// check with different start index
packed
.
insert
(
packed
.
begin
(),
5
,
0xff
);
CHECK
(
j1
==
json
::
from_cbor
(
packed
,
5
));
}
}
...
...
test/src/unit-msgpack.cpp
View file @
83f1d2c8
...
...
@@ -1039,6 +1039,10 @@ TEST_CASE("single MessagePack roundtrip")
// compare parsed JSON values
CHECK
(
j1
==
j2
);
// check with different start index
packed
.
insert
(
packed
.
begin
(),
5
,
0xff
);
CHECK
(
j1
==
json
::
from_msgpack
(
packed
,
5
));
}
}
...
...
test/src/unit-regression.cpp
View file @
83f1d2c8
...
...
@@ -385,7 +385,7 @@ TEST_CASE("regression tests")
{
return
'.'
;
}
std
::
string
do_grouping
()
const
{
return
"
\03
"
;
...
...
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