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
dda8a5c4
Commit
dda8a5c4
authored
Apr 12, 2015
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjusted code to documentation; some cleanup
parent
139ef0e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
66 deletions
+66
-66
src/json.hpp
src/json.hpp
+33
-33
src/json.hpp.re2c
src/json.hpp.re2c
+33
-33
No files found.
src/json.hpp
View file @
dda8a5c4
...
...
@@ -1110,7 +1110,7 @@ class basic_json
////////////////////
/// access specified element with bounds checking
inline
reference
at
(
size_type
pos
)
inline
reference
at
(
size_type
idx
)
{
// at only works for arrays
if
(
m_type
!=
value_t
::
array
)
...
...
@@ -1118,11 +1118,11 @@ class basic_json
throw
std
::
runtime_error
(
"cannot use at with "
+
type_name
());
}
return
m_value
.
array
->
at
(
pos
);
return
m_value
.
array
->
at
(
idx
);
}
/// access specified element with bounds checking
inline
const_reference
at
(
size_type
pos
)
const
inline
const_reference
at
(
size_type
idx
)
const
{
// at only works for arrays
if
(
m_type
!=
value_t
::
array
)
...
...
@@ -1130,11 +1130,35 @@ class basic_json
throw
std
::
runtime_error
(
"cannot use at with "
+
type_name
());
}
return
m_value
.
array
->
at
(
pos
);
return
m_value
.
array
->
at
(
idx
);
}
/// access specified element with bounds checking
inline
reference
at
(
const
typename
object_t
::
key_type
&
key
)
{
// at only works for objects
if
(
m_type
!=
value_t
::
object
)
{
throw
std
::
runtime_error
(
"cannot use at with "
+
type_name
());
}
return
m_value
.
object
->
at
(
key
);
}
/// access specified element with bounds checking
inline
const_reference
at
(
const
typename
object_t
::
key_type
&
key
)
const
{
// at only works for objects
if
(
m_type
!=
value_t
::
object
)
{
throw
std
::
runtime_error
(
"cannot use at with "
+
type_name
());
}
return
m_value
.
object
->
at
(
key
);
}
/// access specified element
inline
reference
operator
[](
size_type
pos
)
inline
reference
operator
[](
size_type
idx
)
{
// implicitly convert null to object
if
(
m_type
==
value_t
::
null
)
...
...
@@ -1151,16 +1175,16 @@ class basic_json
throw
std
::
runtime_error
(
"cannot use [] with "
+
type_name
());
}
for
(
size_t
i
=
m_value
.
array
->
size
();
i
<=
pos
;
++
i
)
for
(
size_t
i
=
m_value
.
array
->
size
();
i
<=
idx
;
++
i
)
{
m_value
.
array
->
push_back
(
basic_json
());
}
return
m_value
.
array
->
operator
[](
pos
);
return
m_value
.
array
->
operator
[](
idx
);
}
/// access specified element
inline
const_reference
operator
[](
size_type
pos
)
const
inline
const_reference
operator
[](
size_type
idx
)
const
{
// at only works for arrays
if
(
m_type
!=
value_t
::
array
)
...
...
@@ -1168,31 +1192,7 @@ class basic_json
throw
std
::
runtime_error
(
"cannot use [] with "
+
type_name
());
}
return
m_value
.
array
->
operator
[](
pos
);
}
/// access specified element with bounds checking
inline
reference
at
(
const
typename
object_t
::
key_type
&
key
)
{
// at only works for objects
if
(
m_type
!=
value_t
::
object
)
{
throw
std
::
runtime_error
(
"cannot use at with "
+
type_name
());
}
return
m_value
.
object
->
at
(
key
);
}
/// access specified element with bounds checking
inline
const_reference
at
(
const
typename
object_t
::
key_type
&
key
)
const
{
// at only works for objects
if
(
m_type
!=
value_t
::
object
)
{
throw
std
::
runtime_error
(
"cannot use at with "
+
type_name
());
}
return
m_value
.
object
->
at
(
key
);
return
m_value
.
array
->
operator
[](
idx
);
}
/// access specified element
...
...
src/json.hpp.re2c
View file @
dda8a5c4
...
...
@@ -1110,7 +1110,7 @@ class basic_json
////////////////////
/// access specified element with bounds checking
inline reference at(size_type
pos
)
inline reference at(size_type
idx
)
{
// at only works for arrays
if (m_type != value_t::array)
...
...
@@ -1118,11 +1118,11 @@ class basic_json
throw std::runtime_error("cannot use at with " + type_name());
}
return m_value.array->at(
pos
);
return m_value.array->at(
idx
);
}
/// access specified element with bounds checking
inline const_reference at(size_type
pos
) const
inline const_reference at(size_type
idx
) const
{
// at only works for arrays
if (m_type != value_t::array)
...
...
@@ -1130,11 +1130,35 @@ class basic_json
throw std::runtime_error("cannot use at with " + type_name());
}
return m_value.array->at(pos);
return m_value.array->at(idx);
}
/// access specified element with bounds checking
inline reference at(const typename object_t::key_type& key)
{
// at only works for objects
if (m_type != value_t::object)
{
throw std::runtime_error("cannot use at with " + type_name());
}
return m_value.object->at(key);
}
/// access specified element with bounds checking
inline const_reference at(const typename object_t::key_type& key) const
{
// at only works for objects
if (m_type != value_t::object)
{
throw std::runtime_error("cannot use at with " + type_name());
}
return m_value.object->at(key);
}
/// access specified element
inline reference operator[](size_type
pos
)
inline reference operator[](size_type
idx
)
{
// implicitly convert null to object
if (m_type == value_t::null)
...
...
@@ -1151,16 +1175,16 @@ class basic_json
throw std::runtime_error("cannot use [] with " + type_name());
}
for (size_t i = m_value.array->size(); i <=
pos
; ++i)
for (size_t i = m_value.array->size(); i <=
idx
; ++i)
{
m_value.array->push_back(basic_json());
}
return m_value.array->operator[](
pos
);
return m_value.array->operator[](
idx
);
}
/// access specified element
inline const_reference operator[](size_type
pos
) const
inline const_reference operator[](size_type
idx
) const
{
// at only works for arrays
if (m_type != value_t::array)
...
...
@@ -1168,31 +1192,7 @@ class basic_json
throw std::runtime_error("cannot use [] with " + type_name());
}
return m_value.array->operator[](pos);
}
/// access specified element with bounds checking
inline reference at(const typename object_t::key_type& key)
{
// at only works for objects
if (m_type != value_t::object)
{
throw std::runtime_error("cannot use at with " + type_name());
}
return m_value.object->at(key);
}
/// access specified element with bounds checking
inline const_reference at(const typename object_t::key_type& key) const
{
// at only works for objects
if (m_type != value_t::object)
{
throw std::runtime_error("cannot use at with " + type_name());
}
return m_value.object->at(key);
return m_value.array->operator[](idx);
}
/// access specified element
...
...
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