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
710f26f9
Unverified
Commit
710f26f9
authored
Mar 19, 2019
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
📝
added documentation
parent
b224c523
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
269 additions
and
18 deletions
+269
-18
doc/examples/json_pointer__operator_add.cpp
doc/examples/json_pointer__operator_add.cpp
+23
-0
doc/examples/json_pointer__operator_add.link
doc/examples/json_pointer__operator_add.link
+1
-0
doc/examples/json_pointer__operator_add.output
doc/examples/json_pointer__operator_add.output
+4
-0
doc/examples/json_pointer__operator_add_binary.cpp
doc/examples/json_pointer__operator_add_binary.cpp
+19
-0
doc/examples/json_pointer__operator_add_binary.link
doc/examples/json_pointer__operator_add_binary.link
+1
-0
doc/examples/json_pointer__operator_add_binary.output
doc/examples/json_pointer__operator_add_binary.output
+3
-0
include/nlohmann/detail/json_pointer.hpp
include/nlohmann/detail/json_pointer.hpp
+109
-9
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+109
-9
No files found.
doc/examples/json_pointer__operator_add.cpp
0 → 100644
View file @
710f26f9
#include <iostream>
#include <nlohmann/json.hpp>
using
json
=
nlohmann
::
json
;
int
main
()
{
// create a JSON pointer
json
::
json_pointer
ptr
(
"/foo"
);
std
::
cout
<<
ptr
<<
'\n'
;
// apppend a JSON Pointer
ptr
/=
json
::
json_pointer
(
"/bar/baz"
);
std
::
cout
<<
ptr
<<
'\n'
;
// append a string
ptr
/=
"fob"
;
std
::
cout
<<
ptr
<<
'\n'
;
// append an array index
ptr
/=
42
;
std
::
cout
<<
ptr
<<
std
::
endl
;
}
doc/examples/json_pointer__operator_add.link
0 → 100644
View file @
710f26f9
<a target="_blank" href="https://wandbox.org/permlink/9GFummh9iBAkOFiL"><b>online</b></a>
\ No newline at end of file
doc/examples/json_pointer__operator_add.output
0 → 100644
View file @
710f26f9
"/foo"
"/foo/bar/baz"
"/foo/bar/baz/fob"
"/foo/bar/baz/fob/42"
doc/examples/json_pointer__operator_add_binary.cpp
0 → 100644
View file @
710f26f9
#include <iostream>
#include <nlohmann/json.hpp>
using
json
=
nlohmann
::
json
;
int
main
()
{
// create a JSON pointer
json
::
json_pointer
ptr
(
"/foo"
);
// apppend a JSON Pointer
std
::
cout
<<
ptr
/
json
::
json_pointer
(
"/bar/baz"
)
<<
'\n'
;
// append a string
std
::
cout
<<
ptr
/
"fob"
<<
'\n'
;
// append an array index
std
::
cout
<<
ptr
/
42
<<
std
::
endl
;
}
doc/examples/json_pointer__operator_add_binary.link
0 → 100644
View file @
710f26f9
<a target="_blank" href="https://wandbox.org/permlink/mxBfUH9gOY9AiOOk"><b>online</b></a>
\ No newline at end of file
doc/examples/json_pointer__operator_add_binary.output
0 → 100644
View file @
710f26f9
"/foo/bar/baz"
"/foo/fob"
"/foo/42"
include/nlohmann/detail/json_pointer.hpp
View file @
710f26f9
...
...
@@ -56,8 +56,7 @@ class json_pointer
@return a string representation of the JSON pointer
@liveexample{The example shows the result of `to_string`.,
json_pointer__to_string}
@liveexample{The example shows the result of `to_string`.,json_pointer__to_string}
@since version 2.0.0
*/
...
...
@@ -79,6 +78,19 @@ class json_pointer
/*!
@brief append another JSON pointer at the end of this JSON pointer
@param[in] ptr JSON pointer to append
@return JSON pointer with @a ptr appended
@liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
@complexity Linear in the length of @a ptr.
@sa @ref operator/=(std::string) to append a reference token
@sa @ref operator/=(std::size_t) to append an array index
@sa @ref operator/(const json_pointer&, const json_pointer&) for a binary operator
@since version 3.6.0
*/
json_pointer
&
operator
/=
(
const
json_pointer
&
ptr
)
{
...
...
@@ -88,14 +100,44 @@ class json_pointer
return
*
this
;
}
/// @copydoc push_back(std::string&&)
/*!
@brief append an unescaped reference token at the end of this JSON pointer
@param[in] token reference token to append
@return JSON pointer with @a token appended without escaping @a token
@liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
@complexity Amortized constant.
@sa @ref operator/=(const json_pointer&) to append a JSON pointer
@sa @ref operator/=(std::size_t) to append an array index
@sa @ref operator/(const json_pointer&, std::size_t) for a binary operator
@since version 3.6.0
*/
json_pointer
&
operator
/=
(
std
::
string
token
)
{
push_back
(
std
::
move
(
token
));
return
*
this
;
}
/// @copydoc operator/=(std::string)
/*!
@brief append an array index at the end of this JSON pointer
@param[in] array_index array index ot append
@return JSON pointer with @a array_index appended
@liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
@complexity Amortized constant.
@sa @ref operator/=(const json_pointer&) to append a JSON pointer
@sa @ref operator/=(std::string) to append a reference token
@sa @ref operator/(const json_pointer&, std::string) for a binary operator
@since version 3.6.0
*/
json_pointer
&
operator
/=
(
std
::
size_t
array_index
)
{
return
*
this
/=
std
::
to_string
(
array_index
);
...
...
@@ -103,15 +145,39 @@ class json_pointer
/*!
@brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
@param[in] lhs JSON pointer
@param[in] rhs JSON pointer
@return a new JSON pointer with @a rhs appended to @a lhs
@liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
@complexity Linear in the length of @a lhs and @a rhs.
@sa @ref operator/=(const json_pointer&) to append a JSON pointer
@since version 3.6.0
*/
friend
json_pointer
operator
/
(
const
json_pointer
&
l
eft_ptr
,
const
json_pointer
&
r
ight_ptr
)
friend
json_pointer
operator
/
(
const
json_pointer
&
l
hs
,
const
json_pointer
&
r
hs
)
{
return
json_pointer
(
l
eft_ptr
)
/=
right_ptr
;
return
json_pointer
(
l
hs
)
/=
rhs
;
}
/*!
@brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
@param[in] ptr JSON pointer
@param[in] token reference token
@return a new JSON pointer with unescaped @a token appended to @a ptr
@liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
@complexity Linear in the length of @a ptr.
@sa @ref operator/=(std::string) to append a reference token
@since version 3.6.0
*/
friend
json_pointer
operator
/
(
const
json_pointer
&
ptr
,
std
::
string
token
)
{
...
...
@@ -120,10 +186,22 @@ class json_pointer
/*!
@brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
@param[in] ptr JSON pointer
@param[in] array_index array index
@return a new JSON pointer with @a array_index appended to @a ptr
@liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
@complexity Linear in the length of @a ptr.
@sa @ref operator/=(std::size_t) to append an array index
@since version 3.6.0
*/
friend
json_pointer
operator
/
(
const
json_pointer
&
lhs
,
std
::
size_t
array_index
)
friend
json_pointer
operator
/
(
const
json_pointer
&
ptr
,
std
::
size_t
array_index
)
{
return
json_pointer
(
lhs
)
/=
array_index
;
return
json_pointer
(
ptr
)
/=
array_index
;
}
/*!
...
...
@@ -790,12 +868,34 @@ class json_pointer
return
result
;
}
/*!
@brief compares two JSON pointers for equality
@param[in] lhs JSON pointer to compare
@param[in] rhs JSON pointer to compare
@return whether @a lhs is equal to @a rhs
@complexity Linear in the length of the JSON pointer
@exceptionsafety No-throw guarantee: this function never throws exceptions.
*/
friend
bool
operator
==
(
json_pointer
const
&
lhs
,
json_pointer
const
&
rhs
)
noexcept
{
return
lhs
.
reference_tokens
==
rhs
.
reference_tokens
;
}
/*!
@brief compares two JSON pointers for inequality
@param[in] lhs JSON pointer to compare
@param[in] rhs JSON pointer to compare
@return whether @a lhs is not equal @a rhs
@complexity Linear in the length of the JSON pointer
@exceptionsafety No-throw guarantee: this function never throws exceptions.
*/
friend
bool
operator
!=
(
json_pointer
const
&
lhs
,
json_pointer
const
&
rhs
)
noexcept
{
...
...
single_include/nlohmann/json.hpp
View file @
710f26f9
...
...
@@ -8466,8 +8466,7 @@ class json_pointer
@return a string representation of the JSON pointer
@liveexample{The example shows the result of `to_string`.,
json_pointer__to_string}
@liveexample{The example shows the result of `to_string`.,json_pointer__to_string}
@since version 2.0.0
*/
...
...
@@ -8489,6 +8488,19 @@ class json_pointer
/*!
@brief append another JSON pointer at the end of this JSON pointer
@param[in] ptr JSON pointer to append
@return JSON pointer with @a ptr appended
@liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
@complexity Linear in the length of @a ptr.
@sa @ref operator/=(std::string) to append a reference token
@sa @ref operator/=(std::size_t) to append an array index
@sa @ref operator/(const json_pointer&, const json_pointer&) for a binary operator
@since version 3.6.0
*/
json_pointer
&
operator
/=
(
const
json_pointer
&
ptr
)
{
...
...
@@ -8498,14 +8510,44 @@ class json_pointer
return
*
this
;
}
/// @copydoc push_back(std::string&&)
/*!
@brief append an unescaped reference token at the end of this JSON pointer
@param[in] token reference token to append
@return JSON pointer with @a token appended without escaping @a token
@liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
@complexity Amortized constant.
@sa @ref operator/=(const json_pointer&) to append a JSON pointer
@sa @ref operator/=(std::size_t) to append an array index
@sa @ref operator/(const json_pointer&, std::size_t) for a binary operator
@since version 3.6.0
*/
json_pointer
&
operator
/=
(
std
::
string
token
)
{
push_back
(
std
::
move
(
token
));
return
*
this
;
}
/// @copydoc operator/=(std::string)
/*!
@brief append an array index at the end of this JSON pointer
@param[in] array_index array index ot append
@return JSON pointer with @a array_index appended
@liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
@complexity Amortized constant.
@sa @ref operator/=(const json_pointer&) to append a JSON pointer
@sa @ref operator/=(std::string) to append a reference token
@sa @ref operator/(const json_pointer&, std::string) for a binary operator
@since version 3.6.0
*/
json_pointer
&
operator
/=
(
std
::
size_t
array_index
)
{
return
*
this
/=
std
::
to_string
(
array_index
);
...
...
@@ -8513,15 +8555,39 @@ class json_pointer
/*!
@brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
@param[in] lhs JSON pointer
@param[in] rhs JSON pointer
@return a new JSON pointer with @a rhs appended to @a lhs
@liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
@complexity Linear in the length of @a lhs and @a rhs.
@sa @ref operator/=(const json_pointer&) to append a JSON pointer
@since version 3.6.0
*/
friend
json_pointer
operator
/
(
const
json_pointer
&
l
eft_ptr
,
const
json_pointer
&
r
ight_ptr
)
friend
json_pointer
operator
/
(
const
json_pointer
&
l
hs
,
const
json_pointer
&
r
hs
)
{
return
json_pointer
(
l
eft_ptr
)
/=
right_ptr
;
return
json_pointer
(
l
hs
)
/=
rhs
;
}
/*!
@brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
@param[in] ptr JSON pointer
@param[in] token reference token
@return a new JSON pointer with unescaped @a token appended to @a ptr
@liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
@complexity Linear in the length of @a ptr.
@sa @ref operator/=(std::string) to append a reference token
@since version 3.6.0
*/
friend
json_pointer
operator
/
(
const
json_pointer
&
ptr
,
std
::
string
token
)
{
...
...
@@ -8530,10 +8596,22 @@ class json_pointer
/*!
@brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
@param[in] ptr JSON pointer
@param[in] array_index array index
@return a new JSON pointer with @a array_index appended to @a ptr
@liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
@complexity Linear in the length of @a ptr.
@sa @ref operator/=(std::size_t) to append an array index
@since version 3.6.0
*/
friend
json_pointer
operator
/
(
const
json_pointer
&
lhs
,
std
::
size_t
array_index
)
friend
json_pointer
operator
/
(
const
json_pointer
&
ptr
,
std
::
size_t
array_index
)
{
return
json_pointer
(
lhs
)
/=
array_index
;
return
json_pointer
(
ptr
)
/=
array_index
;
}
/*!
...
...
@@ -9200,12 +9278,34 @@ class json_pointer
return
result
;
}
/*!
@brief compares two JSON pointers for equality
@param[in] lhs JSON pointer to compare
@param[in] rhs JSON pointer to compare
@return whether @a lhs is equal to @a rhs
@complexity Linear in the length of the JSON pointer
@exceptionsafety No-throw guarantee: this function never throws exceptions.
*/
friend
bool
operator
==
(
json_pointer
const
&
lhs
,
json_pointer
const
&
rhs
)
noexcept
{
return
lhs
.
reference_tokens
==
rhs
.
reference_tokens
;
}
/*!
@brief compares two JSON pointers for inequality
@param[in] lhs JSON pointer to compare
@param[in] rhs JSON pointer to compare
@return whether @a lhs is not equal @a rhs
@complexity Linear in the length of the JSON pointer
@exceptionsafety No-throw guarantee: this function never throws exceptions.
*/
friend
bool
operator
!=
(
json_pointer
const
&
lhs
,
json_pointer
const
&
rhs
)
noexcept
{
...
...
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