1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
/******************************************************************************
* $Id: XMLNode.i 24439 2012-05-17 21:54:16Z rouault $
*
* Project: GDAL SWIG Interface
* Purpose: GDAL XML SWIG Interface declarations.
* Author: Tamas Szekeres (szekerest@gmeil.com)
*
******************************************************************************
* Copyright (c) 2005, Tamas Szekeres
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
%rename (XMLNodeType) CPLXMLNodeType;
typedef enum
{
CXT_Element = 0,
CXT_Text = 1,
CXT_Attribute = 2,
CXT_Comment = 3,
CXT_Literal = 4
} CPLXMLNodeType;
%rename (XMLNode) CPLXMLNode;
%rename (Type) CPLXMLNode::eType;
%rename (Value) CPLXMLNode::pszValue;
%rename (Next) CPLXMLNode::psNext;
%rename (Child) CPLXMLNode::psChild;
typedef struct CPLXMLNode
{
%immutable;
CPLXMLNodeType eType;
char *pszValue;
struct CPLXMLNode *psNext;
struct CPLXMLNode *psChild;
%mutable;
} CPLXMLNode;
%extend CPLXMLNode
{
CPLXMLNode(const char *pszString)
{
return CPLParseXMLString( pszString );
}
/* Interface method added for GDAL 1.7.0 */
CPLXMLNode(CPLXMLNodeType eType, const char *pszText )
{
return CPLCreateXMLNode(NULL, eType, pszText);
}
~CPLXMLNode()
{
CPLDestroyXMLNode( self );
}
/* Interface method added for GDAL 1.7.0 */
#ifdef SWIGJAVA
%newobject ParseXMLFile;
static CPLXMLNode* ParseXMLFile( const char *pszFilename )
{
return CPLParseXMLFile(pszFilename);
}
#endif
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPERL)
retStringAndCPLFree *SerializeXMLTree( )
#else
char *SerializeXMLTree( )
#endif
{
return CPLSerializeXMLTree( self );
}
/* Interface method added for GDAL 1.7.0 */
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPERL)
retStringAndCPLFree * toString()
{
return CPLSerializeXMLTree( self );
}
#endif
CPLXMLNode *SearchXMLNode( const char *pszElement )
{
return CPLSearchXMLNode(self, pszElement);
}
CPLXMLNode *GetXMLNode( const char *pszPath )
{
return CPLGetXMLNode( self, pszPath );
}
const char *GetXMLValue( const char *pszPath,
const char *pszDefault )
{
return CPLGetXMLValue( self, pszPath, pszDefault );
}
// for Java, I don't want to deal with ownerships issues
// so I just clone
#ifdef SWIGJAVA
%apply Pointer NONNULL {CPLXMLNode *psChild};
void AddXMLChild( CPLXMLNode *psChild )
{
CPLAddXMLChild( self, CPLCloneXMLTree(psChild) );
}
%clear CPLXMLNode *psChild;
%apply Pointer NONNULL {CPLXMLNode *psNewSibling};
void AddXMLSibling( CPLXMLNode *psNewSibling )
{
CPLAddXMLSibling( self, CPLCloneXMLTree(psNewSibling) );
}
%clear CPLXMLNode *psNewSibling;
#else
void AddXMLChild( CPLXMLNode *psChild )
{
CPLAddXMLChild( self, psChild );
}
int RemoveXMLChild( CPLXMLNode *psChild )
{
return CPLRemoveXMLChild( self, psChild );
}
void AddXMLSibling( CPLXMLNode *psNewSibling )
{
CPLAddXMLSibling( self, psNewSibling );
}
CPLXMLNode *CreateXMLElementAndValue( const char *pszName,
const char *pszValue )
{
return CPLCreateXMLElementAndValue( self, pszName, pszValue );
}
%newobject CloneXMLTree;
CPLXMLNode *CloneXMLTree( CPLXMLNode *psTree )
{
return CPLCloneXMLTree( psTree );
}
#endif
/* Interface method added for GDAL 1.7.0 */
%newobject Clone;
CPLXMLNode *Clone()
{
return CPLCloneXMLTree( self );
}
int SetXMLValue( const char *pszPath,
const char *pszValue )
{
return CPLSetXMLValue( self, pszPath, pszValue );
}
void StripXMLNamespace( const char *pszNamespace,
int bRecurse )
{
CPLStripXMLNamespace( self, pszNamespace, bRecurse );
}
}
|