Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
f24e4f68
Commit
f24e4f68
authored
Dec 14, 2016
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
cleanup after PR #395
parent
fe00b368
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
36 deletions
+37
-36
README.md
README.md
+1
-0
json.hpp
src/json.hpp
+17
-18
json.hpp.re2c
src/json.hpp.re2c
+19
-18
No files found.
README.md
View file @
f24e4f68
...
@@ -584,6 +584,7 @@ I deeply appreciate the help of the following people.
...
@@ -584,6 +584,7 @@ I deeply appreciate the help of the following people.
- [cgzones](https://github.com/cgzones) had an idea how to fix the Coverity scan.
- [cgzones](https://github.com/cgzones) had an idea how to fix the Coverity scan.
- [Jared Grubb](https://github.com/jaredgrubb) silenced a nasty documentation warning.
- [Jared Grubb](https://github.com/jaredgrubb) silenced a nasty documentation warning.
- [Yixin Zhang](https://github.com/qwename) fixed an integer overflow check.
- [Yixin Zhang](https://github.com/qwename) fixed an integer overflow check.
- [Bosswestfalen](https://github.com/Bosswestfalen) merged two iterator classes into a smaller one.
Thanks a lot for helping out!
Thanks a lot for helping out!
...
...
src/json.hpp
View file @
f24e4f68
...
@@ -228,6 +228,7 @@ class basic_json
...
@@ -228,6 +228,7 @@ class basic_json
public
:
public
:
// forward declarations
// forward declarations
template
<
typename
U
>
class
iter_impl
;
template
<
typename
Base
>
class
json_reverse_iterator
;
template
<
typename
Base
>
class
json_reverse_iterator
;
class
json_pointer
;
class
json_pointer
;
...
@@ -261,8 +262,6 @@ class basic_json
...
@@ -261,8 +262,6 @@ class basic_json
/// the type of an element const pointer
/// the type of an element const pointer
using
const_pointer
=
typename
std
::
allocator_traits
<
allocator_type
>::
const_pointer
;
using
const_pointer
=
typename
std
::
allocator_traits
<
allocator_type
>::
const_pointer
;
// forward declaration for iterators
template
<
typename
U
>
class
iter_impl
;
/// an iterator for a basic_json container
/// an iterator for a basic_json container
using
iterator
=
iter_impl
<
basic_json
>
;
using
iterator
=
iter_impl
<
basic_json
>
;
/// a const iterator for a basic_json container
/// a const iterator for a basic_json container
...
@@ -8208,8 +8207,8 @@ class basic_json
...
@@ -8208,8 +8207,8 @@ class basic_json
/*!
/*!
@brief a template for a random access iterator for the @ref basic_json class
@brief a template for a random access iterator for the @ref basic_json class
This class implements a both iterators (iterator and const_iterator)
This class implements a both iterators (iterator and const_iterator)
for the
for the
@ref basic_json class.
@ref basic_json class.
@note An iterator is called *initialized* when a pointer to a JSON value
@note An iterator is called *initialized* when a pointer to a JSON value
has been set (e.g., by a constructor or a copy assignment). If the
has been set (e.g., by a constructor or a copy assignment). If the
...
@@ -8222,9 +8221,9 @@ class basic_json
...
@@ -8222,9 +8221,9 @@ class basic_json
The iterator that can be moved to point (forward and backward) to any
The iterator that can be moved to point (forward and backward) to any
element in constant time.
element in constant time.
@since version 1.0.0
@since version 1.0.0
, simplified in version 2.0.9
*/
*/
template
<
typename
U
>
template
<
typename
U
>
class
iter_impl
:
public
std
::
iterator
<
std
::
random_access_iterator_tag
,
U
>
class
iter_impl
:
public
std
::
iterator
<
std
::
random_access_iterator_tag
,
U
>
{
{
/// allow basic_json to access private members
/// allow basic_json to access private members
...
@@ -8242,12 +8241,12 @@ class basic_json
...
@@ -8242,12 +8241,12 @@ class basic_json
using
difference_type
=
typename
basic_json
::
difference_type
;
using
difference_type
=
typename
basic_json
::
difference_type
;
/// defines a pointer to the type iterated over (value_type)
/// defines a pointer to the type iterated over (value_type)
using
pointer
=
typename
std
::
conditional
<
std
::
is_const
<
U
>::
value
,
using
pointer
=
typename
std
::
conditional
<
std
::
is_const
<
U
>::
value
,
typename
basic_json
::
const_pointer
,
typename
basic_json
::
const_pointer
,
typename
basic_json
::
pointer
>::
type
;
typename
basic_json
::
pointer
>::
type
;
/// defines a reference to the type iterated over (value_type)
/// defines a reference to the type iterated over (value_type)
using
reference
=
typename
std
::
conditional
<
std
::
is_const
<
U
>::
value
,
using
reference
=
typename
std
::
conditional
<
std
::
is_const
<
U
>::
value
,
typename
basic_json
::
const_reference
,
typename
basic_json
::
const_reference
,
typename
basic_json
::
reference
>::
type
;
typename
basic_json
::
reference
>::
type
;
/// the category of the iterator
/// the category of the iterator
using
iterator_category
=
std
::
bidirectional_iterator_tag
;
using
iterator_category
=
std
::
bidirectional_iterator_tag
;
...
@@ -8288,19 +8287,19 @@ class basic_json
...
@@ -8288,19 +8287,19 @@ class basic_json
}
}
/*
/*
Use operator
const_iterator instead of
Use operator
`const_iterator` instead of `const_iterator(const iterator&
const_iterator(const iterator& other) noexcept
other) noexcept` to avoid two class definitions for @ref iterator and
to avoid two class definitions for iterator and
const_iterator.
@ref
const_iterator.
This function is only called if this class is an
iterator.
This function is only called if this class is an
@ref iterator. If this
If this class is a
const_iterator this function is not called.
class is a @ref
const_iterator this function is not called.
*/
*/
operator
const_iterator
()
const
operator
const_iterator
()
const
{
{
const_iterator
ret
;
const_iterator
ret
;
if
(
m_object
)
if
(
m_object
)
{
{
ret
.
m_object
=
m_object
;
ret
.
m_object
=
m_object
;
ret
.
m_it
=
m_it
;
ret
.
m_it
=
m_it
;
}
}
...
...
src/json.hpp.re2c
View file @
f24e4f68
...
@@ -228,6 +228,7 @@ class basic_json
...
@@ -228,6 +228,7 @@ class basic_json
public:
public:
// forward declarations
// forward declarations
template<typename U> class iter_impl;
template<typename Base> class json_reverse_iterator;
template<typename Base> class json_reverse_iterator;
class json_pointer;
class json_pointer;
...
@@ -262,9 +263,9 @@ class basic_json
...
@@ -262,9 +263,9 @@ class basic_json
using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer;
using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer;
/// an iterator for a basic_json container
/// an iterator for a basic_json container
class iterator
;
using iterator = iter_impl<basic_json>
;
/// a const iterator for a basic_json container
/// a const iterator for a basic_json container
class const_iterator
;
using const_iterator = iter_impl<const basic_json>
;
/// a reverse iterator for a basic_json container
/// a reverse iterator for a basic_json container
using reverse_iterator = json_reverse_iterator<typename basic_json::iterator>;
using reverse_iterator = json_reverse_iterator<typename basic_json::iterator>;
/// a const reverse iterator for a basic_json container
/// a const reverse iterator for a basic_json container
...
@@ -8206,8 +8207,8 @@ class basic_json
...
@@ -8206,8 +8207,8 @@ class basic_json
/*!
/*!
@brief a template for a random access iterator for the @ref basic_json class
@brief a template for a random access iterator for the @ref basic_json class
This class implements a both iterators (iterator and const_iterator)
This class implements a both iterators (iterator and const_iterator)
for the
for the
@ref basic_json class.
@ref basic_json class.
@note An iterator is called *initialized* when a pointer to a JSON value
@note An iterator is called *initialized* when a pointer to a JSON value
has been set (e.g., by a constructor or a copy assignment). If the
has been set (e.g., by a constructor or a copy assignment). If the
...
@@ -8220,9 +8221,9 @@ class basic_json
...
@@ -8220,9 +8221,9 @@ class basic_json
The iterator that can be moved to point (forward and backward) to any
The iterator that can be moved to point (forward and backward) to any
element in constant time.
element in constant time.
@since version 1.0.0
@since version 1.0.0
, simplified in version 2.0.9
*/
*/
template
<typename U>
template<typename U>
class iter_impl : public std::iterator<std::random_access_iterator_tag, U>
class iter_impl : public std::iterator<std::random_access_iterator_tag, U>
{
{
/// allow basic_json to access private members
/// allow basic_json to access private members
...
@@ -8240,12 +8241,12 @@ class basic_json
...
@@ -8240,12 +8241,12 @@ class basic_json
using difference_type = typename basic_json::difference_type;
using difference_type = typename basic_json::difference_type;
/// defines a pointer to the type iterated over (value_type)
/// defines a pointer to the type iterated over (value_type)
using pointer = typename std::conditional<std::is_const<U>::value,
using pointer = typename std::conditional<std::is_const<U>::value,
typename basic_json::const_pointer,
typename basic_json::const_pointer,
typename basic_json::pointer>::type;
typename basic_json::pointer>::type;
/// defines a reference to the type iterated over (value_type)
/// defines a reference to the type iterated over (value_type)
using reference = typename std::conditional<std::is_const<U>::value,
using reference = typename std::conditional<std::is_const<U>::value,
typename basic_json::const_reference,
typename basic_json::const_reference,
typename basic_json::reference>::type;
typename basic_json::reference>::type;
/// the category of the iterator
/// the category of the iterator
using iterator_category = std::bidirectional_iterator_tag;
using iterator_category = std::bidirectional_iterator_tag;
...
@@ -8286,19 +8287,19 @@ class basic_json
...
@@ -8286,19 +8287,19 @@ class basic_json
}
}
/*
/*
Use operator
const_iterator instead of
Use operator
`const_iterator` instead of `const_iterator(const iterator&
const_iterator(const iterator& other) noexcept
other) noexcept` to avoid two class definitions for @ref iterator and
to avoid two class definitions for iterator and
const_iterator.
@ref
const_iterator.
This function is only called if this class is an
iterator.
This function is only called if this class is an
@ref iterator. If this
If this class is a
const_iterator this function is not called.
class is a @ref
const_iterator this function is not called.
*/
*/
operator const_iterator() const
operator const_iterator() const
{
{
const_iterator ret;
const_iterator ret;
if (m_object)
if (m_object)
{
{
ret.m_object = m_object;
ret.m_object = m_object;
ret.m_it = m_it;
ret.m_it = m_it;
}
}
...
...
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