Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

plist.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_PListSupport_h_
00003 #define INCLUDED_PListSupport_h_
00004 
00005 #include "plistBase.h"
00006 #include "plistPrimitives.h"
00007 #include "plistCollections.h"
00008 //#include "plistSpecialty.h"
00009 
00010 /*! The plist namespace provides convenient serialization for persistent storage, 
00011  *  dynamic introspection, and polymorphic primitive values.  The classes happen
00012  *  to use Apple's XML-based "property list" format for serialization, using libxml2
00013  *  for the low level parsing.
00014  *
00015  *  The choice of storage format was based on a desire for human readability,
00016  *  including per-value comments and inline documentation, as well as the desire
00017  *  to make use of syntax hilighting or high-level editing tools.
00018  *  
00019  *  Individual values are based on templated instances of the Primitive<T> class,
00020  *  while groups of values are based on the Collection interface.  Currently, the
00021  *  concrete collections available are Array (one dimensional ordered list of mixed
00022  *  primitive types), ArrayOf<T> (ordered list of a single type), or Dictionary (unordered
00023  *  mapping from string names to mixed primitives).
00024  *
00025  *  Generally, there are two ways you might use the functionality contained within
00026  *  this namespace.  One is as an external storage interface, such as the STL
00027  *  vector and map classes are used.  This might be only a intermediary instance
00028  *  for conversion to and from existing data structures, as a higher-level interface
00029  *  than directly accessing libxml.
00030  *
00031  *  However, to fully benefit from this namespace's functionality, you will generally
00032  *  want your classes to inherit from plist::Dictionary, define your members
00033  *  as public plist Primitives and Collections, and register listeners for notification
00034  *  when these values are modified (either by loading from file or programmatic
00035  *  modification.)
00036  *
00037  *  Example usage is shown below, you can find this code and more in Tekkotsu/tools/test/plist/.
00038  *  @include plist-example.cc
00039  */
00040 namespace plist {
00041   
00042   //! From the name of @a node, will instantiate a new ObjectBase subclass to load it
00043   /*! The mapping from node names to actual instantiated types is: 
00044    *    - 'array' -> Vector
00045    *    - 'dict' -> Map
00046    *    - 'real' -> Primitive<double>
00047    *    - 'integer' -> Primitive<long>
00048    *    - 'string' -> Primitive<std::string>
00049    *    - 'true', 'false' -> Primitive<bool>
00050    *  
00051    *  If successful, returns a pointer to a newly allocated region, which the caller is
00052    *  responsible for freeing.  If an error occurs, NULL is returned.
00053    */
00054   ObjectBase* loadXML(xmlNode* node);
00055   
00056   //! Attempts to parse the file found at @a file, using plist::loadXML()
00057   ObjectBase* loadFile(const std::string& file);
00058   
00059   //! Attempts to parse the buffer found at @a buf, using plist::loadXML()
00060   ObjectBase* loadBuffer(const char* buf, unsigned int len);
00061   
00062 } //namespace plist
00063 
00064 /*! @file
00065  * @brief Provides the plist namespace, a collection of classes to implement the Propery List data storage format, a XML standard used by Apple and others
00066  * @author Ethan Tira-Thompson (ejt) (Creator)
00067  */
00068 
00069 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:47 2016 by Doxygen 1.6.3