26 #ifndef TINYXML_INCLUDED
27 #define TINYXML_INCLUDED
30 #pragma warning( push )
31 #pragma warning( disable : 4530 )
32 #pragma warning( disable : 4786 )
42 #if defined( _DEBUG ) && !defined( DEBUG )
50 #define TIXML_STRING std::string
53 #define TIXML_STRING TiXmlString
63 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
65 #define TIXML_SNPRINTF _snprintf_s
66 #define TIXML_SSCANF sscanf_s
67 #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
70 #define TIXML_SNPRINTF _snprintf
71 #define TIXML_SSCANF sscanf
72 #elif defined(__GNUC__) && (__GNUC__ >= 3 )
75 #define TIXML_SNPRINTF snprintf
76 #define TIXML_SSCANF sscanf
78 #define TIXML_SNPRINTF snprintf
79 #define TIXML_SSCANF sscanf
213 virtual void Print( FILE* cfile,
int depth )
const = 0;
255 virtual const char*
Parse(
const char* p,
292 return ( isspace( (
unsigned char) c ) || c ==
'\n' || c ==
'\r' );
302 static bool StreamWhiteSpace( std::istream * in,
TIXML_STRING * tag );
303 static bool StreamTo( std::istream * in,
int character,
TIXML_STRING * tag );
315 static const char*
ReadText(
const char* in,
317 bool ignoreWhiteSpace,
333 assert( *length >= 0 && *length < 5 );
343 return GetEntity( p, _value, length, encoding );
351 for(
int i=0; p[i] && i<*length; ++i ) {
354 return p + (*length);
386 if ( v < 128 )
return tolower( v );
434 friend std::istream& operator >> (std::istream& in,
TiXmlNode& base);
452 friend std::ostream& operator<< (std::ostream& out,
const TiXmlNode& base);
455 friend std::string& operator<< (std::string& out,
const TiXmlNode& base );
494 const std::string& ValueStr()
const {
return value; }
512 void SetValue(
const std::string& _value ) {
value = _value; }
529 return const_cast< TiXmlNode*
> ((
const_cast< const TiXmlNode*
>(
this))->FirstChild( _value ));
536 return const_cast< TiXmlNode*
> ((
const_cast< const TiXmlNode*
>(
this))->LastChild( _value ));
564 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->IterateChildren( previous ) );
570 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->IterateChildren( _value, previous ) );
620 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->PreviousSibling( _prev ) );
637 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->NextSibling( _next ) );
655 return const_cast< TiXmlElement*
>( (
const_cast< const TiXmlNode*
>(
this))->NextSiblingElement( _next ) );
672 return const_cast< TiXmlElement*
>( (
const_cast< const TiXmlNode*
>(
this))->FirstChildElement( _value ) );
749 virtual void StreamIn( std::istream* in,
TIXML_STRING* tag ) = 0;
793 TiXmlAttribute(
const std::string& _name,
const std::string& _value )
814 const std::string& ValueStr()
const {
return value; }
843 void SetName(
const std::string& _name ) {
name = _name; }
845 void SetValue(
const std::string& _value ) {
value = _value; }
870 virtual void Print( FILE* cfile,
int depth )
const {
871 Print( cfile, depth, 0 );
920 # ifdef TIXML_USE_STL
960 const char*
Attribute(
const char* name )
const;
968 const char*
Attribute(
const char* name,
int* i )
const;
976 const char*
Attribute(
const char* name,
double* d )
const;
1005 #ifdef TIXML_USE_STL
1007 int QueryStringAttribute(
const char* name, std::string* _value )
const {
1010 *_value = std::string( cstr );
1024 template<
typename T >
int QueryValueAttribute(
const std::string& name, T* outValue )
const
1030 std::stringstream sstream( node->ValueStr() );
1031 sstream >> *outValue;
1032 if ( !sstream.fail() )
1037 int QueryValueAttribute(
const std::string& name, std::string* outValue )
const
1042 *outValue = node->ValueStr();
1050 void SetAttribute(
const char* name,
const char * _value );
1052 #ifdef TIXML_USE_STL
1053 const std::string*
Attribute(
const std::string& name )
const;
1054 const std::string*
Attribute(
const std::string& name,
int* i )
const;
1055 const std::string*
Attribute(
const std::string& name,
double* d )
const;
1060 void SetAttribute(
const std::string& name,
const std::string& _value );
1062 void SetAttribute(
const std::string& name,
int _value );
1080 #ifdef TIXML_USE_STL
1126 virtual void Print( FILE* cfile,
int depth )
const;
1146 #ifdef TIXML_USE_STL
1147 virtual void StreamIn( std::istream * in,
TIXML_STRING * tag );
1179 virtual void Print( FILE* cfile,
int depth )
const;
1197 #ifdef TIXML_USE_STL
1198 virtual void StreamIn( std::istream * in,
TIXML_STRING * tag );
1227 #ifdef TIXML_USE_STL
1240 virtual void Print( FILE* cfile,
int depth )
const;
1263 #ifdef TIXML_USE_STL
1264 virtual void StreamIn( std::istream * in,
TIXML_STRING * tag );
1291 #ifdef TIXML_USE_STL
1294 const std::string& _encoding,
1295 const std::string& _standalone );
1300 const char* _encoding,
1301 const char* _standalone );
1319 virtual void Print( FILE* cfile,
int depth )
const {
1320 Print( cfile, depth, 0 );
1335 #ifdef TIXML_USE_STL
1336 virtual void StreamIn( std::istream * in,
TIXML_STRING * tag );
1366 virtual void Print( FILE* cfile,
int depth )
const;
1380 #ifdef TIXML_USE_STL
1381 virtual void StreamIn( std::istream * in,
TIXML_STRING * tag );
1401 #ifdef TIXML_USE_STL
1421 bool SaveFile(
const char * filename )
const;
1431 #ifdef TIXML_USE_STL
1434 return LoadFile( filename.c_str(), encoding );
1436 bool SaveFile(
const std::string& filename )
const
1438 return SaveFile( filename.c_str() );
1528 virtual void Print( FILE* cfile,
int depth = 0 )
const;
1542 #ifdef TIXML_USE_STL
1543 virtual void StreamIn( std::istream * in,
TIXML_STRING * tag );
1675 #ifdef TIXML_USE_STL
1679 TiXmlHandle Child(
const std::string& _value,
int index )
const {
return Child( _value.c_str(), index ); }
1779 #ifdef TIXML_USE_STL
1781 const std::string& Str() {
return buffer; }
1786 for(
int i=0; i<
depth; ++i )
1802 #pragma warning( pop )