Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

plist::ObjectBase Class Reference

#include <plistBase.h>

Inheritance diagram for plist::ObjectBase:

List of all members.


Detailed Description

This base class provides the root functionality for all plist entities -- Dictionary and the various templated subclasses of PrimitiveBase.

The subclasses may throw std::bad_format if the document is poorly structured or bad values are found.

Definition at line 127 of file plistBase.h.


Public Member Functions

 ObjectBase ()
 constructor
virtual ~ObjectBase ()=0
 destructor
virtual void set (const ObjectBase &)=0
 polymorphic assignment (throws std::bad_cast if the assignment is between invalid types, i.e. a primitive and a collection, or different collection types)
template<typename T>
to () const
 casting operator: return current value as specified type (throws std::runtime_error exception if bad cast, e.g. dictionary or array to value type)
virtual std::string toString () const =0
 return current value as a string
virtual long toLong () const =0
 return current value as an (long) integer (throws std::runtime_error exception if incompatable, e.g. dictionary or array to value type)
virtual double toDouble () const =0
 return current value as a double (throws std::runtime_error exception if incompatable, e.g. dictionary or array to value type)
virtual void loadXML (xmlNode *node)=0
 subclasses are expected to provide a working implementation
virtual void saveXML (xmlNode *node) const =0
 subclasses are expected to provide a working implementation
virtual ObjectBaseclone () const __attribute__((warn_unused_result))=0
 allows a copy to be made of an event, supporting polymorphism

Protected Member Functions

ObjectBaseoperator= (const ObjectBase &)
 polymorphic assignment operator, see assign()
Inherited from XMLLoadSave
virtual void setParseTree (xmlDoc *doc) const
 assigns a parse tree which you have obtained from some other source
virtual xmlNodeFindRootXMLElement (xmlDoc *doc) const
 returns the root element of the xml document

Static Protected Member Functions

static bool matchTrue (const std::string &str)
 returns true if str is some form of affirmative (e.g. "true" or "yes")
static bool matchFalse (const std::string &str)
 returns true if str is some form of negative (e.g. "false" or "no")
libxml Forwards
Provides accessor functions to struct fields without having to include libxml.h everywhere

static bool xNodeHasName (xmlNode *node, const char *name)
 returns true if the name of node matches name
static const xmlCharxNodeGetName (xmlNode *node)
 returns name of node (not a libxml function)
static xmlNodexNodeGetChildren (xmlNode *node)
 returns children of node (not a libxml function)
static xmlNodexNodeGetLastChild (xmlNode *node)
 returns last child of node (not a libxml function)
static xmlNodexNodeGetNextNode (xmlNode *node)
 returns next node (sibling) after node (not a libxml function)
static xmlNodexNodeGetPrevNode (xmlNode *node)
 returns previous node (sibling) before node (not a libxml function)
static xmlNodexNodeGetParent (xmlNode *node)
 returns parent node of node (not a libxml function)
static xmlDocxNodeGetDoc (xmlNode *node)
 returns document node of node (not a libxml function)
static bool xNodeIsText (xmlNode *node)
 returns true if node is an XML_TEXT_NODE (not a libxml function)
static bool xNodeIsElement (xmlNode *node)
 returns true if node is an XML_ELEMENT_NODE (not a libxml function)
static bool xNodeIsComment (xmlNode *node)
 returns true if node is an XML_COMMENT_NODE (not a libxml function)

Friends

ObjectBaseloadXML (xmlNode *node)
 From the name of node, will instantiate a new ObjectBase subclass to load it.

Classes

struct  conversion_policy
 specifies that collections (e.g. plist::Array or plist::Dictionary) of these abstract base classes (ObjectBase, PrimitiveBase) can convert any primitive type to a plist::Primitive wrapper More...

Constructor & Destructor Documentation

plist::ObjectBase::ObjectBase (  ) 

constructor

Definition at line 11 of file plistBase.cc.

plist::ObjectBase::~ObjectBase (  )  [pure virtual]

destructor

Definition at line 15 of file plistBase.cc.


Member Function Documentation

virtual void plist::ObjectBase::set ( const ObjectBase  )  [pure 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)

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

template<typename T>
T plist::ObjectBase::to (  )  const [inline]

casting operator: return current value as specified type (throws std::runtime_error exception if bad cast, e.g. dictionary or array to value type)

The implementation for this function is defined by a series of specializations. This allows you to add casts for additional user-defined types, as well as get compile time error if you attempt to cast to an unsupported type. (I really wish we had virtual templated functions...)

Referenced by plist::Primitive< unsigned char >::operator=(), plist::Primitive< char >::operator=(), and plist::Primitive< bool >::operator=().

virtual std::string plist::ObjectBase::toString (  )  const [pure virtual]

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

polymorphic assignment operator, see assign()

This is protected for two reasons: one, so you don't accidentally use it via simple '=' statement, and two, to avoid 'operator= was hidden' warnings in every base class (because they keep reintroducing their default operator=(), hiding/shadowing this one (if it were virtual, as it would need to be to take on the role filled by assign().

Definition at line 167 of file plistBase.h.

Referenced by plist::Collection::operator=().

void plist::ObjectBase::setParseTree ( xmlDoc doc  )  const [protected, virtual]

assigns a parse tree which you have obtained from some other source

This doesn't update the contents of the subclass's values. The values in doc will be overwritten by those in the subclass on the next Save. If you wish to have the subclass's values updated from doc, call readParseTree() after calling this.

Reimplemented from XMLLoadSave.

Definition at line 17 of file plistBase.cc.

xmlNode * plist::ObjectBase::FindRootXMLElement ( xmlDoc doc  )  const [protected, virtual]

returns the root element of the xml document

Reimplemented from XMLLoadSave.

Definition at line 30 of file plistBase.cc.

const xmlChar * plist::ObjectBase::xNodeGetName ( xmlNode node  )  [static, protected]

xmlNode * plist::ObjectBase::xNodeGetChildren ( xmlNode node  )  [static, protected]

returns children of node (not a libxml function)

Definition at line 71 of file plistBase.cc.

Referenced by plist::ArrayBase::loadXML(), and plist::ArrayBase::saveXML().

xmlNode * plist::ObjectBase::xNodeGetLastChild ( xmlNode node  )  [static, protected]

returns last child of node (not a libxml function)

Definition at line 74 of file plistBase.cc.

Referenced by OutputConfig< T >::saveXML().

xmlNode * plist::ObjectBase::xNodeGetNextNode ( xmlNode node  )  [static, protected]

returns next node (sibling) after node (not a libxml function)

Definition at line 77 of file plistBase.cc.

Referenced by plist::ArrayBase::loadXML(), plist::ArrayBase::saveXML(), and plist::DictionaryBase::saveXML().

xmlNode * plist::ObjectBase::xNodeGetPrevNode ( xmlNode node  )  [static, protected]

returns previous node (sibling) before node (not a libxml function)

Definition at line 80 of file plistBase.cc.

xmlNode * plist::ObjectBase::xNodeGetParent ( xmlNode node  )  [static, protected]

returns parent node of node (not a libxml function)

Definition at line 83 of file plistBase.cc.

xmlDoc * plist::ObjectBase::xNodeGetDoc ( xmlNode node  )  [static, protected]

returns document node of node (not a libxml function)

Definition at line 86 of file plistBase.cc.

bool plist::ObjectBase::xNodeIsText ( xmlNode node  )  [static, protected]

returns true if node is an XML_TEXT_NODE (not a libxml function)

Definition at line 89 of file plistBase.cc.

Referenced by plist::DictionaryBase::saveOverXMLNode(), and OutputConfig< T >::saveXML().

bool plist::ObjectBase::xNodeIsElement ( xmlNode node  )  [static, protected]

returns true if node is an XML_ELEMENT_NODE (not a libxml function)

Definition at line 92 of file plistBase.cc.

bool plist::ObjectBase::xNodeIsComment ( xmlNode node  )  [static, protected]

returns true if node is an XML_COMMENT_NODE (not a libxml function)

Definition at line 95 of file plistBase.cc.

static bool plist::ObjectBase::matchTrue ( const std::string &  str  )  [inline, static, protected]

returns true if str is some form of affirmative (e.g. "true" or "yes")

Definition at line 190 of file plistBase.h.

Referenced by plist::Primitive< T >::set(), plist::Primitive< unsigned char >::set(), plist::Primitive< char >::set(), and plist::Primitive< bool >::set().

static bool plist::ObjectBase::matchFalse ( const std::string &  str  )  [inline, static, protected]

returns true if str is some form of negative (e.g. "false" or "no")

Definition at line 192 of file plistBase.h.

Referenced by plist::Primitive< T >::set(), plist::Primitive< unsigned char >::set(), plist::Primitive< char >::set(), and plist::Primitive< bool >::set().


Friends And Related Function Documentation

ObjectBase* loadXML ( xmlNode node  )  [friend]

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.

Implements XMLLoadSave.

Reimplemented in InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >, plist::DictionaryBase, plist::ArrayBase, plist::Primitive< T >, plist::Primitive< char >, plist::Primitive< unsigned char >, plist::Primitive< std::string >, plist::NamedEnumeration< T >, plist::Primitive< float >, plist::Primitive< int >, plist::Primitive< unsigned int >, plist::Primitive< bool >, plist::NamedEnumeration< J_DCT_METHOD >, plist::NamedEnumeration< Config::vision_config::shutter_speeds >, plist::NamedEnumeration< Config::main_config::consoleMode_t >, plist::NamedEnumeration< Config::sound_config::volume_levels >, plist::NamedEnumeration< Config::vision_config::white_balance_levels >, plist::NamedEnumeration< Config::transports >, plist::NamedEnumeration< Config::vision_config::RawCamConfig::encoding_t >, plist::NamedEnumeration< Config::vision_config::RawCamConfig::compression_t >, plist::NamedEnumeration< Config::vision_config::SegCamConfig::compression_t >, and plist::NamedEnumeration< Config::vision_config::gain_levels >.

Definition at line 7 of file plist.cc.

Referenced by plist::loadXML().


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

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