Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

plist::ArrayOf< PO, Alloc > Class Template Reference

#include <plistCollections.h>

Inheritance diagram for plist::ArrayOf< PO, Alloc >:

List of all members.


Detailed Description

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::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(), setEntry(), and addValue (via the Alloc conversion policy) 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.

The optional conversion policy template specifies a base class for the dictionary which can control how the dictionary will handle conversions from non-PO-based types.

Definition at line 1067 of file plistCollections.h.


Public Types

typedef ArrayBase::storage_t storage_t

Public Member Functions

 ArrayOf ()
 ArrayOf (typename storage_t::size_type n, const PO &t, bool growable=true)
 constructor
 ArrayOf (const ArrayOf &d)
 copy constructor (don't assign listeners)
ArrayOfoperator= (const ArrayOf &a)
 assignment (don't assign listeners); subclass should call fireEntriesChanged after calling this (and updating its own storage)
virtual void set (const ObjectBase &ob)
 polymorphic assignment (throws std::bad_cast if the assignment is between invalid types, i.e. a primitive and a collection, or different collection types)
virtual void set (const ArrayBase &a)
 handles polymorphic assignment of ArrayBase subclasses, similar to operator=(ArrayOf), but allows conversion of entries
 ~ArrayOf ()
 destructor
virtual void addEntry (PO &val, const std::string &comment="")
 adds a new entry to the end of the array, (de)allocation retained by caller
virtual void addEntry (PO *val, const std::string &comment="")
 adds a new entry to the end of the array, (de)allocation responsibility of array
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 array can store the specified object
virtual ArrayOfclone () 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

Static Protected Member Functions

static PO * allocatePO ()
 allocates a new PO instance, unless PO is an abstract type, in which case a template specialization will throw a bad_cast
static void assignPO (PO &a, const PO &b)
 assigns one PO to another, unless PO is ObjectBase, in which case set() is used (via template specialization)

Member Typedef Documentation

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
typedef ArrayBase::storage_t plist::ArrayOf< PO, Alloc >::storage_t

shorthand for the type of the storage

Reimplemented from plist::ArrayBase.

Definition at line 1074 of file plistCollections.h.


Constructor & Destructor Documentation

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
plist::ArrayOf< PO, Alloc >::ArrayOf (  )  [inline]

constructor

Definition at line 1112 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
plist::ArrayOf< PO, Alloc >::ArrayOf ( typename storage_t::size_type  n,
const PO &  t,
bool  growable = true 
) [inline]

constructor

Definition at line 1114 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
plist::ArrayOf< PO, Alloc >::ArrayOf ( const ArrayOf< PO, Alloc > &  d  )  [inline]

copy constructor (don't assign listeners)

Definition at line 1121 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
plist::ArrayOf< PO, Alloc >::~ArrayOf (  )  [inline]

destructor

Definition at line 1129 of file plistCollections.h.


Member Function Documentation

template<typename PO, typename Alloc>
ArrayOf< PO, Alloc > & plist::ArrayOf< PO, Alloc >::operator= ( const ArrayOf< PO, Alloc > &  a  )  [inline]

assignment (don't assign listeners); subclass should call fireEntriesChanged after calling this (and updating its own storage)

Definition at line 1355 of file plistCollections.h.

Referenced by plist::ArrayOf< PO, Alloc >::set().

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
virtual void plist::ArrayOf< PO, Alloc >::set ( const ObjectBase  )  [inline, virtual]

polymorphic assignment (throws std::bad_cast if the assignment is between invalid types, i.e. a primitive and a collection, or different collection types)

Implements plist::ObjectBase.

Definition at line 1125 of file plistCollections.h.

template<typename PO, typename Alloc>
void plist::ArrayOf< PO, Alloc >::set ( const ArrayBase a  )  [inline, virtual]

handles polymorphic assignment of ArrayBase subclasses, similar to operator=(ArrayOf), but allows conversion of entries

Definition at line 1299 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
virtual void plist::ArrayOf< PO, Alloc >::addEntry ( PO &  val,
const std::string &  comment = "" 
) [inline, virtual]

adds a new entry to the end of the array, (de)allocation retained by caller

Definition at line 1132 of file plistCollections.h.

Referenced by plist::ArrayOf< PO, Alloc >::loadXMLNode(), plist::ArrayOf< PO, Alloc >::operator=(), and plist::ArrayOf< PO, Alloc >::set().

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
virtual void plist::ArrayOf< PO, Alloc >::addEntry ( PO *  val,
const std::string &  comment = "" 
) [inline, virtual]

adds a new entry to the end of the array, (de)allocation responsibility of array

Definition at line 1134 of file plistCollections.h.

template<typename PO, typename Alloc>
void plist::ArrayOf< PO, Alloc >::setEntry ( size_t  index,
PO &  val,
bool  warnExists = false 
) [inline, virtual]

replaces previous entry at the specified index, which must be less than or equal to the current array size

Definition at line 1178 of file plistCollections.h.

Referenced by plist::ArrayOf< PO, Alloc >::loadXMLNode(), plist::ArrayOf< PO, Alloc >::operator=(), and plist::ArrayOf< PO, Alloc >::set().

template<typename PO, typename Alloc>
void plist::ArrayOf< PO, Alloc >::addEntry ( size_t  index,
PO &  val,
const std::string &  comment = "" 
) [inline, virtual]

replaces previous entry at the specified index, which must be less than or equal to the current array size

Definition at line 1194 of file plistCollections.h.

template<typename PO, typename Alloc>
void plist::ArrayOf< PO, Alloc >::setEntry ( size_t  index,
PO *  val,
bool  warnExists = false 
) [inline, virtual]

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

Definition at line 1207 of file plistCollections.h.

template<typename PO, typename Alloc>
void plist::ArrayOf< PO, Alloc >::addEntry ( size_t  index,
PO *  val,
const std::string &  comment = "" 
) [inline, virtual]

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

Definition at line 1231 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
PO& plist::ArrayOf< PO, Alloc >::getEntry ( size_t  index  )  const [inline]

return the value at position index, which must exist (no range checking)

Reimplemented from plist::ArrayBase.

Definition at line 1146 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
PO& plist::ArrayOf< PO, Alloc >::operator[] ( size_t  index  )  const [inline]

return the value at position index, which must exist (no range checking, equivalent to getEntry(index))

Reimplemented from plist::ArrayBase.

Definition at line 1148 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
const_iterator plist::ArrayOf< PO, Alloc >::begin (  )  const [inline]

return an STL const_iterator to the first entry

Reimplemented from plist::ArrayBase.

Definition at line 1151 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
const_iterator plist::ArrayOf< PO, Alloc >::end (  )  const [inline]

return the one-past-end const_iterator

Reimplemented from plist::ArrayBase.

Definition at line 1153 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
virtual bool plist::ArrayOf< PO, Alloc >::canContain ( const ObjectBase obj  )  [inline, virtual]

returns true if the array can store the specified object

Implements plist::Collection.

Definition at line 1156 of file plistCollections.h.

template<typename PO, typename Alloc>
ArrayOf< PO, Alloc > * plist::ArrayOf< PO, Alloc >::clone (  )  const [inline, virtual]

clone implementation for Array

implements the clone function for Array

Implements plist::ObjectBase.

Definition at line 1248 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
static PO* plist::ArrayOf< PO, Alloc >::allocatePO (  )  [inline, static, protected]

allocates a new PO instance, unless PO is an abstract type, in which case a template specialization will throw a bad_cast

Definition at line 1163 of file plistCollections.h.

Referenced by plist::ArrayOf< PO, Alloc >::set().

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
static void plist::ArrayOf< PO, Alloc >::assignPO ( PO &  a,
const PO &  b 
) [inline, static, protected]

assigns one PO to another, unless PO is ObjectBase, in which case set() is used (via template specialization)

Definition at line 1165 of file plistCollections.h.

Referenced by plist::ArrayOf< PO, Alloc >::operator=().

template<typename PO, typename Alloc>
bool plist::ArrayOf< PO, Alloc >::loadXMLNode ( size_t  index,
xmlNode val,
const std::string &  comment 
) [inline, protected, virtual]

called with each node being loaded so subclass can handle appropriately

Implements plist::ArrayBase.

Definition at line 1262 of file plistCollections.h.


The documentation for this class was generated from the following file:

Tekkotsu v4.0
Generated Thu Nov 22 00:58:56 2007 by Doxygen 1.5.4