Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

plist::ArrayBase Class Reference

#include <plistCollections.h>

Inheritance diagram for plist::ArrayBase:

List of all members.


Detailed Description

Maintains an array of value, see ArrayOf, and the Array typedef.

You can add or set entries by a quite a few variations on addEntry(), setEntry(), or addValue(). 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

Definition at line 811 of file plistCollections.h.


Public Types

typedef std::vector< ObjectBase * > 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

virtual bool removeEntry (size_t index)
 remove the entry at position index, returns true if something was actually removed (if false, wasn't there to begin with)
ObjectBasegetEntry (size_t index) const
 return the value at position index, which must exist (no range checking)
ObjectBaseoperator[] (size_t index) const
 return the value at position index, which must exist (no range checking, equivalent to getEntry(index))
virtual ObjectBaseresolveEntry (const std::string &path) const
 recursively resolves path interpreted as a series of collection entry names separated by '.', returns NULL if it doesn't exist
virtual void clear ()
 remove all entries in one fell swoop
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 size_t size () const
 return the size of the array
virtual void setComment (size_t index, const std::string &comment)
 replaces previous comment for name, or adds it if it doesn't already exist (can preceed actual entry!)
virtual const std::string & getComment (size_t index) const
 returns comment retrieved from loaded file, or any subsequent call to setComment
virtual void loadXML (xmlNode *node)
 From the name of node, will instantiate a new ObjectBase subclass to load it.
virtual void saveXML (xmlNode *node) const
 subclasses are expected to provide a working implementation
virtual std::string toString () const
 return current value as a string
virtual unsigned int getLongestKeyLen (const regex_t *reg=NULL, unsigned int depth=-1) const
 returns longest key length which matches the regular expression
bool ownsReference (ObjectBase *val) const
 returns true if the specified object will be deallocated when removed from the array

Protected Types

typedef std::map< size_t,
std::string > 
comments_t
 shorthand for the type of comments

Protected Member Functions

 ArrayBase (bool growable)
 constructor
 ArrayBase (const ArrayBase &d)
 copy constructor
ArrayBaseoperator= (const ArrayBase &d)
 assignment
 ~ArrayBase ()
 destructor
virtual void takeObject (size_t index, ObjectBase *obj)
 indicates that the storage implementation should mark this as an externally supplied heap reference, which needs to be deleted on removal/destruction
virtual void fireEntryRemoved (ObjectBase &val)
 run through collectionListeners, calling CollectionListener::plistCollectionEntryRemoved(*this,val)
iterator getSubEntry (const std::string &name, std::string::size_type &seppos)
 returns an entry matching just the prefix
const_iterator getSubEntry (const std::string &name, std::string::size_type &seppos) const
 returns an entry matching just the prefix
virtual void cloneMyRef ()
 called after an assignment or copy to clone the objects in myRef to perform a deep copy
virtual bool loadXMLNode (size_t index, xmlNode *val, const std::string &comment)=0
 called by loadXML(), loads a single xmlNode into a specified position, replacing previous entry if it can't accept the new value (subject to the load/save policy...)

Protected Attributes

storage_t arr
 storage of entries
std::set< ObjectBase * > myRef
 objects which have been handed over to the collection for eventual de-allocation
comments_t comments
 storage of entry comments -- mapping from keys to help text comments for manual editing or user feedback

Friends

std::ostream & operator<< (std::ostream &os, const ArrayBase &d)
 provides textual output

Classes

struct  ConversionTo
 This conversion policy accepts entries of the specified template type, and will try to create new instances of that type constructed from any values which are passed. More...
struct  DeniedValueConversions
 Indicates that no value conversions are allowed. More...
struct  EntryConstraint
struct  IntegerConversion
 Abstract base class to test whether the collection will accept integers (possibly converting to another value type, or storing directly as a [unsigned] long depending on concrete type). More...
struct  RealConversion
 Abstract base class to test whether the collection will accept floating point numbers (possibly converting to another value type, or storing directly as a double depending on concrete type). More...
struct  StringConversion
 Abstract base class to test whether the collection will accept strings (possibly converting to a value type, or storing directly as string depending on concrete type). More...
struct  WrapValueConversion
 This conversion policy accepts any entries of the specified template type, values will be directly wrapped as Primitives so no conversion at all is actually performed. More...

Member Typedef Documentation

typedef std::vector<ObjectBase*> plist::ArrayBase::storage_t

shorthand for the type of the storage

Reimplemented in plist::ArrayOf< PO, Alloc >, and plist::ArrayOf< plist::Primitive< std::string > >.

Definition at line 815 of file plistCollections.h.

typedef storage_t::iterator plist::ArrayBase::iterator

shorthand for iterators to be returned

Definition at line 817 of file plistCollections.h.

typedef storage_t::const_iterator plist::ArrayBase::const_iterator

shorthand for iterators to be returned

Definition at line 819 of file plistCollections.h.

typedef std::map<size_t,std::string> plist::ArrayBase::comments_t [protected]

shorthand for the type of comments

Definition at line 1035 of file plistCollections.h.


Constructor & Destructor Documentation

plist::ArrayBase::ArrayBase ( bool  growable  )  [inline, protected]

constructor

Definition at line 997 of file plistCollections.h.

plist::ArrayBase::ArrayBase ( const ArrayBase d  )  [inline, protected]

copy constructor

Definition at line 999 of file plistCollections.h.

plist::ArrayBase::~ArrayBase (  )  [inline, protected]

destructor

Definition at line 1004 of file plistCollections.h.


Member Function Documentation

bool plist::ArrayBase::removeEntry ( size_t  index  )  [virtual]

remove the entry at position index, returns true if something was actually removed (if false, wasn't there to begin with)

Definition at line 541 of file plistCollections.cc.

Referenced by loadXML().

ObjectBase& plist::ArrayBase::getEntry ( size_t  index  )  const [inline]

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

Reimplemented in plist::ArrayOf< PO, Alloc >, and plist::ArrayOf< plist::Primitive< std::string > >.

Definition at line 966 of file plistCollections.h.

Referenced by resolveEntry().

ObjectBase& plist::ArrayBase::operator[] ( size_t  index  )  const [inline]

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

Reimplemented in plist::ArrayOf< PO, Alloc >, and plist::ArrayOf< plist::Primitive< std::string > >.

Definition at line 968 of file plistCollections.h.

ObjectBase * plist::ArrayBase::resolveEntry ( const std::string &  path  )  const [virtual]

recursively resolves path interpreted as a series of collection entry names separated by '.', returns NULL if it doesn't exist

Implements plist::Collection.

Definition at line 553 of file plistCollections.cc.

void plist::ArrayBase::clear (  )  [virtual]

remove all entries in one fell swoop

Implements plist::Collection.

Definition at line 565 of file plistCollections.cc.

const_iterator plist::ArrayBase::begin (  )  const [inline]

return an STL const_iterator to the first entry

Reimplemented in plist::ArrayOf< PO, Alloc >, and plist::ArrayOf< plist::Primitive< std::string > >.

Definition at line 974 of file plistCollections.h.

const_iterator plist::ArrayBase::end (  )  const [inline]

return the one-past-end const_iterator

Reimplemented in plist::ArrayOf< PO, Alloc >, and plist::ArrayOf< plist::Primitive< std::string > >.

Definition at line 976 of file plistCollections.h.

void plist::ArrayBase::setComment ( size_t  index,
const std::string &  comment 
) [virtual]

replaces previous comment for name, or adds it if it doesn't already exist (can preceed actual entry!)

Definition at line 578 of file plistCollections.cc.

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

const std::string & plist::ArrayBase::getComment ( size_t  index  )  const [virtual]

returns comment retrieved from loaded file, or any subsequent call to setComment

Definition at line 585 of file plistCollections.cc.

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

void plist::ArrayBase::loadXML ( xmlNode node  )  [virtual]

From the name of node, will instantiate a new ObjectBase subclass to load it.

The mapping from node names to actual instantiated types is:

If successful, returns a pointer to a newly allocated region, which the caller is responsible for freeing. If an error occurs, NULL is returned.

Reimplemented from plist::ObjectBase.

Definition at line 593 of file plistCollections.cc.

void plist::ArrayBase::saveXML ( xmlNode node  )  const [virtual]

subclasses are expected to provide a working implementation

Implements plist::ObjectBase.

Definition at line 612 of file plistCollections.cc.

std::string plist::ArrayBase::toString (  )  const [virtual]

return current value as a string

Implements plist::ObjectBase.

Definition at line 716 of file plistCollections.cc.

unsigned int plist::ArrayBase::getLongestKeyLen ( const regex_t *  reg = NULL,
unsigned int  depth = -1 
) const [virtual]

returns longest key length which matches the regular expression

Implements plist::Collection.

Definition at line 722 of file plistCollections.cc.

bool plist::ArrayBase::ownsReference ( ObjectBase val  )  const [inline]

returns true if the specified object will be deallocated when removed from the array

Definition at line 993 of file plistCollections.h.

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

ArrayBase& plist::ArrayBase::operator= ( const ArrayBase d  )  [inline, protected]

assignment

Definition at line 1001 of file plistCollections.h.

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

void plist::ArrayBase::takeObject ( size_t  index,
ObjectBase obj 
) [protected, virtual]

indicates that the storage implementation should mark this as an externally supplied heap reference, which needs to be deleted on removal/destruction

Definition at line 740 of file plistCollections.cc.

Referenced by plist::ArrayOf< PO, Alloc >::addEntry(), and plist::ArrayOf< PO, Alloc >::setEntry().

void plist::ArrayBase::fireEntryRemoved ( ObjectBase val  )  [protected, virtual]

run through collectionListeners, calling CollectionListener::plistCollectionEntryRemoved(*this,val)

Reimplemented from plist::Collection.

Definition at line 744 of file plistCollections.cc.

Referenced by removeEntry().

ArrayBase::iterator plist::ArrayBase::getSubEntry ( const std::string &  name,
std::string::size_type &  seppos 
) [protected]

returns an entry matching just the prefix

Parameters:
[in] name the name being looked up
[out] seppos the position of the separator (sub-collections are separated by '.')
Returns:
iterator of the sub entry

Definition at line 753 of file plistCollections.cc.

Referenced by resolveEntry().

ArrayBase::const_iterator plist::ArrayBase::getSubEntry ( const std::string &  name,
std::string::size_type &  seppos 
) const [protected]

returns an entry matching just the prefix

Parameters:
[in] name the name being looked up
[out] seppos the position of the separator (sub-collections are separated by '.')
Returns:
iterator of the sub entry

Definition at line 767 of file plistCollections.cc.

void plist::ArrayBase::cloneMyRef (  )  [protected, virtual]

called after an assignment or copy to clone the objects in myRef to perform a deep copy

Definition at line 782 of file plistCollections.cc.

virtual bool plist::ArrayBase::loadXMLNode ( size_t  index,
xmlNode val,
const std::string &  comment 
) [protected, pure virtual]

called by loadXML(), loads a single xmlNode into a specified position, replacing previous entry if it can't accept the new value (subject to the load/save policy...)

Implemented in plist::ArrayOf< PO, Alloc >, and plist::ArrayOf< plist::Primitive< std::string > >.

Referenced by loadXML().


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const ArrayBase d 
) [friend]

provides textual output

Definition at line 1417 of file plistCollections.h.


Member Data Documentation

std::set<ObjectBase*> plist::ArrayBase::myRef [protected]

objects which have been handed over to the collection for eventual de-allocation

Definition at line 1032 of file plistCollections.h.

Referenced by clear(), cloneMyRef(), fireEntryRemoved(), plist::ArrayOf< PO, Alloc >::operator=(), plist::ArrayOf< PO, Alloc >::set(), plist::ArrayOf< PO, Alloc >::setEntry(), and takeObject().

storage of entry comments -- mapping from keys to help text comments for manual editing or user feedback

not every key necessarily has a comment!

Definition at line 1038 of file plistCollections.h.

Referenced by clear(), getComment(), removeEntry(), saveXML(), and setComment().


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

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