plist::ArrayOf< PO, Alloc > Class Template Reference#include <plistCollections.h>
Inheritance diagram for plist::ArrayOf< PO, Alloc >:
[legend]List of all members.
Detailed Description
template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase>::value_conversion>
class plist::ArrayOf< PO, Alloc >
A collection of plist objects, similar to a Dictionary, but no keys -- order matters!, see plist::Array.
You can add or set entries by a quite a few variations on addEntry() and setEntry(). Basically these boil down to either:
- pass a pointer to an ObjectBase or directly pass a primitive value (int, float, char, etc.), in which case the Array will assume management of the corresponding ObjectBase instance (freeing the memory region when removed)
- pass a reference to an ObjectBase, in which case you retain control over the object's allocation
You have probably noticed this is a templated class -- you can provide any of the ObjectBase subclasses to restrict the storage to that particular type, which will make life easier when retrieving objects since their type will be known.
However, if you want an Array of mixed types, you can pass ObjectBase itself for the template parameter, and you can then insert any combination of the plist types into the same array. For convenience, a plist::Array typedef is provided which does exactly this.
So plist::Array can handle any mixture of types, whereas plist::ArrayOf<PO> will only accept the plist objects of type PO (or their subclasses). The Alloc template argument allows you to define how new string values will be handled from ArrayBase. An array which accepts a mixture would probably want an allocator of Primitive<std::string>, whereas a type-specific array would use the default PO allocator.
Definition at line 461 of file plistCollections.h.
|
Public Types |
|
typedef std::vector< PO * > | storage_t |
| | shorthand for the type of the storage
|
|
typedef storage_t::iterator | iterator |
| | shorthand for iterators to be returned
|
|
typedef storage_t::const_iterator | const_iterator |
| | shorthand for iterators to be returned
|
Public Member Functions |
|
| ArrayOf () |
| | constructor
|
|
| ArrayOf (bool growable) |
| | constructor
|
|
| ArrayOf (const ArrayOf &d) |
| | copy constructor (don't assign listeners)
|
|
ArrayOf & | operator= (const ArrayOf &d) |
| | assignment (don't assign listeners); subclass should call fireEntriesChanged after calling this (and updating its own storage)
|
|
| ~ArrayOf () |
| | destructor
|
|
virtual void | addEntry (PO &val, const std::string &comment="") |
| | replaces previous entry at the specified index, which must represent an integer value less than or equal to the current array size
|
|
virtual void | addEntry (PO *val, const std::string &comment="") |
| | replaces previous entry at the specified index, which must represent an integer value less than or equal to the current array size
|
|
virtual void | setEntry (size_t index, PO &val, bool warnExists=false) |
| | replaces previous entry at the specified index, which must be less than or equal to the current array size
|
|
virtual void | addEntry (size_t index, PO &val, const std::string &comment="") |
| | replaces previous entry at the specified index, which must be less than or equal to the current array size
|
|
virtual void | setEntry (size_t index, PO *val, bool warnExists=false) |
| | replaces previous entry at the specified index, which must be less than or equal to the current array size; control of (de)allocation will be assumed by the Array
|
|
virtual void | addEntry (size_t index, PO *val, const std::string &comment="") |
| | replaces previous entry at the specified index, which must be less than or equal to the current array size; control of (de)allocation will be assumed by the Array
|
|
PO & | getEntry (size_t index) const |
| | return the value at position index, which must exist (no range checking)
|
|
PO & | operator[] (size_t index) const |
| | return the value at position index, which must exist (no range checking, equivalent to getEntry(index))
|
|
const_iterator | begin () const |
| | return an STL const_iterator to the first entry
|
|
const_iterator | end () const |
| | return the one-past-end const_iterator
|
|
virtual bool | canContain (const ObjectBase &obj) |
| | returns true if the Collection subclass allows storage of the argument
|
|
virtual ArrayOf * | clone () const __attribute__((warn_unused_result)) |
| | clone implementation for Array
|
Protected Member Functions |
|
virtual bool | loadXMLNode (size_t index, xmlNode *val, const std::string &comment) |
| | called with each node being loaded so subclass can handle appropriately
|
The documentation for this class was generated from the following file:
|