some cleanup
This commit is contained in:
parent
818ae5a524
commit
623c03bc49
4 changed files with 549 additions and 905 deletions
|
@ -57,6 +57,7 @@ Though it's 2015 already, the support for C++11 is still a bit sparse. Currently
|
|||
- GCC 4.9
|
||||
- GCC 5.0
|
||||
- GCC 5.1
|
||||
- GCC 5.2
|
||||
- Clang 3.4
|
||||
- Clang 3.5
|
||||
- Clang 3.6
|
||||
|
|
|
@ -37,7 +37,7 @@ OPTIMIZE_FOR_FORTRAN = NO
|
|||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
EXTENSION_MAPPING =
|
||||
MARKDOWN_SUPPORT = YES
|
||||
AUTOLINK_SUPPORT = YES
|
||||
AUTOLINK_SUPPORT = NO
|
||||
BUILTIN_STL_SUPPORT = YES
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
|
@ -95,7 +95,7 @@ QUIET = YES
|
|||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_NO_PARAMDOC = YES
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
|
@ -108,7 +108,7 @@ RECURSIVE = NO
|
|||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_SYMBOLS = nlohmann::internals
|
||||
EXCLUDE_SYMBOLS = nlohmann::anonymous_namespace
|
||||
EXAMPLE_PATH = examples
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
|
@ -151,7 +151,7 @@ HTML_COLORSTYLE_HUE = 220
|
|||
HTML_COLORSTYLE_SAT = 100
|
||||
HTML_COLORSTYLE_GAMMA = 80
|
||||
HTML_TIMESTAMP = YES
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
HTML_DYNAMIC_SECTIONS = YES
|
||||
HTML_INDEX_NUM_ENTRIES = 100
|
||||
GENERATE_DOCSET = YES
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
|
|
877
src/json.hpp
877
src/json.hpp
File diff suppressed because it is too large
Load diff
|
@ -103,24 +103,47 @@ default)
|
|||
|
||||
@requirement The class satisfies the following concept requirements:
|
||||
- Basic
|
||||
- [DefaultConstructible](http://en.cppreference.com/w/cpp/concept/DefaultConstructible)
|
||||
- [MoveConstructible](http://en.cppreference.com/w/cpp/concept/MoveConstructible)
|
||||
- [CopyConstructible](http://en.cppreference.com/w/cpp/concept/CopyConstructible)
|
||||
- [MoveAssignable](http://en.cppreference.com/w/cpp/concept/MoveAssignable)
|
||||
- [CopyAssignable](http://en.cppreference.com/w/cpp/concept/CopyAssignable)
|
||||
- [Destructible](http://en.cppreference.com/w/cpp/concept/Destructible)
|
||||
- [DefaultConstructible](http://en.cppreference.com/w/cpp/concept/DefaultConstructible):
|
||||
JSON values can be default constructed. The result will be a JSON null value.
|
||||
- [MoveConstructible](http://en.cppreference.com/w/cpp/concept/MoveConstructible):
|
||||
A JSON value can be constructed from an rvalue argument.
|
||||
- [CopyConstructible](http://en.cppreference.com/w/cpp/concept/CopyConstructible):
|
||||
A JSON value can be copy-constrcuted from an lvalue expression.
|
||||
- [MoveAssignable](http://en.cppreference.com/w/cpp/concept/MoveAssignable):
|
||||
A JSON value van be assigned from an rvalue argument.
|
||||
- [CopyAssignable](http://en.cppreference.com/w/cpp/concept/CopyAssignable):
|
||||
A JSON value can be copy-assigned from an lvalue expression.
|
||||
- [Destructible](http://en.cppreference.com/w/cpp/concept/Destructible):
|
||||
JSON values can be destructed.
|
||||
- Layout
|
||||
- [StandardLayoutType](http://en.cppreference.com/w/cpp/concept/StandardLayoutType)
|
||||
- [StandardLayoutType](http://en.cppreference.com/w/cpp/concept/StandardLayoutType):
|
||||
JSON values have
|
||||
[standard layout](http://en.cppreference.com/w/cpp/language/data_members#Standard_layout):
|
||||
All non-static data members are private and standard layout types, the class
|
||||
has no virtual functions or (virtual) base classes.
|
||||
- Library-wide
|
||||
- [EqualityComparable](http://en.cppreference.com/w/cpp/concept/EqualityComparable)
|
||||
- [LessThanComparable](http://en.cppreference.com/w/cpp/concept/LessThanComparable)
|
||||
- [Swappable](http://en.cppreference.com/w/cpp/concept/Swappable)
|
||||
- [NullablePointer](http://en.cppreference.com/w/cpp/concept/NullablePointer)
|
||||
- [EqualityComparable](http://en.cppreference.com/w/cpp/concept/EqualityComparable):
|
||||
JSON values can be compared with `==`, see @ref
|
||||
operator==(const_reference,const_reference).
|
||||
- [LessThanComparable](http://en.cppreference.com/w/cpp/concept/LessThanComparable):
|
||||
JSON values can be compared with `<`, see @ref
|
||||
operator<(const_reference,const_reference).
|
||||
- [Swappable](http://en.cppreference.com/w/cpp/concept/Swappable):
|
||||
Any JSON lvalue or rvalue of can be swapped with any lvalue or rvalue of
|
||||
other compatible types, using unqualified function call @ref swap().
|
||||
- [NullablePointer](http://en.cppreference.com/w/cpp/concept/NullablePointer):
|
||||
JSON values can be compared against `std::nullptr_t` objects which are used
|
||||
to model the `null` value.
|
||||
- Container
|
||||
- [Container](http://en.cppreference.com/w/cpp/concept/Container)
|
||||
- [ReversibleContainer](http://en.cppreference.com/w/cpp/concept/ReversibleContainer)
|
||||
- [Container](http://en.cppreference.com/w/cpp/concept/Container):
|
||||
JSON values can be used like STL containers and provide iterator access.
|
||||
- [ReversibleContainer](http://en.cppreference.com/w/cpp/concept/ReversibleContainer);
|
||||
JSON values can be used like STL containers and provide reverse iterator
|
||||
access.
|
||||
|
||||
@internal
|
||||
@note ObjectType trick from http://stackoverflow.com/a/9860911
|
||||
@endinternal
|
||||
|
||||
@see RFC 7159 <http://rfc7159.net/rfc7159>
|
||||
*/
|
||||
|
@ -137,8 +160,13 @@ class basic_json
|
|||
{
|
||||
private:
|
||||
/// workaround type for MSVC
|
||||
using basic_json_t =
|
||||
basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType>;
|
||||
using basic_json_t = basic_json<ObjectType,
|
||||
ArrayType,
|
||||
StringType,
|
||||
BooleanType,
|
||||
NumberIntegerType,
|
||||
NumberFloatType,
|
||||
AllocatorType>;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -269,8 +297,11 @@ class basic_json
|
|||
|
||||
@sa array_t
|
||||
*/
|
||||
using object_t =
|
||||
ObjectType<StringType, basic_json, std::less<StringType>, AllocatorType<std::pair<const StringType, basic_json>>>;
|
||||
using object_t = ObjectType<StringType,
|
||||
basic_json,
|
||||
std::less<StringType>,
|
||||
AllocatorType<std::pair<const StringType,
|
||||
basic_json>>>;
|
||||
|
||||
/*!
|
||||
@brief a type for an array
|
||||
|
@ -526,7 +557,7 @@ class basic_json
|
|||
boolean, ///< boolean value
|
||||
number_integer, ///< number value (integer)
|
||||
number_float, ///< number value (floating-point)
|
||||
discarded ///< (internal) indicates the parser callback chose not to keep the value
|
||||
discarded ///< discarded by the the parser callback function
|
||||
};
|
||||
|
||||
|
||||
|
@ -767,7 +798,6 @@ class basic_json
|
|||
value.,basic_json}
|
||||
|
||||
@sa basic_json(std::nullptr_t)
|
||||
@ingroup container
|
||||
*/
|
||||
basic_json() noexcept = default;
|
||||
|
||||
|
@ -1503,9 +1533,7 @@ class basic_json
|
|||
@throw std::bad_alloc if allocation for object, array, or string fails.
|
||||
|
||||
@liveexample{The following code shows an example for the copy
|
||||
constructor.,basic_jsonbasic_json_t}
|
||||
|
||||
@ingroup container
|
||||
constructor.,basic_json__basic_json}
|
||||
*/
|
||||
basic_json(const basic_json& other)
|
||||
: m_type(other.m_type)
|
||||
|
@ -1599,8 +1627,6 @@ class basic_json
|
|||
creates a copy of value `a` which is then swapped with `b`. Finally\, the
|
||||
copy of `a` (which is the null value after the swap) is
|
||||
destroyed.,basic_json__copyassignment}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
reference& operator=(basic_json other) noexcept (
|
||||
std::is_nothrow_move_constructible<value_t>::value and
|
||||
|
@ -1625,8 +1651,6 @@ class basic_json
|
|||
@requirement This function satisfies the Container requirements:
|
||||
- The complexity is linear.
|
||||
- All stored elements are destroyed and all memory is freed.
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
~basic_json()
|
||||
{
|
||||
|
@ -3138,8 +3162,6 @@ class basic_json
|
|||
- The complexity is constant.
|
||||
|
||||
@liveexample{The following code shows an example for @ref begin.,begin}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
iterator begin()
|
||||
{
|
||||
|
@ -3150,7 +3172,6 @@ class basic_json
|
|||
|
||||
/*!
|
||||
@copydoc basic_json::cbegin()
|
||||
@ingroup container
|
||||
*/
|
||||
const_iterator begin() const
|
||||
{
|
||||
|
@ -3173,8 +3194,6 @@ class basic_json
|
|||
- Has the semantics of `const_cast<const basic_json&>(*this).begin()`.
|
||||
|
||||
@liveexample{The following code shows an example for @ref cbegin.,cbegin}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
const_iterator cbegin() const
|
||||
{
|
||||
|
@ -3198,8 +3217,6 @@ class basic_json
|
|||
- The complexity is constant.
|
||||
|
||||
@liveexample{The following code shows an example for @ref end.,end}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
iterator end()
|
||||
{
|
||||
|
@ -3210,7 +3227,6 @@ class basic_json
|
|||
|
||||
/*!
|
||||
@copydoc basic_json::cend()
|
||||
@ingroup container
|
||||
*/
|
||||
const_iterator end() const
|
||||
{
|
||||
|
@ -3233,8 +3249,6 @@ class basic_json
|
|||
- Has the semantics of `const_cast<const basic_json&>(*this).end()`.
|
||||
|
||||
@liveexample{The following code shows an example for @ref cend.,cend}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
const_iterator cend() const
|
||||
{
|
||||
|
@ -3257,8 +3271,6 @@ class basic_json
|
|||
- Has the semantics of `reverse_iterator(end())`.
|
||||
|
||||
@liveexample{The following code shows an example for @ref rbegin.,rbegin}
|
||||
|
||||
@ingroup reversiblecontainer
|
||||
*/
|
||||
reverse_iterator rbegin()
|
||||
{
|
||||
|
@ -3267,7 +3279,6 @@ class basic_json
|
|||
|
||||
/*!
|
||||
@copydoc basic_json::crbegin()
|
||||
@ingroup reversiblecontainer
|
||||
*/
|
||||
const_reverse_iterator rbegin() const
|
||||
{
|
||||
|
@ -3289,8 +3300,6 @@ class basic_json
|
|||
- Has the semantics of `reverse_iterator(begin())`.
|
||||
|
||||
@liveexample{The following code shows an example for @ref rend.,rend}
|
||||
|
||||
@ingroup reversiblecontainer
|
||||
*/
|
||||
reverse_iterator rend()
|
||||
{
|
||||
|
@ -3299,7 +3308,6 @@ class basic_json
|
|||
|
||||
/*!
|
||||
@copydoc basic_json::crend()
|
||||
@ingroup reversiblecontainer
|
||||
*/
|
||||
const_reverse_iterator rend() const
|
||||
{
|
||||
|
@ -3321,8 +3329,6 @@ class basic_json
|
|||
- Has the semantics of `const_cast<const basic_json&>(*this).rbegin()`.
|
||||
|
||||
@liveexample{The following code shows an example for @ref crbegin.,crbegin}
|
||||
|
||||
@ingroup reversiblecontainer
|
||||
*/
|
||||
const_reverse_iterator crbegin() const
|
||||
{
|
||||
|
@ -3344,8 +3350,6 @@ class basic_json
|
|||
- Has the semantics of `const_cast<const basic_json&>(*this).rend()`.
|
||||
|
||||
@liveexample{The following code shows an example for @ref crend.,crend}
|
||||
|
||||
@ingroup reversiblecontainer
|
||||
*/
|
||||
const_reverse_iterator crend() const
|
||||
{
|
||||
|
@ -3388,8 +3392,6 @@ class basic_json
|
|||
|
||||
@liveexample{The following code uses @ref empty to check if a @ref json
|
||||
object contains any elements.,empty}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
bool empty() const noexcept
|
||||
{
|
||||
|
@ -3444,8 +3446,6 @@ class basic_json
|
|||
|
||||
@liveexample{The following code calls @ref size on the different value
|
||||
types.,size}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
size_type size() const noexcept
|
||||
{
|
||||
|
@ -3503,8 +3503,6 @@ class basic_json
|
|||
|
||||
@liveexample{The following code calls @ref max_size on the different value
|
||||
types. Note the output is implementation specific.,max_size}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
size_type max_size() const noexcept
|
||||
{
|
||||
|
@ -3932,8 +3930,6 @@ class basic_json
|
|||
|
||||
@liveexample{The example below shows how JSON arrays can be
|
||||
swapped.,swap__reference}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
void swap(reference other) noexcept (
|
||||
std::is_nothrow_move_constructible<value_t>::value and
|
||||
|
@ -3962,8 +3958,6 @@ class basic_json
|
|||
|
||||
@liveexample{The example below shows how JSON values can be
|
||||
swapped.,swap__array_t}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
void swap(array_t& other)
|
||||
{
|
||||
|
@ -3993,8 +3987,6 @@ class basic_json
|
|||
|
||||
@liveexample{The example below shows how JSON values can be
|
||||
swapped.,swap__object_t}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
void swap(object_t& other)
|
||||
{
|
||||
|
@ -4024,8 +4016,6 @@ class basic_json
|
|||
|
||||
@liveexample{The example below shows how JSON values can be
|
||||
swapped.,swap__string_t}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
void swap(string_t& other)
|
||||
{
|
||||
|
@ -4100,8 +4090,6 @@ class basic_json
|
|||
|
||||
@liveexample{The example demonstrates comparing several JSON
|
||||
types.,operator__equal}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
friend bool operator==(const_reference lhs, const_reference rhs) noexcept
|
||||
{
|
||||
|
@ -4186,8 +4174,6 @@ class basic_json
|
|||
|
||||
@liveexample{The example demonstrates comparing several JSON
|
||||
types.,operator__notequal}
|
||||
|
||||
@ingroup container
|
||||
*/
|
||||
friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
|
||||
{
|
||||
|
@ -4839,7 +4825,7 @@ class basic_json
|
|||
}
|
||||
|
||||
/// return value to compare
|
||||
operator const difference_type () const
|
||||
operator difference_type () const
|
||||
{
|
||||
return m_it;
|
||||
}
|
||||
|
@ -4862,21 +4848,28 @@ class basic_json
|
|||
struct internal_iterator
|
||||
{
|
||||
/// iterator for JSON objects
|
||||
typename object_t::iterator object_iterator;
|
||||
typename object_t::iterator object_iterator = typename object_t::iterator();
|
||||
/// iterator for JSON arrays
|
||||
typename array_t::iterator array_iterator;
|
||||
typename array_t::iterator array_iterator = typename array_t::iterator();
|
||||
/// generic iterator for all other types
|
||||
primitive_iterator_t primitive_iterator;
|
||||
|
||||
// leave the union un-initialized
|
||||
internal_iterator() {}
|
||||
primitive_iterator_t primitive_iterator = primitive_iterator_t();
|
||||
};
|
||||
|
||||
public:
|
||||
/// a const random access iterator for the basic_json class
|
||||
/*!
|
||||
@brief a const random access iterator for the @ref basic_json class
|
||||
|
||||
This class implements a const iterator for the @ref basic_json class. From
|
||||
this class, the @ref iterator class is derived.
|
||||
|
||||
@requirement The class satisfies the following concept requirements:
|
||||
- [RandomAccessIterator](http://en.cppreference.com/w/cpp/concept/RandomAccessIterator):
|
||||
The iterator that can be moved to point (forward and backward) to any
|
||||
element in constant time.
|
||||
*/
|
||||
class const_iterator : public std::iterator<std::random_access_iterator_tag, const basic_json>
|
||||
{
|
||||
// allow basic_json class to access m_it
|
||||
/// allow basic_json to access private members
|
||||
friend class basic_json;
|
||||
|
||||
public:
|
||||
|
@ -5368,7 +5361,16 @@ class basic_json
|
|||
internal_iterator m_it = internal_iterator();
|
||||
};
|
||||
|
||||
/// a random access iterator for the basic_json class
|
||||
/*!
|
||||
@brief a mutable random access iterator for the @ref basic_json class
|
||||
|
||||
@requirement The class satisfies the following concept requirements:
|
||||
- [RandomAccessIterator](http://en.cppreference.com/w/cpp/concept/RandomAccessIterator):
|
||||
The iterator that can be moved to point (forward and backward) to any
|
||||
element in constant time.
|
||||
- [OutputIterator](http://en.cppreference.com/w/cpp/concept/OutputIterator):
|
||||
It is possible to write to the pointed-to element.
|
||||
*/
|
||||
class iterator : public const_iterator
|
||||
{
|
||||
public:
|
||||
|
@ -5490,13 +5492,28 @@ class basic_json
|
|||
}
|
||||
};
|
||||
|
||||
/// a template for a reverse iterator class
|
||||
/*!
|
||||
@brief a template for a reverse iterator class
|
||||
|
||||
@tparam Base the base iterator type to reverse. Valid types are @ref
|
||||
iterator (to create @ref reverse_iterator) and @ref const_iterator (to
|
||||
create @ref const_reverse_iterator).
|
||||
|
||||
@requirement The class satisfies the following concept requirements:
|
||||
- [RandomAccessIterator](http://en.cppreference.com/w/cpp/concept/RandomAccessIterator):
|
||||
The iterator that can be moved to point (forward and backward) to any
|
||||
element in constant time.
|
||||
- [OutputIterator](http://en.cppreference.com/w/cpp/concept/OutputIterator):
|
||||
It is possible to write to the pointed-to element (only if @a Base is
|
||||
@ref iterator).
|
||||
*/
|
||||
template<typename Base>
|
||||
class json_reverse_iterator : public std::reverse_iterator<Base>
|
||||
{
|
||||
public:
|
||||
/// shortcut to the reverse iterator adaptor
|
||||
using base_iterator = std::reverse_iterator<Base>;
|
||||
/// the reference type for the pointed-to element
|
||||
using reference = typename Base::reference;
|
||||
|
||||
/// create reverse iterator from iterator
|
||||
|
@ -6353,7 +6370,6 @@ namespace std
|
|||
{
|
||||
/*!
|
||||
@brief exchanges the values of two JSON objects
|
||||
@ingroup container
|
||||
*/
|
||||
template <>
|
||||
inline void swap(nlohmann::json& j1,
|
||||
|
|
Loading…
Reference in a new issue