|
BDE 4.14.0 Production release
|
#include <bdljsn_json.h>
Public Types | |
| typedef Elements::iterator | Iterator |
| typedef Elements::const_iterator | ConstIterator |
| typedef Elements::value_type | value_type |
| typedef Elements::reference | reference |
| typedef Elements::const_reference | const_reference |
| typedef Elements::iterator | iterator |
| typedef Elements::const_iterator | const_iterator |
| typedef Elements::difference_type | difference_type |
| typedef Elements::size_type | size_type |
Public Member Functions | |
| BSLMF_NESTED_TRAIT_DECLARATION (JsonArray, bslma::UsesBslmaAllocator) | |
| BSLMF_NESTED_TRAIT_DECLARATION (JsonArray, bslmf::IsBitwiseMoveable) | |
| BSLMF_NESTED_TRAIT_DECLARATION (JsonArray, bdlb::HasPrintMethod) | |
| JsonArray () | |
| JsonArray (bslma::Allocator *basicAllocator) | |
| JsonArray (const JsonArray &original, bslma::Allocator *basicAllocator=0) | |
| JsonArray (bslmf::MovableRef< JsonArray > original) BSLS_KEYWORD_NOEXCEPT | |
| JsonArray (bslmf::MovableRef< JsonArray > original, bslma::Allocator *basicAllocator) | |
| template<class INPUT_ITERATOR > | |
| JsonArray (INPUT_ITERATOR first, INPUT_ITERATOR last, bslma::Allocator *basicAllocator=0) | |
| JsonArray & | operator= (const JsonArray &rhs) |
| JsonArray & | operator= (bslmf::MovableRef< JsonArray > rhs) |
| Json & | operator[] (bsl::size_t index) |
| template<class INPUT_ITERATOR > | |
| void | assign (INPUT_ITERATOR first, INPUT_ITERATOR last) |
| Iterator | begin () |
| Iterator | end () |
| Json & | front () |
| Json & | back () |
| void | clear () |
| Iterator | erase (bsl::size_t index) |
| Iterator | erase (ConstIterator position) |
| Iterator | erase (ConstIterator first, ConstIterator last) |
| Iterator | insert (bsl::size_t index, const Json &json) |
| Iterator | insert (bsl::size_t index, bslmf::MovableRef< Json > json) |
| template<class INPUT_ITERATOR > | |
| Iterator | insert (bsl::size_t index, INPUT_ITERATOR first, INPUT_ITERATOR last) |
| Iterator | insert (ConstIterator position, const Json &json) |
| Iterator | insert (ConstIterator position, bslmf::MovableRef< Json > json) |
| template<class INPUT_ITERATOR > | |
| Iterator | insert (ConstIterator position, INPUT_ITERATOR first, INPUT_ITERATOR last) |
| void | popBack () |
| void | pushBack (const Json &json) |
| void | pushBack (bslmf::MovableRef< Json > json) |
| void | resize (bsl::size_t count) |
| void | resize (bsl::size_t count, const Json &json) |
| void | swap (JsonArray &other) |
| const Json & | operator[] (bsl::size_t index) const |
| ConstIterator | begin () const BSLS_KEYWORD_NOEXCEPT |
| ConstIterator | cbegin () const BSLS_KEYWORD_NOEXCEPT |
| ConstIterator | end () const BSLS_KEYWORD_NOEXCEPT |
| ConstIterator | cend () const BSLS_KEYWORD_NOEXCEPT |
| const Json & | front () const |
| const Json & | back () const |
| bool | empty () const |
Return true if this JsonArray has size 0, and false otherwise. | |
| bsl::size_t | size () const |
Return the number of elements in this JsonArray. | |
| bslma::Allocator * | allocator () const BSLS_KEYWORD_NOEXCEPT |
| Return the allocator used by this object to allocate memory. | |
| bsl::size_t | maxSize () const BSLS_KEYWORD_NOEXCEPT |
| bsl::ostream & | print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const |
Friends | |
| bool | operator== (const JsonArray &, const JsonArray &) |
| bool | operator!= (const JsonArray &, const JsonArray &) |
| template<class HASHALG > | |
| void | hashAppend (HASHALG &, const JsonArray &) |
| void | swap (JsonArray &, JsonArray &) |
This type is designed to replicate much of the standard sequence container interface, eliding interfaces that are less relevant for a non-generic container. Note that a bsl::vector is chosen for the implementation because our implementation permits the element type to be incomplete (when just spelling the type name).
See bdljsn_json
|
inline |
|
inlineexplicit |
Create an empty JsonArray. Optionally specify a basicAllocator used to supply memory. If basicAllocator is not specified, the currently installed default allocator is used.
|
inline |
|
inline |
Create a JsonArray having the same value as the specified original object by moving (in constant time) the contents of original to the new JsonArray object. The allocator associated with original is propagated for use in the newly-created JsonArray object. original is left in a valid but unspecified state.
|
inline |
Create a JsonArray having the same value as the specified original object that uses the specified basicAllocator to supply memory. The contents of original are moved (in constant time) to the new JsonArray object if basicAllocator == original.allocator(), and are move-inserted (in linear time) using basicAllocator otherwise. original is left in a valid but unspecified state.
|
inline |
Create a JsonArray and insert (in order) each Json object in the range starting at the specified first element, and ending immediately before the specified last element. Optionally specify basicAllocator used to supply memory. If basicAllocator is not specified, the currently installed default allocator is used. Throw bsl::length_error if the number of elements in [first .. last) exceeds the value returned by the method maxSize. The (template parameter) type INPUT_ITERATOR shall meet the requirements of an input iterator defined in the c++11 standard [24.2.3] providing access to values of a type convertible to Json, and Json must be emplace-constructible form *i, where i is a dereferenceable iterator in the range [first .. last). The behavior is undefined unless first and last refer to a range of valid values where first is at a position at or before last.
|
inline |
|
inline |
Assign to this object the value resulting from first clearing this JsonArray and then inserting (in order) each Json object in the range starting at the specified first element, and ending immediately before the specified last element. If an exception is thrown, *this is left in a valid but unspecified state. Throw bsl::length_error if distance(first,last) > maxSize(). The (template parameter) type INPUT_ITERATOR shall meet the requirements of an input iterator defined in the c++11 standard [24.2.3] providing access to values of a type convertible to Json, and Json must be emplace-constructible form *i, where i is a dereferenceable iterator in the range [first .. last). The behavior is undefined unless first and last refer to a range of valid values where first is at a position at or before last.
|
inline |
|
inline |
|
inline |
|
inline |
| bdljsn::JsonArray::BSLMF_NESTED_TRAIT_DECLARATION | ( | JsonArray | , |
| bdlb::HasPrintMethod | |||
| ) |
| bdljsn::JsonArray::BSLMF_NESTED_TRAIT_DECLARATION | ( | JsonArray | , |
| bslma::UsesBslmaAllocator | |||
| ) |
| bdljsn::JsonArray::BSLMF_NESTED_TRAIT_DECLARATION | ( | JsonArray | , |
| bslmf::IsBitwiseMoveable | |||
| ) |
|
inline |
|
inline |
Return the past-the-end iterator providing non-modifiable access to this JsonArray.
|
inline |
|
inline |
|
inline |
Return the past-the-end iterator providing modifiable access to this JsonArray.
|
inline |
|
inline |
Remove from this JsonArray the element at the specified index, and return an iterator providing modifiable access to the element immediately following the removed element, or the position returned by the method end if the removed element was the last in the sequence. The behavior is undefined unless index is in the range [0 .. size()).
|
inline |
Remove from this JsonArray the sequence of elements starting at the specified first position and ending before the specified last position, and return an iterator providing modifiable access to the element immediately following the last removed element, or the position returned by the method end if the removed elements were last in the sequence. The behavior is undefined unless first is an iterator in the range [cbegin() .. cend()] (both endpoints included) and last is an iterator in the range [first .. cend()] (both endpoints included).
|
inline |
Remove from this JsonArray the element at the specified position, and return an iterator providing modifiable access to the element immediately following the removed element, or the position returned by the method end if the removed element was the last in the sequence. The behavior is undefined unless position is an iterator in the range [cbegin() .. cend()).
|
inline |
|
inline |
|
inline |
Insert at the specified index in this JsonArray the specified move-insertable json, and return an iterator referring to the newly inserted element. json is left in a valid but unspecified state. If an exception is thrown, this is unaffected. Throw bsl::length_error if size() == maxSize(). The behavior is undefined unless index is in the range [0 .. size()] (both endpoints included).
|
inline |
Insert at the specified index in this JsonArray a copy of the specified json, and return an iterator referring to the newly inserted element. If an exception is thrown, *this is unaffected. Throw bsl::length_error if size() == maxSize(). The behavior is undefined unless index is in the range [0 .. size()].
|
inline |
Insert at the specified index in this JsonArray the values in the range starting at the specified first element, and ending immediately before the specified last element. Return an iterator referring to the first newly inserted element. If an exception is thrown, *this is unaffected. Throw bsl::length_error if size() + distance(first, last) > maxSize(). The (template parameter) type INPUT_ITERATOR shall meet the requirements of an input iterator defined in the C++11 standard [24.2.3] providing access to values of a type convertible to Json, and Json must be emplace-constructible from *i into this JsonArray, wherei' is a dereferenceable iterator in the range [first .. last). The behavior is undefined unless index is in the range [0 .. size()] (both endpoints included), and first and last refer to a range of valid values where first is at a position at or before last.
|
inline |
Insert at the specified position in this JsonArray the specified move-insertable json, and return an iterator referring to the newly inserted element. json is left in a valid but unspecified state. If an exception is thrown, this is unaffected. Throw bsl::length_error if size() == maxSize(). The behavior is undefined unless position is an iterator in the range [begin() .. end()] (both endpoints included).
|
inline |
Insert at the specified position in this JsonArray a copy of the specified json, and return an iterator referring to the newly inserted element. If an exception is thrown, *this is unaffected. Throw bsl::length_error if size() == maxSize(). The behavior is undefined unless position is an iterator in the range [begin() .. end()] (both endpoints included).
|
inline |
Insert at the specified position in this JsonArray the values in the range starting at the specified first element, and ending immediately before the specified last element. Return an iterator referring to the first newly inserted element. If an exception is thrown, *this is unaffected. Throw bsl::length_error if size() + distance(first, last) > maxSize(). The (template parameter) type INPUT_ITERATOR shall meet the requirements of an input iterator defined in the C++11 standard [24.2.3] providing access to values of a type convertible to value_type, and value_type must be emplace-constructible from *i into this JsonArray, where i is a dereferenceable iterator in the range [first .. last). The behavior is undefined unless position is an iterator in the range [begin() .. end()] (both endpoints included), and first and last refer to a range of valid values where first is at a position at or before last.
|
inline |
Return a theoretical upper bound on the largest number of elements that this JsonArray could possibly hold. Note that there is no guarantee that the JsonArray can successfully grow to the returned size, or even close to that size without running out of resources. Also note that requests to create a JsonArray longer than this number of elements are guaranteed to raise a bsl::length_error exception.
|
inline |
Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object. The contents of rhs are moved (in constant time) to this JsonArray if allocator() == rhs.allocator(); otherwise, all elements in this JsonArray are either destroyed or move-assigned to and each additional element in rhs is move-inserted into this JsonArray. rhs is left in a valid but unspecified state.
Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object. If an exception is thrown, *this is left in a valid but unspecified state.
|
inline |
|
inline |
|
inline |
| bsl::ostream & bdljsn::JsonArray::print | ( | bsl::ostream & | stream, |
| int | level = 0, |
||
| int | spacesPerLevel = 4 |
||
| ) | const |
Write the value of this object to the specified output stream in a human-readable format, and return a reference to stream. Optionally specify an initial indentation level, whose absolute value is incremented recursively for nested objects. If level is specified, optionally specify spacesPerLevel, whose absolute value indicates the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect. Note that this human-readable format is not fully specified, and can change without notice.
|
inline |
|
inline |
|
inline |
Change the size of this JsonArray to the specified count. If count < size(), the elements in the range [count .. size()) are erased, and this function does not throw. If count > size(), the (newly created) elements in the range [size() .. count) are default-constructed Json objects, and if an exception is thrown, *this is unaffected. Throw bsl::length_error if count > maxSize().
|
inline |
Change the size of this JsonArray to the specified count, inserting copies of the specified json at the end if count > size(). If count < size(), the elements in the range [count .. size()) are erased json is ignored, and this method does not throw. If count > size() and an exception is thrown, *this is unaffected. Throw bsl::length_error if count > maxSize().
|
inline |
|
inline |
Exchange the value of this object with that of the specified other object. If an exception is thrown, both objects are left in valid but unspecified states. This operation guarantees O[1] complexity. The behavior is undefined unless this object was created with the same allocator as other.
|
friend |
Invoke the specified hashAlg on the attributes of the specified object.
Return false if the specified lhs and rhs objects have the same value, and true otherwise. Two JsonArray objects lhs and rhs have the same value if they have the same number of elements, and each element in the ordered sequence of elements of lhs has the same value as the corresponding element in the ordered sequence of elements of rhs.
Return true if the specified lhs and rhs objects have the same value, and false otherwise. Two JsonArray objects lhs and rhs have the same value if they have the same number of elements, and each element in the ordered sequence of elements of lhs has the same value as the corresponding element in the ordered sequence of elements of rhs.
Exchange the value of the specified a JsonArray with that of the specified b JsonArray. This function provides the no-throw exception-safety guarantee. This operation has O[1] complexity if a was created with the same allocator as b; otherwise, it has O[n+m] complexity, where n and m are the number of elements in a and b, respectively.