64 #ifndef TINYXML_INCLUDED 65 #define TINYXML_INCLUDED 68 #pragma warning( push ) 69 #pragma warning( disable : 4530 ) 70 #pragma warning( disable : 4786 ) 80 #if defined( _DEBUG ) && !defined( DEBUG ) 87 #define TIXML_STRING std::string 88 #define TIXML_ISTREAM std::istream 89 #define TIXML_OSTREAM std::ostream 92 #define TIXML_STRING TiXmlString 93 #define TIXML_OSTREAM TiXmlOutStream 101 #define TIXML_SAFE // TinyXml isn't fully buffer overrun protected, safe code. This is work in progress. 103 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) 105 #define TIXML_SNPRINTF _snprintf_s 106 #define TIXML_SNSCANF _snscanf_s 107 #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) 110 #define TIXML_SNPRINTF _snprintf 111 #define TIXML_SNSCANF _snscanf 112 #elif defined(__GNUC__) && (__GNUC__ >= 3 ) 115 #define TIXML_SNPRINTF snprintf 116 #define TIXML_SNSCANF snscanf 120 namespace RTT {
namespace marsh {
126 class TiXmlAttribute;
128 class TiXmlDeclaration;
129 class TiXmlParsingData;
204 virtual void Print( FILE* cfile,
int depth )
const = 0;
235 int Row()
const {
return location.row + 1; }
236 int Column()
const {
return location.col + 1; }
243 static const int utf8ByteTable[256];
245 virtual const char* Parse(
const char* p,
268 TIXML_ERROR_STRING_COUNT
283 static const char* SkipWhiteSpace(
const char*,
TiXmlEncoding encoding );
286 return ( isspace( (
unsigned char) c ) || c ==
'\n' || c ==
'\r' );
291 return IsWhiteSpace( (
char) c );
298 static bool StreamWhiteSpace( TIXML_ISTREAM * in,
TIXML_STRING * tag );
299 static bool StreamTo( TIXML_ISTREAM * in,
int character,
TIXML_STRING * tag );
311 static const char* ReadText(
const char* in,
313 bool ignoreWhiteSpace,
319 static const char* GetEntity(
const char* in,
char* value,
int* length,
TiXmlEncoding encoding );
328 *length = utf8ByteTable[ *((
unsigned char*)p) ];
329 assert( *length >= 0 && *length < 5 );
339 return GetEntity( p, _value, length, encoding );
347 for(
int i=0; p[i] && i<*length; ++i ) {
350 return p + (*length);
368 static bool StringEqual(
const char* p,
373 static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
382 static int IsAlpha(
unsigned char anyByte,
TiXmlEncoding encoding );
383 static int IsAlphaNum(
unsigned char anyByte,
TiXmlEncoding encoding );
388 if ( v < 128 )
return tolower( v );
396 static void ConvertUTF32ToUTF8(
unsigned long input,
char* output,
int* length );
405 unsigned int strLength;
411 MAX_ENTITY_LENGTH = 6
414 static Entity entity[ NUM_ENTITY ];
415 static bool condenseWhiteSpace;
492 const char *
Value()
const {
return value.c_str (); }
499 const std::string& ValueStr()
const {
return value; }
511 void SetValue(
const char * _value) { value = _value;}
514 void SetValue(
const std::string& _value ) { value = _value; }
527 const TiXmlNode* FirstChild(
const char * value )
const;
528 TiXmlNode* FirstChild(
const char * value );
532 const TiXmlNode* LastChild(
const char * value )
const;
533 TiXmlNode* LastChild(
const char * value );
536 const TiXmlNode* FirstChild(
const std::string& _value )
const {
return FirstChild (_value.c_str ()); }
537 TiXmlNode* FirstChild(
const std::string& _value ) {
return FirstChild (_value.c_str ()); }
538 const TiXmlNode* LastChild(
const std::string& _value )
const {
return LastChild (_value.c_str ()); }
539 TiXmlNode* LastChild(
const std::string& _value ) {
return LastChild (_value.c_str ()); }
562 const TiXmlNode* IterateChildren(
const char * value,
const TiXmlNode* previous )
const;
566 const TiXmlNode* IterateChildren(
const std::string& _value,
const TiXmlNode* previous )
const {
return IterateChildren (_value.c_str (), previous); }
567 TiXmlNode* IterateChildren(
const std::string& _value,
TiXmlNode* previous ) {
return IterateChildren (_value.c_str (), previous); }
603 bool RemoveChild(
TiXmlNode* removeThis );
610 const TiXmlNode* PreviousSibling(
const char * )
const;
611 TiXmlNode* PreviousSibling(
const char * );
614 const TiXmlNode* PreviousSibling(
const std::string& _value )
const {
return PreviousSibling (_value.c_str ()); }
615 TiXmlNode* PreviousSibling(
const std::string& _value ) {
return PreviousSibling (_value.c_str ()); }
616 const TiXmlNode* NextSibling(
const std::string& _value)
const {
return NextSibling (_value.c_str ()); }
617 TiXmlNode* NextSibling(
const std::string& _value) {
return NextSibling (_value.c_str ()); }
625 const TiXmlNode* NextSibling(
const char * )
const;
639 const TiXmlElement* NextSiblingElement(
const char * )
const;
643 const TiXmlElement* NextSiblingElement(
const std::string& _value)
const {
return NextSiblingElement (_value.c_str ()); }
644 TiXmlElement* NextSiblingElement(
const std::string& _value) {
return NextSiblingElement (_value.c_str ()); }
652 const TiXmlElement* FirstChildElement(
const char * value )
const;
656 const TiXmlElement* FirstChildElement(
const std::string& _value )
const {
return FirstChildElement (_value.c_str ()); }
657 TiXmlElement* FirstChildElement(
const std::string& _value ) {
return FirstChildElement (_value.c_str ()); }
664 int Type()
const {
return type; }
703 virtual void StreamIn( TIXML_ISTREAM* in,
TIXML_STRING* tag ) = 0;
746 TiXmlAttribute(
const std::string& _name,
const std::string& _value )
765 const char*
Name()
const {
return name.c_str (); }
766 const char*
Value()
const {
return value.c_str (); }
767 int IntValue()
const;
768 double DoubleValue()
const;
782 int QueryIntValue(
int* _value )
const;
784 int QueryDoubleValue(
double* _value )
const;
786 void SetName(
const char* _name ) { name = _name; }
787 void SetValue(
const char* _value ) { value = _value; }
789 void SetIntValue(
int _value );
790 void SetDoubleValue(
double _value );
793 void SetName(
const std::string& _name ) { name = _name; }
796 void SetValue(
const std::string& _value ) { value = _value; }
816 virtual void Print( FILE* cfile,
int depth )
const;
898 const char*
Attribute(
const char* name )
const;
906 const char* Attribute(
const char* name,
int* i )
const;
914 const char* Attribute(
const char* name,
double* d )
const;
923 int QueryIntAttribute(
const char* name,
int* _value )
const;
925 int QueryDoubleAttribute(
const char* name,
double* _value )
const;
929 int result = QueryDoubleAttribute( name, &d );
939 void SetAttribute(
const char* name,
const char * _value );
942 const char* Attribute(
const std::string& name )
const {
return Attribute( name.c_str() ); }
943 const char* Attribute(
const std::string& name,
int* i )
const {
return Attribute( name.c_str(), i ); }
944 const char* Attribute(
const std::string& name,
double* d )
const {
return Attribute( name.c_str(), d ); }
945 int QueryIntAttribute(
const std::string& name,
int* _value )
const {
return QueryIntAttribute( name.c_str(), _value ); }
946 int QueryDoubleAttribute(
const std::string& name,
double* _value )
const {
return QueryDoubleAttribute( name.c_str(), _value ); }
949 void SetAttribute(
const std::string& name,
const std::string& _value );
951 void SetAttribute(
const std::string& name,
int _value );
957 void SetAttribute(
const char * name,
int value );
962 void SetDoubleAttribute(
const char * name,
double value );
966 void RemoveAttribute(
const char * name );
968 void RemoveAttribute(
const std::string& name ) { RemoveAttribute (name.c_str ()); }
1008 const char* GetText()
const;
1013 virtual void Print( FILE* cfile,
int depth )
const;
1029 #ifdef TIXML_USE_STL 1030 virtual void StreamIn( TIXML_ISTREAM * in,
TIXML_STRING * tag );
1061 virtual void Print( FILE* cfile,
int depth )
const;
1075 #ifdef TIXML_USE_STL 1076 virtual void StreamIn( TIXML_ISTREAM * in,
TIXML_STRING * tag );
1100 SetValue( initValue );
1105 #ifdef TIXML_USE_STL 1109 SetValue( initValue );
1118 virtual void Print( FILE* cfile,
int depth )
const;
1138 #ifdef TIXML_USE_STL 1139 virtual void StreamIn( TIXML_ISTREAM * in,
TIXML_STRING * tag );
1166 #ifdef TIXML_USE_STL 1169 const std::string& _encoding,
1170 const std::string& _standalone );
1175 const char* _encoding,
1176 const char* _standalone );
1184 const char *
Version()
const {
return version.c_str (); }
1186 const char *
Encoding()
const {
return encoding.c_str (); }
1193 virtual void Print( FILE* cfile,
int depth )
const;
1203 #ifdef TIXML_USE_STL 1204 virtual void StreamIn( TIXML_ISTREAM * in,
TIXML_STRING * tag );
1235 virtual void Print( FILE* cfile,
int depth )
const;
1245 #ifdef TIXML_USE_STL 1246 virtual void StreamIn( TIXML_ISTREAM * in,
TIXML_STRING * tag );
1267 #ifdef TIXML_USE_STL 1281 bool LoadFile(
TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1283 bool SaveFile()
const;
1285 bool LoadFile(
const char * filename,
TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1287 bool SaveFile(
const char * filename )
const;
1293 bool LoadFile( FILE*,
TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1295 bool SaveFile( FILE* )
const;
1297 #ifdef TIXML_USE_STL 1298 bool LoadFile(
const std::string& filename,
TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )
1303 bool SaveFile(
const std::string& filename )
const 1331 const char *
ErrorDesc()
const {
return errorDesc.c_str (); }
1382 errorLocation.row = errorLocation.col = 0;
1390 virtual void Print( FILE* cfile,
int depth = 0 )
const;
1401 #ifdef TIXML_USE_STL 1402 virtual void StreamIn( TIXML_ISTREAM * in,
TIXML_STRING * tag );
1413 bool useMicrosoftBOM;
1509 TiXmlHandle FirstChild(
const char * value )
const;
1513 TiXmlHandle FirstChildElement(
const char * value )
const;
1518 TiXmlHandle Child(
const char* value,
int index )
const;
1527 TiXmlHandle ChildElement(
const char* value,
int index )
const;
1534 #ifdef TIXML_USE_STL 1535 TiXmlHandle FirstChild(
const std::string& _value )
const {
return FirstChild( _value.c_str() ); }
1536 TiXmlHandle FirstChildElement(
const std::string& _value )
const {
return FirstChildElement( _value.c_str() ); }
1538 TiXmlHandle Child(
const std::string& _value,
int index )
const {
return Child( _value.c_str(), index ); }
1539 TiXmlHandle ChildElement(
const std::string& _value,
int index )
const {
return ChildElement( _value.c_str(), index ); }
1547 TiXmlText*
Text()
const {
return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
1558 #pragma warning( pop ) A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thi...
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
const char * Encoding() const
Encoding. Will return an empty string if none was found.
bool NoChildren() const
Returns true if this node has no children.
const char * Name() const
Return the name of this attribute.
bool operator<(const TiXmlAttribute &rhs) const
static int ToLower(int v, TiXmlEncoding encoding)
const char * Value() const
Return the value of this attribute.
int ErrorRow()
Returns the location (if known) of the error.
int Type() const
Query the type (as an enumerated value, above) of this node.
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
void SetName(const char *_name)
Set the name of this attribute.
void CopyTo(TiXmlUnknown *target) const
TiXmlHandle operator=(const TiXmlHandle &ref)
static bool IsWhiteSpace(char c)
void SetTabSize(int _tabsize)
SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct v...
std::istream & operator>>(std::istream &is, BufferPolicy &bp)
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null not of the requested type.
bool operator>(const TiXmlAttribute &rhs) const
const TIXML_STRING & NameTStr() const
void operator=(const TiXmlUnknown ©)
void SetUserData(void *user)
bool CDATA()
Queries whether this represents text using a CDATA section.
An attribute is a name-value pair.
Always the top level node.
int ErrorCol()
The column where the error occured. See ErrorRow()
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null not of the requested type.
void * userData
Field containing a generic user pointer.
const TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
TiXmlUnknown * Unknown() const
Return the handle as a TiXmlUnknown. This may return null;.
TiXmlAttribute * LastAttribute()
TiXmlDeclaration()
Construct an empty declaration.
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
TiXmlUnknown(const TiXmlUnknown ©)
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null if not of the requested type.
TiXmlNode * Node() const
Return the handle as a TiXmlNode. This may return null.
int QueryFloatAttribute(const char *name, float *_value) const
QueryFloatAttribute examines the attribute - see QueryIntAttribute().
const TiXmlElement * RootElement() const
Get the root element – the only top level element – of the document.
int Column() const
See Row()
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null not of the requested type.
bool operator==(const TiXmlAttribute &rhs) const
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null not of the requested type.
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
const char * Version() const
Version. Will return an empty string if none was found.
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null if not of the requested type.
static void SetCondenseWhiteSpace(bool condense)
The world does not agree on whether white space should be kept or not.
void operator=(const TiXmlText &base)
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
const char * Standalone() const
Is this a standalone document?
TiXmlText(const TiXmlText ©)
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
const int TIXML_PATCH_VERSION
TiXmlNode * NextSibling()
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
void SetValue(const char *_value)
Changes the value of the node.
virtual ~TiXmlDeclaration()
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
TiXmlText(const char *initValue)
Constructor for text element.
void Print() const
Dump the document to standard out.
TIXML_OSTREAM & operator<<(TIXML_OSTREAM &out, const TiXmlNode &base)
const int TIXML_MAJOR_VERSION
The parent class for everything in the Document Object Model.
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null if not of the requested type.
const TiXmlAttribute * First() const
TiXmlBase is a base class for every class in TinyXml.
const int TIXML_MINOR_VERSION
TiXmlElement * RootElement()
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null if not of the requested type.
The element is a container class.
TiXmlAttribute * FirstAttribute()
TiXmlText * Text() const
Return the handle as a TiXmlText. This may return null.
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
void ClearError()
If you have handled the error, it can be reset with this call.
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
TiXmlNode * PreviousSibling()
void SetDocument(TiXmlDocument *doc)
static bool IsWhiteSpace(int c)
const TiXmlEncoding TIXML_DEFAULT_ENCODING
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null if not of the requested type.
const TiXmlNode * LastChild() const
bool Error() const
If an error occurs, Error will be set to true.
TiXmlNode * Parent()
One step up the DOM.
const TiXmlNode * Parent() const
void SetValue(const char *_value)
Set the value.
void CopyTo(TiXmlText *target) const
An Attribute has a name and contains data which can be set and get.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
In correct XML the declaration is the first entry in the file.
NodeType
The types of XML nodes supported by TinyXml.
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
Any tag that tinyXml doesn't recognize is saved as an unknown.
const char * Value() const
The meaning of 'value' changes for the specific type of TiXmlNode.
const TiXmlAttribute * Last() const
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null if not of the requested type.
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
static const char * GetChar(const char *p, char *_value, int *length, TiXmlEncoding encoding)
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null not of the requested type.
int ErrorId() const
Generally, you probably want the error string ( ErrorDesc() ).
int Row() const
Return the position, in the original source file, of this node or attribute.
TiXmlAttribute()
Construct an empty attribute.
TiXmlElement * Element() const
Return the handle as a TiXmlElement. This may return null.