Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

parseobj.hpp

Go to the documentation of this file.
00001 // See ../../license.txt for license information.
00002 //
00003 // parseobj.hpp
00004 //
00005 // NOTES
00006 //              XML Parser for the persistence framework.
00007 //
00008 // 30-Jun-2003  phamilton  Created
00009 //
00010 
00011 #ifndef incPERSIST_XML_PARSEOBJ
00012 #define incPERSIST_XML_PARSEOBJ
00013 
00014 // forwards
00015 #include <string>
00016 #include <stack>
00017 #include <vector>
00018 #include <map>
00019 #include "parse.hpp"
00020 #include "parseobj_opts.h"
00021 #include "boost/filesystem/path.hpp"
00022 
00023 namespace ph {
00024 namespace common {
00025 class object_base;
00026 class persistable_object_context;
00027 class importable_object_base;
00028 };
00029 namespace persist {
00030 namespace xml {
00031 
00032 class PERSIST_DECL parseobj : public parse
00033 /*
00034         Concrete subclass for xml::parse for parseing objects.
00035 */
00036 {
00037 public:
00038         parseobj(parseobj *outer, // the outer parser (they are nested).
00039                 std::istream *stream, // the stream we are parseing from.
00040                 const boost::filesystem::path &streampath, // the pathname for the above stream.
00041                 ph::common::persistable_object_context *context, // a context to pass around.
00042                 std::ostream *console, // where to write messages.
00043                 const boost::filesystem::path &rootpath, // the basepath for the parse.
00044                 bool silent, // write errors out?
00045                 unsigned int debug=PARSEOBJ_NO_DEBUG);
00046 
00047                 ph::common::object_base *obj() { return _obj; };
00048                         //!< return the object that was parsed.
00049                         
00050                 void add_params(const std::map<std::string, std::string> &params);
00051                         //!< add the map of parameters passed in to this parser.
00052                         
00053                 void set_root_outer(ph::common::object_base *outer) 
00054                         { _rootouter = outer; }
00055                         //!< set an outer object to use for the root object.
00056 private:
00057         parseobj            *_outer; // the "outer" parser for importing.
00058         std::istream        *_stream; // where we are reading from.
00059         boost::filesystem::path _streampath; // the name of the above.
00060         ph::common::persistable_object_context      *_context; 
00061                         // the context is used to communicate with teh base system.
00062         boost::filesystem::path  _rootpath; // TBD: Not implemented yet.
00063         ph::common::object_base *_obj; // the object to return from the parse.
00064         ph::common::object_base *_root; // the root object in the system.
00065         ph::common::object_base *_rootouter; // the outer object for the root in the system.
00066         std::string          _cdata; // the latest cdata that we have accumulated
00067         std::string          _comment; // TBD: Not implemented yet.
00068         bool                 _abort; // we should abort.
00069         bool                 _inmember;
00070         int                  _anonymousobjnum;
00071         unsigned int         _debug;
00072         std::stack<ph::common::object_base *> _stack;
00073         
00074         // importing.
00075         parseobj                *_import; // the parser to use for the import.
00076         std::istream            *_importstream; // the stream to use for the import.
00077         boost::filesystem::path  _importstreampath; // the aboves path (on the disk).
00078         std::string              _rootname; // name we should give to the root object.
00079         std::map<std::string, std::string> _params; // parameters used during import.
00080         ph::common::importable_object_base *_delayed_obj; // we are in the middle of a delayed import.
00081         
00082         // fragments
00083         bool                     _fragment; // we are inside a fragment.
00084 
00085         ph::common::object_base *create_object(ph::common::object_base *top,
00086                 const xmlstring &type, const xmlstring &name);
00087         xmlstring dosubs(const xmlstring &s);
00088         xmlstring getdecodedattrval(const std::vector<xmlstring> &atts, int index);
00089         xmlstring getdecodedexpectedattr(const std::vector<xmlstring> &atts, 
00090                 const xmlstring &token);
00091         xmlstring getdecodedattr(const std::vector<xmlstring> &atts, const xmlstring &token);
00092         void add_param(const std::string &name, const std::string &val);
00093         static void add_param_1(std::map<std::string, std::string> *params, 
00094                 const std::string &name, const std::string &val);
00095         bool find_param(const std::string &name, std::string *value);
00096         bool test_outerable(ph::common::object_base *obj);
00097         bool test_persistable(ph::common::object_base *obj);
00098         bool test_composition(ph::common::object_base *obj);
00099 
00100         // parse
00101         virtual void startelement_handler(const xmlstring &name, 
00102                 const std::vector<xmlstring> &atts);
00103         virtual void endelement_handler(const xmlstring &name);
00104         virtual void cdata_handler(const xmlstring &s, int len);
00105         virtual void comment_handler(const xmlstring &s);
00106         virtual void finish_handler();
00107         
00108         // debugging.
00109         void obj_out(const std::string &msg, ph::common::object_base *obj);
00110         void element_out(const std::string &msg, const xmlstring &element);
00111 };
00112 
00113 }; // xml
00114 }; // persist
00115 }; // ph
00116 
00117 #endif // incPERSIST_XML_PARSEOBJ

Generated on Wed Apr 5 22:03:26 2006 for cppxmlobj by  doxygen 1.4.3