Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

plist::NamedEnumeration< T > Class Template Reference

#include <plistPrimitives.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 289 of file plistPrimitives.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< T > &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)
 interprets node as either a string holding the name, or a number corresponding to its index (name is preferred)
void saveXML (xmlNode *node) const
 saves name of current value (if available, index used otherwise) into node
void set (const std::string &str)
 assign a new value
std::string get () const
 return current value as a string
virtual NamedEnumeration<
T > * 
clone () const __attribute__((warn_unused_result))
 implements the clone function for NamedEnumeration<T>

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 291 of file plistPrimitives.h.

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

copy constructor

Definition at line 292 of file plistPrimitives.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 293 of file plistPrimitives.h.

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

automatic casting from the enumeration

Definition at line 294 of file plistPrimitives.h.


Member Function Documentation

template<class T>
NamedEnumeration< T > * plist::NamedEnumeration< T >::clone (  )  const [virtual]

implements the clone function for NamedEnumeration<T>

Implements plist::ObjectBase.

Definition at line 382 of file plistPrimitives.h.

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

returns the enum corresponding to name

Definition at line 364 of file plistPrimitives.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 352 of file plistPrimitives.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 304 of file plistPrimitives.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 303 of file plistPrimitives.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 302 of file plistPrimitives.h.

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

interprets node as either a string holding the name, or a number corresponding to its index (name is preferred)

Reimplemented from plist::ObjectBase.

Definition at line 307 of file plistPrimitives.h.

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

value access

Definition at line 299 of file plistPrimitives.h.

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

automatic casting to the enumeration value

Definition at line 300 of file plistPrimitives.h.

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

assignment

Definition at line 297 of file plistPrimitives.h.

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

assignment from string

Definition at line 296 of file plistPrimitives.h.

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

assignment from enumeration value (numeric)

Definition at line 295 of file plistPrimitives.h.

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

saves name of current value (if available, index used otherwise) into node

Implements plist::ObjectBase.

Definition at line 333 of file plistPrimitives.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 343 of file plistPrimitives.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 301 of file plistPrimitives.h.


Member Data Documentation

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


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

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