class ArrayNode
Inherited from: ValueNode.
Required header: <Eclog/ArrayNode.h>
The ArrayNode abstract class represents an array node in a document tree (See Document).
Name | Description |
---|---|
Element | Provides an interface for accessing an element (value) in the array. |
Iterator |
Provides a STL-style random-access iterator for the array. |
ConstIterator |
Provides a STL-style const random-access iterator for the array. |
Name | Description |
---|---|
clear | Removes all elements. |
empty | Checks if this array is empty. |
size | Returns the number of elements. |
begin | Returns an iterator to the first element. |
end | Returns an iterator to the past-the-end element. |
first | Gets the first element. |
last | Gets the last element. |
indexOf | Gets the index of the specified element. |
at | Gets an element by index. |
getValue | Gets a value by index. |
getNull | Gets a null value by index. |
getBoolean | Gets a Boolean value by index. |
getString | Gets a string value by index. |
getNumber | Gets a number value by index. |
getObject | Gets an object value by index. |
getArray | Gets an array value by index. |
append | Inserts an element at the end. |
insert | Inserts an element before the given position. |
remove | Removes specified elements. |
assign | Assigns new elements to this array. |
virtual void clear();
Removes all elements.
All iterators and pointers related to this array are invalidated.
Linear in the number of elements to remove.
virtual bool empty() const;
Checks if this array is empty.
bool
true if this array is empty, false otherwise.
Constant.
virtual size_t size() const;
Returns the number of elements.
size_t
Number of elements in this array.
Constant.
virtual Iterator begin();
virtual ConstIterator begin() const;
Returns an iterator to the first element.
If this array is empty, the returned iterator will be equal to end.
Iterator
Iterator to the first element.
ConstIterator
Iterator to the first element.
Constant.
virtual Iterator end();
virtual ConstIterator end() const;
Returns an iterator to the past-the-end element.
This element acts as a placeholder; attempting to access it results in OutOfRange
fault.
Iterator
Iterator to the past-the-end element.
ConstIterator
Iterator to the past-the-end element.
Constant.
Element& first();
const Element& first() const;
Gets the first element.
Element&
Reference to the first element.
const
Element&
Reference to the first element.
An OutOfRange
fault occurs if this array is empty.
Constant.
Element& last();
const Element& last() const;
Gets the last element.
Element&
Reference to the last element.
const
Element&
Reference to the last element.
An OutOfRange
fault occurs if this array is empty.
Constant.
virtual size_t indexOf(const Element& element) const;
Gets the index of the specified element.
const
Element&
element An element in this array.
size_t
Index of the specified element.
Constant.
virtual Element& at(size_t index);
virtual const Element& at(size_t index) const;
Gets an element by index.
size_t
index Index of the element.
Element&
Reference to the element.
const
Element&
Reference to the element.
An OutOfRange
fault occurs if the specified index is out of bound.
Constant.
ValueNode& getValue(size_t index);
const ValueNode& getValue(size_t index) const;
Gets a value by index.
size_t
index Index of the element.
ValueNode&
Reference to the value node.
const
ValueNode&
Reference to the value node.
An OutOfRange
fault occurs if the specified index is out of bound.
Constant.
NullNode& getNull(size_t index);
const NullNode& getNull(size_t index) const;
BooleanNode& getBoolean(size_t index);
const BooleanNode& getBoolean(size_t index) const;
StringNode& getString(size_t index);
const StringNode& getString(size_t index) const;
NumberNode& getNumber(size_t index);
const NumberNode& getNumber(size_t index) const;
ObjectNode& getObject(size_t index);
const ObjectNode& getObject(size_t index) const;
ArrayNode& getArray(size_t index);
const ArrayNode& getArray(size_t index) const;
Gets a value by index and casts the value to a specific type.
size_t
index Index of the element.
(value node type)&
Reference to the value node.
const
(value node type)&
Reference to the value node.
An OutOfRange
fault occurs if the specified index is out of bound.
A BadCast
fault occurs if the value node is not of the specified type.
Constant.
void append(const Element& element);
void append(const ValueNode& value);
void append(const ValueDesc& value);
Inserts an element at the end.
const
Element&
element The element to be inserted.
const
ValueNode&
value The value to be inserted.
const
ValueDesc&
desc The description of the value to be inserted.
If an error occurs, this array remains untouched.
If a reallocation happens, all iterators related to this array are invalidated.
Amortized constant.
virtual Iterator insert(Iterator pos, const Element& element);
virtual Iterator insert(Iterator pos, const ValueNode& value);
virtual Iterator insert(Iterator pos, const ValueDesc& value);
Inserts an element before the given position.
Iterator
pos Position in this array where the new element will be inserted before.
const
Element&
element The element to be inserted.
const
ValueNode&
value The value to be inserted.
const
ValueDesc&
desc The description of the value to be inserted.
Iterator
Iterator to the inserted element.
If an error occurs, this array remains untouched.
If a reallocation happens, all iterators related to this array are invalidated; otherwise, all iterators to elements before the given position will remain valid.
Constant plus linear in the distance between the given position and the end of the container.
virtual void remove(Iterator pos);
virtual void remove(Iterator first, Iterator last);
virtual void remove(size_t index);
virtual void remove(size_t index, size_t count);
Removes specified elements.
Iterator
pos Iterator to the element to be removed.
Iterator
first, last Range of elements to be removed.
size_t
index Index of the element to be removed.
size_t
count Number of elements to be removed.
Iterators to removed elements and subsequent elements are invalidated.
Linear in the number of elements to be removed.
virtual void assign(const ArrayDesc& desc);
virtual void assign(const ArrayNode& other);
Assigns new elements to this array, replacing its current elements.
const
ArrayDesc&
desc An array description.
const
ArrayNode&
other Another array.
If an error occurs, this array remains untouched.
All iterators related to this array are invalidated.
Linear in the number of elements to be removed and to be copied.