![]() |
PVL: Parameter Value Language
|
An Array implements a Value that is a list of Values. More...
#include <Value.hh>
Classes | |
class | Depth_Iterator |
A Depth_Iterator is a bidirectional iterator over an Array's Value list and, depth-first, over the Value list of each Array encountered. More... | |
Public Types | |
typedef Value_List::const_iterator | const_iterator |
Identify the iterator for compilers that need help. | |
typedef Depth_Iterator | depth_iterator |
A specialized iterator that descends into Arrays in the Value list. | |
typedef Value_List::iterator | iterator |
Identify the iterator for compilers that need help. | |
typedef Vectal< Value > | Value_List |
Array as a Vectal (vector) of Values. | |
Public Member Functions | |
Array & | add (const Value &value) |
Adds a clone of a Value to the end of the Array's Value list. | |
Array & | add (Value *value) |
Adds a Value to the end of the Array's Value list. | |
Array (const Array &array) | |
Constructs an Array as a copy of another Array. | |
Array (Parser &parser, const Type type=Default_Subtype) | |
Construct an Array from a Parser. | |
Array (const Type type=Default_Subtype) | |
Constructs an empty Array. | |
Array (const Value &value) | |
Constructs an Array from another Value. | |
Array & | base (const int) |
Prevents the base from being changed. | |
Depth_Iterator | begin_depth () |
Gets a Depth_Iterator positioned at the beginning of this Array. | |
Array * | clone () const |
Constructs a clone of this Array. | |
int | compare (const Value &value) const |
This Array is compared to another Value. | |
Array & | copy_in (const Array &array) |
Copies the Value list in an Array into this Array's list. | |
Depth_Iterator | end_depth () |
Gets a Depth_Iterator positioned at the end of this Array. | |
void | entering (Value *value) |
Sets the parent of a Value to this Array. | |
bool | is_Array () const |
Asserts that the Array is an ARRAY Type. | |
bool | is_Sequence () const |
Tests if the Array is a SEQUENCE Type. | |
bool | is_Set () const |
Tests if the Array is a SET Type. | |
Array & | move_in (Array &array) |
Moves the Value list in an Array into this Array's list. | |
operator int () const | |
operator Integer_type () const | |
operator Real_type () const | |
operator String_type () const | |
Array | operator+ (const Value &value) const |
Adds this Array and a Value. | |
Array & | operator+= (const Value &value) |
Adds a Value to this Array. | |
Array & | operator= (const unsigned int value) |
Array & | operator= (const Real_type value) |
Array & | operator= (const Integer_type value) |
Array & | operator= (const int value) |
Array & | operator= (const Value &value) |
Assigns a Value to this Array. | |
Array & | operator= (const Unsigned_Integer_type value) |
Array & | operator= (const char *value) |
Array & | operator= (const String_type &value) |
Value & | operator[] (unsigned int index) |
Gets the Value at an index of the Array list. | |
const Value & | operator[] (unsigned int index) const |
Gets the Value at an index of the Array list. | |
Value * | remove (Value *value) |
Removes a Value from the Array's Value list. | |
Value * | remove (size_type index) |
Removes a Value at an element index of the Array's Value list. | |
Value * | remove (iterator position) |
Removes a Value at an iterator position from the Array's Value list. | |
Value * | remove_depth (Value *value) |
Removes a Value from the Array's Value list or any of its sub-Array ists. | |
void | removing (Value *value) |
Resets the parent of a Value to NULL. | |
size_type | total_size () |
Counts the number of Values in the Array's Value list and, recursively, the number of Values in the Value list of each Array in the list. | |
Array & | type (const Type type_code) |
Sets the specific Array Type. | |
Type | type () const |
Gets the specific Array Type. | |
std::string | type_name () const |
Gets the name string for the Array Type. | |
Static Public Member Functions | |
static Type | default_type () |
Gets the default Type for an Array. | |
static Type | default_type (const int type_code) |
Sets the default Type to use when constructing an Array. |
An Array implements a Value that is a list of Values.
An Array provides for the hierarchical structuring of Values.
The list is provided by subclassing a Vectal of Values. A Vectal is a vector of virtual objects that are stored as pointers but for which reference semantics are offered in the access interface. However, the normal value functionality is also provided by copying (actually cloning) objects into the list and deleting them on removal. An Array ensures that, normally, whenever a Value is entered into its list the parent of the Value is set to the Array. Thus the hierarchical relationships are automatically maintained. Provision is also made for pulling a Value from an Array's list without deleting it, but also automatically resetting its parent to NULL to correctly reflect that it is no longer a member of the Array hierarchy.
In addition to the normal vector interators for traversing an Array's Value list, specialized Depth_Iterators are provided that descend into Arrays encountered in a Value list. They continue iterating the parent list where they left off after completing the interation of a child Array. They also remember the root Array where they started, which is where they will end. These iterators are bidirectional with some random access capabilities.
typedef Vectal<Value> Value_List |
typedef Value_List::iterator iterator |
Identify the iterator for compilers that need help.
Reimplemented from Vectal< Value >.
Identify the iterator for compilers that need help.
Reimplemented from Vectal< Value >.
typedef Depth_Iterator depth_iterator |
A specialized iterator that descends into Arrays in the Value list.
Constructs an empty Array.
type | The Type specification for an Array. This must be either SET or SEQUENCE. |
Construct an Array from a Parser.
The next Value obtained from the Parser is used as the contents of the new Array. If the Parser Value is an Array, then all of its elements are moved into the new Array which is set to the same Type, and the original Array is deleted. Otherwise the Value becomes the only element of the new Array which is set to the specified Type.
parser | The Parser from which to construct the Value. |
type | The default Type of the Array to construct if the Parser does not provide an Array. |
Array* clone | ( | ) | const [inline, virtual] |
Constructs a clone of this Array.
A clone is a copy constructed on the heap.
Implements Value.
References Value::Array.
operator Integer_type | ( | ) | const [virtual] |
Invalid_Argument | An Array can not be cast to a primitive type. |
Implements Value.
operator int | ( | ) | const [virtual] |
Invalid_Argument | An Array can not be cast to a primitive type. |
Implements Value.
operator Real_type | ( | ) | const [virtual] |
Invalid_Argument | An Array can not be cast to a primitive type. |
Implements Value.
operator String_type | ( | ) | const [virtual] |
Invalid_Argument | An Array can not be cast to a primitive type. |
Implements Value.
Array& base | ( | const int | ) | [inline, virtual] |
bool is_Array | ( | ) | const [inline, virtual] |
bool is_Set | ( | ) | const [inline, virtual] |
Tests if the Array is a SET Type.
Reimplemented from Value.
References Value::SET.
bool is_Sequence | ( | ) | const [inline, virtual] |
Tests if the Array is a SEQUENCE Type.
Reimplemented from Value.
References Value::SEQUENCE.
Type type | ( | ) | const [inline, virtual] |
Sets the specific Array Type.
type_code | An Array Type code, which must be one of SET or SEQUENCE. |
Invalid_Argument | if the type_code is not one of the ARRAY Type values. |
std::string type_name | ( | ) | const [inline, virtual] |
static Type default_type | ( | ) | [inline, static] |
Gets the default Type for an Array.
static Type default_type | ( | const int | type_code | ) | [static] |
Sets the default Type to use when constructing an Array.
type_code | An Array Type code, which must be one of SET or SEQUENCE. |
Invalid_Argument | if the type_code is not one of the ARRAY Type values. |
Value& operator[] | ( | unsigned int | index | ) | [inline, virtual] |
const Value& operator[] | ( | unsigned int | index | ) | const [inline, virtual] |
Assigns a Value to this Array.
The Value being assigned must be an Array. Use the add (or push_back) method to add a Value to the Array list.
The existing Value list is set aside without deleting it in case the Value being assigned is contained with this Array. The Value list from the assigned Value is copied into this Array's now empty Value list. The copied Values are cloned in depth. Finally the original Value list is deleted.
value | The Value to be assigned. |
Invalid_Argument | If the assigned Value is not an Array. |
Implements Value.
Array& operator= | ( | const Integer_type | value | ) | [virtual] |
Invalid_Argument | An Array can not be assigned a primitive type. |
Implements Value.
Array& operator= | ( | const Unsigned_Integer_type | value | ) |
Invalid_Argument | An Array can not be assigned a primitive type. |
Array& operator= | ( | const int | value | ) | [inline, virtual] |
Invalid_Argument | An Array can not be assigned a primitive type. |
Implements Value.
References Value::operator=().
Array& operator= | ( | const unsigned int | value | ) | [inline, virtual] |
Invalid_Argument | An Array can not be assigned a primitive type. |
Implements Value.
References Value::operator=().
Invalid_Argument | An Array can not be assigned a primitive type. |
Implements Value.
Array& operator= | ( | const String_type & | value | ) | [virtual] |
Invalid_Argument | An Array can not be assigned a primitive type. |
Implements Value.
Array& operator= | ( | const char * | value | ) | [virtual] |
Invalid_Argument | An Array can not be assigned a primitive type. |
Implements Value.
int compare | ( | const Value & | value | ) | const [virtual] |
This Array is compared to another Value.
An Array always compares greater than other types of Values.
When the other Value is an Array the Value list sizes are compared. If the list sizes are the same then each Value in the list is compared and the first non-equal Values determine the comparison.
value | The Value to be compared against. |
Implements Value.
void entering | ( | Value * | value | ) |
Sets the parent of a Value to this Array.
This method overrides the Vectal's method that is invoked whenever a Value is entered into the Value list. It is not intended for normal use since it affects the logical relationship of Values in an Array hierarchy.
The uniquness of the Value in the path hierachy is ensured; loops are prevented.
value | The Value whose parent is to be changed. |
Invalid_Argument | If the value is in the Array's path; i.e. the Value is already in the parent hierachy of the Array, or is the Array itself. |
void removing | ( | Value * | value | ) |
Resets the parent of a Value to NULL.
This method overrides the Vectal's method that is invoked whenever a Value is removed from the Value list. It is not intended for normal use since it affects the logical relationship of Values in an Array hierarchy.
value | The Value whose parent is to be changed. |
size_type total_size | ( | ) |
Depth_Iterator begin_depth | ( | ) |
Gets a Depth_Iterator positioned at the beginning of this Array.
Depth_Iterator end_depth | ( | ) |
Gets a Depth_Iterator positioned at the end of this Array.