00001 /********************************************************************** 00002 * $Id: cpl_minixml.h,v 1.14 2005/10/07 00:03:29 fwarmerdam Exp $ 00003 * 00004 * Project: CPL - Common Portability Library 00005 * Purpose: Declarations for MiniXML Handler. 00006 * Author: Frank Warmerdam, warmerdam@pobox.com 00007 * 00008 ********************************************************************** 00009 * Copyright (c) 2001, Frank Warmerdam 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining a 00012 * copy of this software and associated documentation files (the "Software"), 00013 * to deal in the Software without restriction, including without limitation 00014 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00015 * and/or sell copies of the Software, and to permit persons to whom the 00016 * Software is furnished to do so, subject to the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be included 00019 * in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00022 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00023 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00024 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00025 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00026 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00027 * DEALINGS IN THE SOFTWARE. 00028 ********************************************************************** 00029 * 00030 * $Log: cpl_minixml.h,v $ 00031 * Revision 1.14 2005/10/07 00:03:29 fwarmerdam 00032 * improve documentation 00033 * 00034 * Revision 1.13 2005/05/13 18:17:48 fwarmerdam 00035 * added CPLRemoveXMLChild 00036 * 00037 * Revision 1.12 2005/03/09 17:07:25 fwarmerdam 00038 * added CPLSearchXMLNode 00039 * 00040 * Revision 1.11 2004/01/29 15:29:28 warmerda 00041 * Added CPLCleanXMLElementName 00042 * 00043 * Revision 1.10 2003/12/04 15:46:51 warmerda 00044 * Added CPLAddXMLSibling() 00045 * 00046 * Revision 1.9 2003/11/05 20:14:21 warmerda 00047 * added lots of documentation 00048 * 00049 * Revision 1.8 2003/03/27 18:12:41 warmerda 00050 * Added NULL pszNameSpace support in namespace stripper (all namespaces). 00051 * Added XML file read/write functions. 00052 * 00053 * Revision 1.7 2003/03/24 16:46:48 warmerda 00054 * added CPLStripXMLNamespace 00055 * 00056 * Revision 1.6 2002/11/16 20:38:34 warmerda 00057 * added support for literals like DOCTYPE 00058 * 00059 * Revision 1.5 2002/05/24 04:09:10 warmerda 00060 * added clone and SetXMLValue functions 00061 * 00062 * Revision 1.4 2002/03/05 14:26:57 warmerda 00063 * expanded tabs 00064 * 00065 * Revision 1.3 2002/01/23 20:45:06 warmerda 00066 * handle <?...?> and comment elements 00067 * 00068 * Revision 1.2 2001/12/06 18:13:49 warmerda 00069 * added CPLAddXMLChild and CPLCreateElmentAndValue 00070 * 00071 * Revision 1.1 2001/11/16 15:39:48 warmerda 00072 * New 00073 * 00074 **********************************************************************/ 00075 00076 #ifndef _CPL_MINIXML_H_INCLUDED 00077 #define _CPL_MINIXML_H_INCLUDED 00078 00079 #include "cpl_port.h" 00080 00087 CPL_C_START 00088 00089 typedef enum 00090 { CXT_Element = 0, CXT_Text = 1, CXT_Attribute = 2, CXT_Comment = 3, CXT_Literal = 4 00096 } CPLXMLNodeType; 00097 00111 typedef struct _CPLXMLNode 00112 { 00119 CPLXMLNodeType eType; 00120 00142 char *pszValue; 00143 00151 struct _CPLXMLNode *psNext; 00152 00163 struct _CPLXMLNode *psChild; 00164 } CPLXMLNode; 00165 00166 00167 CPLXMLNode CPL_DLL *CPLParseXMLString( const char * ); 00168 void CPL_DLL CPLDestroyXMLNode( CPLXMLNode * ); 00169 CPLXMLNode CPL_DLL *CPLGetXMLNode( CPLXMLNode *poRoot, 00170 const char *pszPath ); 00171 CPLXMLNode CPL_DLL *CPLSearchXMLNode( CPLXMLNode *poRoot, 00172 const char *pszTarget ); 00173 const char CPL_DLL *CPLGetXMLValue( CPLXMLNode *poRoot, 00174 const char *pszPath, 00175 const char *pszDefault ); 00176 CPLXMLNode CPL_DLL *CPLCreateXMLNode( CPLXMLNode *poParent, 00177 CPLXMLNodeType eType, 00178 const char *pszText ); 00179 char CPL_DLL *CPLSerializeXMLTree( CPLXMLNode *psNode ); 00180 void CPL_DLL CPLAddXMLChild( CPLXMLNode *psParent, 00181 CPLXMLNode *psChild ); 00182 int CPL_DLL CPLRemoveXMLChild( CPLXMLNode *psParent, 00183 CPLXMLNode *psChild ); 00184 void CPL_DLL CPLAddXMLSibling( CPLXMLNode *psOlderSibling, 00185 CPLXMLNode *psNewSibling ); 00186 CPLXMLNode CPL_DLL *CPLCreateXMLElementAndValue( CPLXMLNode *psParent, 00187 const char *pszName, 00188 const char *pszValue ); 00189 CPLXMLNode CPL_DLL *CPLCloneXMLTree( CPLXMLNode *psTree ); 00190 int CPL_DLL CPLSetXMLValue( CPLXMLNode *psRoot, const char *pszPath, 00191 const char *pszValue ); 00192 void CPL_DLL CPLStripXMLNamespace( CPLXMLNode *psRoot, 00193 const char *pszNameSpace, 00194 int bRecurse ); 00195 void CPL_DLL CPLCleanXMLElementName( char * ); 00196 00197 CPLXMLNode CPL_DLL *CPLParseXMLFile( const char *pszFilename ); 00198 int CPL_DLL CPLSerializeXMLTreeToFile( CPLXMLNode *psTree, 00199 const char *pszFilename ); 00200 00201 CPL_C_END 00202 00203 #endif /* _CPL_MINIXML_H_INCLUDED */