Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

plist::NamedEnumeration< T > Class Template Reference

#include <plist.h>

Inheritance diagram for plist::NamedEnumeration< T >:

Inheritance graph
[legend]
List of all members.

Detailed Description

template<typename T>
class plist::NamedEnumeration< T >

Provides an interface for the use of enumerations in a plist -- you can specify values by either the string name or the corresponding integer value.

Where an array of names is required, you must order the array such that the enumeration value can be used as an index into the array. The 'maxval' parameters should be one above the maximum enumeration -- if your enumeration runs sequentially from 0 to n, max should be the number of enumerations: n+1

Definition at line 635 of file plist.h.

Public Member Functions

 NamedEnumeration ()
 constructor
 NamedEnumeration (const NamedEnumeration &ne)
 copy constructor
 NamedEnumeration (const T &v, const char *const *enumnames, unsigned int maxval)
 constructor, pass initial value, array of strings (the names), and the one-plus-maximum enum value (i.e. the number of enumeration values if they run sequentially from 0)
 NamedEnumeration (const T &v)
 automatic casting from the enumeration
NamedEnumerationoperator= (const T &v)
 assignment from enumeration value (numeric)
NamedEnumerationoperator= (const std::string &v)
 assignment from string
NamedEnumerationoperator= (const NamedEnumeration &ne)
 assignment
const T & operator * () const
 value access
 operator T () const
 automatic casting to the enumeration value
void setNames (const char *const *enumnames, unsigned int maxval)
 (re)set the array of names and one-plus-maximum enum value (i.e. the number of enumeration values if they run sequentially from 0)
const char *const * getNames () const
 returns the array of names previously provided from constructor or setNames()
const char * getName (unsigned int i) const
 returns the name for a particular index
unsigned int getMax () const
 returns the one-past-maximum of enumeration values previously provided to constructor or setNames()
void LoadXML (xmlNode *node)
 This is called when the subclass needs to update its values from those values in the parse tree.
void SaveXML (xmlNode *node) const
 This is called when XMLLoadSave needs to have the subclass update values in the tree currently in memory -- may already be filled out by previous contents.
void set (const std::string &str)
 assign a new value
std::string get () const
 return current value as a string

Protected Member Functions

unsigned int findName (const char *name)
 returns the enum corresponding to name

Protected Attributes

val
 storage of enum value
const char *const * names
 pointer to array of names -- enum value must be able to serve as index for lookup
unsigned int max
 one-plus-maximum enum value, i.e. the number of enum entries if they are ordered sequentially from 0


Constructor & Destructor Documentation

template<typename T>
plist::NamedEnumeration< T >::NamedEnumeration  )  [inline]
 

constructor

Definition at line 637 of file plist.h.

template<typename T>
plist::NamedEnumeration< T >::NamedEnumeration const NamedEnumeration< T > &  ne  )  [inline]
 

copy constructor

Definition at line 638 of file plist.h.

template<typename T>
plist::NamedEnumeration< T >::NamedEnumeration const T &  v,
const char *const *  enumnames,
unsigned int  maxval
[inline]
 

constructor, pass initial value, array of strings (the names), and the one-plus-maximum enum value (i.e. the number of enumeration values if they run sequentially from 0)

Definition at line 639 of file plist.h.

template<typename T>
plist::NamedEnumeration< T >::NamedEnumeration const T &  v  )  [inline]
 

automatic casting from the enumeration

Definition at line 640 of file plist.h.


Member Function Documentation

template<typename T>
unsigned int plist::NamedEnumeration< T >::findName const char *  name  )  [inline, protected]
 

returns the enum corresponding to name

Definition at line 705 of file plist.h.

Referenced by plist::NamedEnumeration< T >::LoadXML(), and plist::NamedEnumeration< T >::set().

template<typename T>
std::string plist::NamedEnumeration< T >::get  )  const [inline, virtual]
 

return current value as a string

Implements plist::PrimitiveBase.

Definition at line 696 of file plist.h.

Referenced by plist::NamedEnumeration< T >::SaveXML().

template<typename T>
unsigned int plist::NamedEnumeration< T >::getMax  )  const [inline]
 

returns the one-past-maximum of enumeration values previously provided to constructor or setNames()

Definition at line 650 of file plist.h.

template<typename T>
const char* plist::NamedEnumeration< T >::getName unsigned int  i  )  const [inline]
 

returns the name for a particular index

Definition at line 649 of file plist.h.

template<typename T>
const char* const* plist::NamedEnumeration< T >::getNames  )  const [inline]
 

returns the array of names previously provided from constructor or setNames()

Definition at line 648 of file plist.h.

template<typename T>
void plist::NamedEnumeration< T >::LoadXML xmlNode node  )  [inline, virtual]
 

This is called when the subclass needs to update its values from those values in the parse tree.

node is the current node in the tree -- it may be the root, but it may also be a subnode within the tree if a recursive structure is used

Implements XMLLoadSave.

Definition at line 652 of file plist.h.

template<typename T>
const T& plist::NamedEnumeration< T >::operator *  )  const [inline]
 

value access

Definition at line 645 of file plist.h.

template<typename T>
plist::NamedEnumeration< T >::operator T  )  const [inline]
 

automatic casting to the enumeration value

Definition at line 646 of file plist.h.

template<typename T>
NamedEnumeration& plist::NamedEnumeration< T >::operator= const NamedEnumeration< T > &  ne  )  [inline]
 

assignment

Definition at line 643 of file plist.h.

template<typename T>
NamedEnumeration& plist::NamedEnumeration< T >::operator= const std::string &  v  )  [inline]
 

assignment from string

Definition at line 642 of file plist.h.

template<typename T>
NamedEnumeration& plist::NamedEnumeration< T >::operator= const T &  v  )  [inline]
 

assignment from enumeration value (numeric)

Definition at line 641 of file plist.h.

template<typename T>
void plist::NamedEnumeration< T >::SaveXML xmlNode node  )  const [inline, virtual]
 

This is called when XMLLoadSave needs to have the subclass update values in the tree currently in memory -- may already be filled out by previous contents.

node is the current node in the tree -- it may be the root, but it may also be a subnode within the tree if a recursive structure is used

Implements XMLLoadSave.

Definition at line 677 of file plist.h.

template<typename T>
void plist::NamedEnumeration< T >::set const std::string &  str  )  [inline, virtual]
 

assign a new value

Implements plist::PrimitiveBase.

Definition at line 687 of file plist.h.

Referenced by plist::NamedEnumeration< T >::LoadXML(), and plist::NamedEnumeration< T >::operator=().

template<typename T>
void plist::NamedEnumeration< T >::setNames const char *const *  enumnames,
unsigned int  maxval
[inline]
 

(re)set the array of names and one-plus-maximum enum value (i.e. the number of enumeration values if they run sequentially from 0)

Definition at line 647 of file plist.h.


Member Data Documentation

template<typename T>
unsigned int plist::NamedEnumeration< T >::max [protected]
 

one-plus-maximum enum value, i.e. the number of enum entries if they are ordered sequentially from 0

Definition at line 715 of file plist.h.

Referenced by plist::NamedEnumeration< T >::findName(), plist::NamedEnumeration< T >::get(), plist::NamedEnumeration< T >::getMax(), plist::NamedEnumeration< T >::SaveXML(), and plist::NamedEnumeration< T >::setNames().

template<typename T>
const char* const* plist::NamedEnumeration< T >::names [protected]
 

pointer to array of names -- enum value must be able to serve as index for lookup

Definition at line 714 of file plist.h.

Referenced by plist::NamedEnumeration< T >::findName(), plist::NamedEnumeration< T >::get(), plist::NamedEnumeration< T >::getName(), plist::NamedEnumeration< T >::getNames(), plist::NamedEnumeration< T >::SaveXML(), and plist::NamedEnumeration< T >::setNames().

template<typename T>
T plist::NamedEnumeration< T >::val [protected]
 

storage of enum value

Definition at line 713 of file plist.h.

Referenced by plist::NamedEnumeration< T >::get(), plist::NamedEnumeration< T >::LoadXML(), plist::NamedEnumeration< T >::operator *(), plist::NamedEnumeration< T >::operator T(), plist::NamedEnumeration< T >::operator=(), plist::NamedEnumeration< T >::SaveXML(), and plist::NamedEnumeration< T >::set().


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

Tekkotsu v2.4.1
Generated Tue Aug 16 16:35:14 2005 by Doxygen 1.4.4