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
3b776c08
Commit
3b776c08
authored
Feb 07, 2016
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clarified documentation
parent
8b1a777d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
14 deletions
+16
-14
src/json.hpp
src/json.hpp
+8
-7
src/json.hpp.re2c
src/json.hpp.re2c
+8
-7
No files found.
src/json.hpp
View file @
3b776c08
...
...
@@ -3144,7 +3144,7 @@ class basic_json
@return reference to the element at index @a idx
@throw std::domain_error if JSON is not an array or null; example: `"cannot
use operator[] with
null
"`
use operator[] with
string
"`
@complexity Constant if @a idx is in the range of the array. Otherwise
linear in `idx - size()`.
...
...
@@ -3157,16 +3157,17 @@ class basic_json
*/
reference
operator
[](
size_type
idx
)
{
// implicitly convert null
to object
// implicitly convert null
value to an empty array
if
(
is_null
())
{
m_type
=
value_t
::
array
;
m_value
.
array
=
create
<
array_t
>
();
}
// [] only works for arrays
//
operator
[] only works for arrays
if
(
is_array
())
{
// fill up array with null values until given idx is reached
assert
(
m_value
.
array
!=
nullptr
);
for
(
size_t
i
=
m_value
.
array
->
size
();
i
<=
idx
;
++
i
)
{
...
...
@@ -3202,7 +3203,7 @@ class basic_json
*/
const_reference
operator
[](
size_type
idx
)
const
{
//
at
only works for arrays
//
const operator[]
only works for arrays
if
(
is_array
())
{
assert
(
m_value
.
array
!=
nullptr
);
...
...
@@ -3243,14 +3244,14 @@ class basic_json
*/
reference
operator
[](
const
typename
object_t
::
key_type
&
key
)
{
// implicitly convert null
to
object
// implicitly convert null
value to an empty
object
if
(
is_null
())
{
m_type
=
value_t
::
object
;
m_value
.
object
=
create
<
object_t
>
();
}
// [] only works for objects
//
operator
[] only works for objects
if
(
is_object
())
{
assert
(
m_value
.
object
!=
nullptr
);
...
...
@@ -3291,7 +3292,7 @@ class basic_json
*/
const_reference
operator
[](
const
typename
object_t
::
key_type
&
key
)
const
{
// [] only works for objects
//
const operator
[] only works for objects
if
(
is_object
())
{
assert
(
m_value
.
object
!=
nullptr
);
...
...
src/json.hpp.re2c
View file @
3b776c08
...
...
@@ -3144,7 +3144,7 @@ class basic_json
@return reference to the element at index @a idx
@throw std::domain_error if JSON is not an array or null; example: `"cannot
use operator[] with
null
"`
use operator[] with
string
"`
@complexity Constant if @a idx is in the range of the array. Otherwise
linear in `idx - size()`.
...
...
@@ -3157,16 +3157,17 @@ class basic_json
*/
reference operator[](size_type idx)
{
// implicitly convert null
to object
// implicitly convert null
value to an empty array
if (is_null())
{
m_type = value_t::array;
m_value.array = create<array_t>();
}
// [] only works for arrays
//
operator
[] only works for arrays
if (is_array())
{
// fill up array with null values until given idx is reached
assert(m_value.array != nullptr);
for (size_t i = m_value.array->size(); i <= idx; ++i)
{
...
...
@@ -3202,7 +3203,7 @@ class basic_json
*/
const_reference operator[](size_type idx) const
{
//
at
only works for arrays
//
const operator[]
only works for arrays
if (is_array())
{
assert(m_value.array != nullptr);
...
...
@@ -3243,14 +3244,14 @@ class basic_json
*/
reference operator[](const typename object_t::key_type& key)
{
// implicitly convert null
to
object
// implicitly convert null
value to an empty
object
if (is_null())
{
m_type = value_t::object;
m_value.object = create<object_t>();
}
// [] only works for objects
//
operator
[] only works for objects
if (is_object())
{
assert(m_value.object != nullptr);
...
...
@@ -3291,7 +3292,7 @@ class basic_json
*/
const_reference operator[](const typename object_t::key_type& key) const
{
// [] only works for objects
//
const operator
[] only works for objects
if (is_object())
{
assert(m_value.object != 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