🎨 cleanup after PR #395
This commit is contained in:
parent
fe00b368ae
commit
f24e4f680e
3 changed files with 37 additions and 36 deletions
|
@ -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!
|
||||||
|
|
||||||
|
|
35
src/json.hpp
35
src/json.hpp
|
@ -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
|
||||||
/// 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
|
||||||
/*!
|
/*!
|
||||||
@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
|
||||||
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
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
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
|
||||||
/*!
|
/*!
|
||||||
@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
|
||||||
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
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue