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
- 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
|
| | 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 t_INPUT_ITERATOR > |
| | JsonArray (t_INPUT_ITERATOR first, t_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 t_INPUT_ITERATOR > |
| JsonArray & | assign (t_INPUT_ITERATOR first, t_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) |
| |
| template<class t_INDEX > |
| bsl::enable_if< bsl::is_integral< t_INDEX >::value &&!bsl::is_same< t_INDEX, bool >::value, Iterator >::type | insert (t_INDEX index, const Json &json) |
| |
| template<class t_INDEX > |
| bsl::enable_if< bsl::is_integral< t_INDEX >::value &&!bsl::is_same< t_INDEX, bool >::value, Iterator >::type | insert (t_INDEX index, bslmf::MovableRef< Json > json) |
| |
| template<class t_INDEX , class t_INPUT_ITERATOR > |
| bsl::enable_if< bsl::is_integral< t_INDEX >::value &&!bsl::is_same< t_INDEX, bool >::value, Iterator >::type | insert (t_INDEX index, t_INPUT_ITERATOR first, t_INPUT_ITERATOR last) |
| |
| Iterator | insert (ConstIterator position, const Json &json) |
| |
| Iterator | insert (ConstIterator position, bslmf::MovableRef< Json > json) |
| |
| template<class t_INPUT_ITERATOR > |
| Iterator | insert (ConstIterator position, t_INPUT_ITERATOR first, t_INPUT_ITERATOR last) |
| |
| void | popBack () |
| |
| JsonArray & | pushBack (const Json &json) |
| |
| JsonArray & | pushBack (const JsonArray &array) |
| |
| JsonArray & | pushBack (const JsonObject &object) |
| |
| JsonArray & | pushBack (const JsonNumber &number) |
| |
| JsonArray & | pushBack (bslmf::MovableRef< Json > json) |
| |
| JsonArray & | pushBack (bslmf::MovableRef< JsonArray > array) |
| |
| JsonArray & | pushBack (bslmf::MovableRef< JsonObject > object) |
| |
| JsonArray & | pushBack (bslmf::MovableRef< JsonNumber > number) |
| |
| JsonArray & | pushBack (const JsonNull &value) |
| |
| JsonArray & | pushBack (bool value) |
| |
| JsonArray & | pushBack (int value) |
| |
| JsonArray & | pushBack (unsigned int value) |
| |
| JsonArray & | pushBack (long value) |
| |
| JsonArray & | pushBack (unsigned long value) |
| |
| JsonArray & | pushBack (long long value) |
| |
| JsonArray & | pushBack (unsigned long long value) |
| |
| JsonArray & | pushBack (float value) |
| |
| JsonArray & | pushBack (double value) |
| |
| JsonArray & | pushBack (bdldfp::Decimal64 value) |
| |
| JsonArray & | pushBack (const char *string) |
| |
| JsonArray & | pushBack (const bsl::string_view &string) |
| |
| template<class t_STRING_TYPE > |
| bsl::enable_if< bsl::is_same< t_STRING_TYPE, bsl::string >::value, JsonArray & >::type | pushBack (BSLMF_MOVABLEREF_DEDUCE(t_STRING_TYPE) string) |
| |
| 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 |
| |
| bsl::size_t | size () const |
| |
| bslma::Allocator * | allocator () const BSLS_KEYWORD_NOEXCEPT |
| |
| bsl::size_t | maxSize () const BSLS_KEYWORD_NOEXCEPT |
| |
| bsl::ostream & | print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const |
| |
template<class t_INPUT_ITERATOR >
| bdljsn::JsonArray::JsonArray |
( |
t_INPUT_ITERATOR |
first, |
|
|
t_INPUT_ITERATOR |
last, |
|
|
bslma::Allocator * |
basicAllocator = 0 |
|
) |
| |
|
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 t_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).
- Precondition
- 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.
template<class t_INPUT_ITERATOR >
| JsonArray & bdljsn::JsonArray::assign |
( |
t_INPUT_ITERATOR |
first, |
|
|
t_INPUT_ITERATOR |
last |
|
) |
| |
|
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. Return a non-const reference to this array. 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 t_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).
- Precondition
- 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.
template<class t_INPUT_ITERATOR >
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 t_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).
- Precondition
- 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.
template<class t_INDEX , class t_INPUT_ITERATOR >
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 t_INDEX must be a non-bool integral type. The (template parameter) type t_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, where i is a dereferenceable iterator in the range [first .. last).
- Precondition
- 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.
| 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
- Note that this human-readable format is not fully specified, and can change without notice.