Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

plist::Collection Class Reference

#include <plistCollections.h>

Inheritance diagram for plist::Collection:

Inheritance graph
[legend]
List of all members.

Detailed Description

Provides a common base class for the collection-oriented primitives, Dictionary, Map, Array, and Vector.

Definition at line 13 of file plistCollections.h.

Public Member Functions

virtual void addCollectionListener (CollectionListener *l)
 get notified of changes; be sure to call removeCollectionListener() before destructing l!
virtual void removeCollectionListener (CollectionListener *l)
 no longer take notification of changes to this object's value
virtual bool isCollectionListener (CollectionListener *l)
 test if l is currently registered as a listener
virtual void setEntry (const std::string &name, ObjectBase &val, bool warnExists=false)=0
 insert a new entry to the dictionary, with key name and value val (replaces any previous entry by same name, but gives a warning)
virtual void addEntry (const std::string &name, ObjectBase &val, const std::string &comment="")=0
 insert a new entry to the dictionary, with key name and value val (replaces any previous entry by same name, but gives a warning)
virtual void setEntry (const std::string &name, ObjectBase *val, bool warnExists=false)=0
 insert a new entry to the dictionary, with key name and value val, control of deallocation given to collection
virtual void addEntry (const std::string &name, ObjectBase *val, const std::string &comment="")=0
 insert a new entry to the dictionary, with key name and value val, control of deallocation given to collection
virtual void removeEntry (const std::string &name)=0
 remove the entry with key name
virtual ObjectBasegetEntry (const std::string &name) const =0
 return the value of the key name, or NULL if it doesn't exist
virtual ObjectBaseoperator[] (const std::string &name) const
 return the value of the key name, or NULL if it doesn't exist (equivalent to getEntry(name))
virtual void clear ()=0
 remove all entries in one fell swoop
virtual void setComment (const std::string &name, const std::string &comment)=0
 replaces previous comment for name, or adds it if it doesn't already exist (can preceed actual entry!)
virtual const std::string & getComment (const std::string &name) const =0
 returns comment retrieved from loaded file, or any subsequent call to setComment
void setUnusedWarning (bool b)
 set warnUnused
bool getUnusedWarning ()
 returns warnUnused
virtual bool getTrimExtraLoad () const
 returns trimExtraLoad
virtual bool getTrimExtraSave () const
 returns trimExtraSave
virtual void setTrimExtra (bool trim)
 sets trimExtraLoad and trimExtraSave to the save value
virtual void setTrimExtra (bool trimLoad, bool trimSave)
 sets trimExtraLoad and trimExtraSave

Protected Member Functions

 Collection (bool bl, bool bs)
 constructor
 Collection (const Collection &d)
 copy constructor (don't assign listeners)
Collectionoperator= (const Collection &d)
 assignment (don't assign listeners); subclass should call fireEntriesChanged after calling this (and updating it storage)
 ~Collection ()
 destructor
virtual void fireEntryAdded (ObjectBase &val)
 run through collectionListeners, calling CollectionListener::plistCollectionEntryAdded(*this,val)
virtual void fireEntryRemoved (ObjectBase &val)
 run through collectionListeners, calling CollectionListener::plistCollectionEntryRemoved(*this,val)
virtual void fireEntriesChanged ()
 run through collectionListeners, calling CollectionListener::plistCollectionEntriesChanged(*this)
virtual unsigned int getLongestKeyLen () const =0
 return the length of the longest key for formatting purposes

Static Protected Member Functions

static unsigned int getLongestKeyLenOther (const Collection &c)
 a forwarding function to allow recursive flow of control (gets around not being able to call protected functions on non-this objects)
static const std::string & Collection::emptyStr ()
 when an empty string is needed for not found items
static const std::string & Collection::subCollectionSep ()
 defines separator between sub-collections

Protected Attributes

std::list< CollectionListener * > * collectionListeners
 stores a list of the current listeners
bool warnUnused
 if true (the default) loadXML will give warnings if there are unused entries in the node it is passed (can only happen if trimExtraLoad is false), or extra values in a file being saved into (can only happen if trimExtraSave is false)
bool trimExtraLoad
 if true, unloaded items in the collection will be removed after a load, and new entries will be created for extras in the source (brings storage into complete sync with input)
bool trimExtraSave
 if true, unsaved items in the destination will be removed after a save (brings output XML tree into complete sync with storage)


Constructor & Destructor Documentation

plist::Collection::Collection ( bool  bl,
bool  bs 
) [inline, explicit, protected]

constructor

Definition at line 55 of file plistCollections.h.

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

copy constructor (don't assign listeners)

Definition at line 57 of file plistCollections.h.

plist::Collection::~Collection (  )  [protected]

destructor

Definition at line 11 of file plistCollections.cc.


Member Function Documentation

void plist::Collection::addCollectionListener ( CollectionListener l  )  [virtual]

get notified of changes; be sure to call removeCollectionListener() before destructing l!

Definition at line 16 of file plistCollections.cc.

virtual void plist::Collection::addEntry ( const std::string &  name,
ObjectBase val,
const std::string &  comment = "" 
) [pure virtual]

insert a new entry to the dictionary, with key name and value val, control of deallocation given to collection

Implemented in plist::Dictionary, and plist::Array.

virtual void plist::Collection::addEntry ( const std::string &  name,
ObjectBase val,
const std::string &  comment = "" 
) [pure virtual]

insert a new entry to the dictionary, with key name and value val (replaces any previous entry by same name, but gives a warning)

Implemented in plist::Dictionary, and plist::Array.

Referenced by plist::Dictionary::addEntry().

virtual void plist::Collection::clear (  )  [pure virtual]

remove all entries in one fell swoop

Implemented in plist::Dictionary, and plist::Array.

static const std::string& plist::Collection::Collection::emptyStr (  )  [inline, static, protected]

when an empty string is needed for not found items

(defined as a function instead of just a constant member so there's no issues with initialization order)

Definition at line 86 of file plistCollections.h.

Referenced by Collection::emptyStr().

static const std::string& plist::Collection::Collection::subCollectionSep (  )  [inline, static, protected]

defines separator between sub-collections

(defined as a function instead of just a constant member so there's no issues with initialization order)

Definition at line 92 of file plistCollections.h.

void plist::Collection::fireEntriesChanged (  )  [protected, virtual]

run through collectionListeners, calling CollectionListener::plistCollectionEntriesChanged(*this)

Definition at line 66 of file plistCollections.cc.

Referenced by plist::Array::clear(), plist::Dictionary::clear(), and plist::Array::setEntry().

void plist::Collection::fireEntryAdded ( ObjectBase val  )  [protected, virtual]

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

Definition at line 46 of file plistCollections.cc.

Referenced by plist::Array::addEntry(), plist::Dictionary::addEntry(), plist::Array::setEntry(), and plist::Dictionary::setEntry().

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

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

Reimplemented in plist::Dictionary, and plist::Array.

Definition at line 56 of file plistCollections.cc.

virtual const std::string& plist::Collection::getComment ( const std::string &  name  )  const [pure virtual]

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

Implemented in plist::Dictionary, and plist::Array.

virtual ObjectBase* plist::Collection::getEntry ( const std::string &  name  )  const [pure virtual]

return the value of the key name, or NULL if it doesn't exist

Implemented in plist::Dictionary, and plist::Array.

Referenced by operator[]().

virtual unsigned int plist::Collection::getLongestKeyLen (  )  const [protected, pure virtual]

return the length of the longest key for formatting purposes

Implemented in plist::Dictionary, and plist::Array.

Referenced by getLongestKeyLenOther().

static unsigned int plist::Collection::getLongestKeyLenOther ( const Collection c  )  [inline, static, protected]

a forwarding function to allow recursive flow of control (gets around not being able to call protected functions on non-this objects)

Definition at line 75 of file plistCollections.h.

Referenced by plist::Array::getLongestKeyLen(), plist::Dictionary::getLongestKeyLen(), and plist::operator<<().

virtual bool plist::Collection::getTrimExtraLoad (  )  const [inline, virtual]

returns trimExtraLoad

Definition at line 48 of file plistCollections.h.

virtual bool plist::Collection::getTrimExtraSave (  )  const [inline, virtual]

returns trimExtraSave

Definition at line 49 of file plistCollections.h.

bool plist::Collection::getUnusedWarning (  )  [inline]

returns warnUnused

Definition at line 46 of file plistCollections.h.

bool plist::Collection::isCollectionListener ( CollectionListener l  )  [virtual]

test if l is currently registered as a listener

Definition at line 37 of file plistCollections.cc.

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

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

Definition at line 59 of file plistCollections.h.

virtual ObjectBase* plist::Collection::operator[] ( const std::string &  name  )  const [inline, virtual]

return the value of the key name, or NULL if it doesn't exist (equivalent to getEntry(name))

Reimplemented in plist::Array.

Definition at line 36 of file plistCollections.h.

void plist::Collection::removeCollectionListener ( CollectionListener l  )  [virtual]

no longer take notification of changes to this object's value

Definition at line 24 of file plistCollections.cc.

virtual void plist::Collection::removeEntry ( const std::string &  name  )  [pure virtual]

remove the entry with key name

Implemented in plist::Dictionary, and plist::Array.

virtual void plist::Collection::setComment ( const std::string &  name,
const std::string &  comment 
) [pure virtual]

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

Implemented in plist::Dictionary, and plist::Array.

virtual void plist::Collection::setEntry ( const std::string &  name,
ObjectBase val,
bool  warnExists = false 
) [pure virtual]

insert a new entry to the dictionary, with key name and value val, control of deallocation given to collection

Implemented in plist::Dictionary, and plist::Array.

virtual void plist::Collection::setEntry ( const std::string &  name,
ObjectBase val,
bool  warnExists = false 
) [pure virtual]

insert a new entry to the dictionary, with key name and value val (replaces any previous entry by same name, but gives a warning)

Implemented in plist::Dictionary, and plist::Array.

virtual void plist::Collection::setTrimExtra ( bool  trimLoad,
bool  trimSave 
) [inline, virtual]

sets trimExtraLoad and trimExtraSave

Definition at line 51 of file plistCollections.h.

virtual void plist::Collection::setTrimExtra ( bool  trim  )  [inline, virtual]

sets trimExtraLoad and trimExtraSave to the save value

Definition at line 50 of file plistCollections.h.

void plist::Collection::setUnusedWarning ( bool  b  )  [inline]

set warnUnused

Definition at line 45 of file plistCollections.h.


Member Data Documentation

if true, unloaded items in the collection will be removed after a load, and new entries will be created for extras in the source (brings storage into complete sync with input)

Definition at line 80 of file plistCollections.h.

Referenced by getTrimExtraLoad(), plist::Array::loadXML(), plist::Dictionary::loadXML(), plist::Array::loadXMLNode(), plist::Dictionary::loadXMLNode(), and setTrimExtra().

if true, unsaved items in the destination will be removed after a save (brings output XML tree into complete sync with storage)

Definition at line 82 of file plistCollections.h.

Referenced by getTrimExtraSave(), plist::Array::saveXML(), plist::Dictionary::saveXML(), and setTrimExtra().

if true (the default) loadXML will give warnings if there are unused entries in the node it is passed (can only happen if trimExtraLoad is false), or extra values in a file being saved into (can only happen if trimExtraSave is false)

Definition at line 78 of file plistCollections.h.

Referenced by getUnusedWarning(), plist::Array::loadXMLNode(), plist::Dictionary::loadXMLNode(), plist::Array::saveXML(), plist::Dictionary::saveXML(), and setUnusedWarning().


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

Tekkotsu v3.0
Generated Wed Oct 4 00:05:23 2006 by Doxygen 1.4.7