00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef CPL_MINIXML_H_INCLUDED
00031 #define CPL_MINIXML_H_INCLUDED
00032
00033 #include "cpl_port.h"
00034
00041 CPL_C_START
00042
00043 typedef enum
00044 { CXT_Element = 0, CXT_Text = 1, CXT_Attribute = 2, CXT_Comment = 3, CXT_Literal = 4
00050 } CPLXMLNodeType;
00051
00065 typedef struct CPLXMLNode
00066 {
00073 CPLXMLNodeType eType;
00074
00096 char *pszValue;
00097
00105 struct CPLXMLNode *psNext;
00106
00117 struct CPLXMLNode *psChild;
00118 } CPLXMLNode;
00119
00120
00121 CPLXMLNode CPL_DLL *CPLParseXMLString( const char * );
00122 void CPL_DLL CPLDestroyXMLNode( CPLXMLNode * );
00123 CPLXMLNode CPL_DLL *CPLGetXMLNode( CPLXMLNode *poRoot,
00124 const char *pszPath );
00125 CPLXMLNode CPL_DLL *CPLSearchXMLNode( CPLXMLNode *poRoot,
00126 const char *pszTarget );
00127 const char CPL_DLL *CPLGetXMLValue( CPLXMLNode *poRoot,
00128 const char *pszPath,
00129 const char *pszDefault );
00130 CPLXMLNode CPL_DLL *CPLCreateXMLNode( CPLXMLNode *poParent,
00131 CPLXMLNodeType eType,
00132 const char *pszText );
00133 char CPL_DLL *CPLSerializeXMLTree( const CPLXMLNode *psNode );
00134 void CPL_DLL CPLAddXMLChild( CPLXMLNode *psParent,
00135 CPLXMLNode *psChild );
00136 int CPL_DLL CPLRemoveXMLChild( CPLXMLNode *psParent,
00137 CPLXMLNode *psChild );
00138 void CPL_DLL CPLAddXMLSibling( CPLXMLNode *psOlderSibling,
00139 CPLXMLNode *psNewSibling );
00140 CPLXMLNode CPL_DLL *CPLCreateXMLElementAndValue( CPLXMLNode *psParent,
00141 const char *pszName,
00142 const char *pszValue );
00143 void CPL_DLL CPLAddXMLAttributeAndValue( CPLXMLNode *psParent,
00144 const char *pszName,
00145 const char *pszValue );
00146 CPLXMLNode CPL_DLL *CPLCloneXMLTree( CPLXMLNode *psTree );
00147 int CPL_DLL CPLSetXMLValue( CPLXMLNode *psRoot, const char *pszPath,
00148 const char *pszValue );
00149 void CPL_DLL CPLStripXMLNamespace( CPLXMLNode *psRoot,
00150 const char *pszNameSpace,
00151 int bRecurse );
00152 void CPL_DLL CPLCleanXMLElementName( char * );
00153
00154 CPLXMLNode CPL_DLL *CPLParseXMLFile( const char *pszFilename );
00155 int CPL_DLL CPLSerializeXMLTreeToFile( const CPLXMLNode *psTree,
00156 const char *pszFilename );
00157
00158 CPL_C_END
00159
00160 #ifdef __cplusplus
00161
00162
00163 class CPLXMLTreeCloser {
00164 public:
00165 explicit CPLXMLTreeCloser(CPLXMLNode* data) { the_data_ = data; }
00166
00167 ~CPLXMLTreeCloser() {
00168 if (the_data_) CPLDestroyXMLNode(the_data_);
00169 }
00170
00171
00172 CPLXMLNode* get() const { return the_data_; }
00173
00174 CPLXMLNode* operator->() const { return get(); }
00175
00176 private:
00177 CPLXMLNode* the_data_;
00178 };
00179 #endif
00180
00181 #endif