My Project
|
00001 /* 00002 $Id: MiniXmlParser.hh 2212 2010-11-11 07:29:57Z jisuzuki $ 00003 */ 00004 #include "Header.hh" 00005 #include <mxml.h> 00006 00007 #ifndef MINIXMLPARSER 00008 #define MINIXMLPARSER 00009 00010 #include "StringTools.hh" 00011 00012 class MiniXmlParser{ 00013 protected: 00014 mxml_node_t *xml_tree; 00015 string st; 00016 00017 Int4 SaveString( mxml_node_t *node, Int4 MaxLength, 00018 mxml_save_cb_t cb=MXML_NO_CALLBACK ); 00019 string PutString(); 00020 00021 public: 00022 MiniXmlParser(); 00023 ~MiniXmlParser(); // Add a destructor. 20101029 00024 00025 mxml_node_t *CreateNewTree(); 00026 void SaveXmlTree( string FileName ); 00027 mxml_node_t *ReadXmlTree( string FileName ); 00028 mxml_node_t *PutXmlTree(){ return xml_tree; } 00029 00030 mxml_node_t *PutParent( mxml_node_t *node ){ return node->parent; } 00031 mxml_node_t *PutChild( mxml_node_t *node ){ return node->child; } 00032 mxml_node_t *PutPrev( mxml_node_t *node ){ return node->prev; } 00033 mxml_node_t *PutNext( mxml_node_t *node ){ return node->next; } 00034 00035 mxml_node_t *NewElement( mxml_node_t *node, string name ); 00036 void NewText( mxml_node_t *node, string text ); 00037 void NewText( mxml_node_t *node, vector<string> text ); 00038 void NewText( mxml_node_t *node, vector<UInt4> text ); 00039 void NewText( mxml_node_t *node, vector<Int4> text ); 00040 void NewText( mxml_node_t *node, vector<Double> text ); 00041 void SetAttr( mxml_node_t *node, string name, string value ); 00042 00043 /* 00044 Int4 SaveString( mxml_node_t *node, Int4 MaxLength, 00045 mxml_save_cb_t cb=MXML_NO_CALLBACK ); 00046 string PutString(); 00047 */ 00048 00049 string PutString( mxml_node_t *node, Int4 MaxLength=1024 ); 00050 vector<string> PutStringVector( mxml_node_t *node, Int4 MaxLength=1024 ); 00051 vector<Int4> PutInt4Vector( mxml_node_t *node, Int4 MaxLength=1024 ); 00052 vector<UInt4> PutUInt4Vector( mxml_node_t *node, Int4 MaxLength=1024 ); 00053 vector<Double> PutDoubleVector( mxml_node_t *node, Int4 MaxLength=1024 ); 00054 00055 00056 string PutAttr( mxml_node_t *node, string name, UInt4 MaxLen ); 00057 00058 mxml_node_t *WalkPrevious( mxml_node_t *current, mxml_node_t *tree, 00059 int descend=MXML_DESCEND ); 00060 mxml_node_t *WalkNext( mxml_node_t *current, mxml_node_t *tree, 00061 int descend=MXML_DESCEND ); 00062 mxml_node_t *FindElement( mxml_node_t *node, 00063 mxml_node_t *top, 00064 string name="NULL", 00065 string attr="NULL", 00066 string value="NULL", 00067 int descend=MXML_DESCEND ); 00068 00069 }; 00070 00071 #endif 00072