tinystr.h | tinystr.h | |||
---|---|---|---|---|
skipping to change at line 54 | skipping to change at line 54 | |||
{ | { | |||
public : | public : | |||
// TiXmlString constructor, based on a string | // TiXmlString constructor, based on a string | |||
TiXmlString (const char * instring); | TiXmlString (const char * instring); | |||
// TiXmlString empty constructor | // TiXmlString empty constructor | |||
TiXmlString () | TiXmlString () | |||
{ | { | |||
allocated = 0; | allocated = 0; | |||
cstring = NULL; | cstring = NULL; | |||
current_length = 0; | ||||
} | } | |||
// TiXmlString copy constructor | // TiXmlString copy constructor | |||
TiXmlString (const TiXmlString& copy); | TiXmlString (const TiXmlString& copy); | |||
// TiXmlString destructor | // TiXmlString destructor | |||
~ TiXmlString () | ~ TiXmlString () | |||
{ | { | |||
empty_it (); | empty_it (); | |||
} | } | |||
skipping to change at line 144 | skipping to change at line 145 | |||
function clears the content of the TiXmlString if any exists . | function clears the content of the TiXmlString if any exists . | |||
*/ | */ | |||
void reserve (unsigned size) | void reserve (unsigned size) | |||
{ | { | |||
empty_it (); | empty_it (); | |||
if (size) | if (size) | |||
{ | { | |||
allocated = size; | allocated = size; | |||
cstring = new char [size]; | cstring = new char [size]; | |||
cstring [0] = 0; | cstring [0] = 0; | |||
current_length = 0; | ||||
} | } | |||
} | } | |||
// [] operator | // [] operator | |||
char& operator [] (unsigned index) const | char& operator [] (unsigned index) const | |||
{ | { | |||
assert( index < length ()); | assert( index < length ()); | |||
return cstring [index]; | return cstring [index]; | |||
} | } | |||
skipping to change at line 166 | skipping to change at line 168 | |||
npos = notfound }; | npos = notfound }; | |||
void append (const char *str, int len ); | void append (const char *str, int len ); | |||
protected : | protected : | |||
// The base string | // The base string | |||
char * cstring; | char * cstring; | |||
// Number of chars allocated | // Number of chars allocated | |||
unsigned allocated; | unsigned allocated; | |||
// Current string size | ||||
unsigned current_length; | ||||
// New size computation. It is simplistic right now : it returns twice the amount | // New size computation. It is simplistic right now : it returns twice the amount | |||
// we need | // we need | |||
unsigned assign_new_size (unsigned minimum_to_allocate) | unsigned assign_new_size (unsigned minimum_to_allocate) | |||
{ | { | |||
return minimum_to_allocate * 2; | return minimum_to_allocate * 2; | |||
} | } | |||
// Internal function that clears the content of a TiXmlString | // Internal function that clears the content of a TiXmlString | |||
void empty_it () | void empty_it () | |||
{ | { | |||
if (cstring) | if (cstring) | |||
delete [] cstring; | delete [] cstring; | |||
cstring = NULL; | cstring = NULL; | |||
allocated = 0; | allocated = 0; | |||
current_length = 0; | ||||
} | } | |||
void append (const char *suffix ); | void append (const char *suffix ); | |||
// append function for another TiXmlString | // append function for another TiXmlString | |||
void append (const TiXmlString & suffix) | void append (const TiXmlString & suffix) | |||
{ | { | |||
append (suffix . c_str ()); | append (suffix . c_str ()); | |||
} | } | |||
End of changes. 4 change blocks. | ||||
0 lines changed or deleted | 5 lines changed or added | |||
tinyxml.h | tinyxml.h | |||
---|---|---|---|---|
skipping to change at line 51 | skipping to change at line 51 | |||
#define DEBUG | #define DEBUG | |||
#endif | #endif | |||
#if defined( DEBUG ) && defined( _MSC_VER ) | #if defined( DEBUG ) && defined( _MSC_VER ) | |||
#include <windows.h> | #include <windows.h> | |||
#define TIXML_LOG OutputDebugString | #define TIXML_LOG OutputDebugString | |||
#else | #else | |||
#define TIXML_LOG printf | #define TIXML_LOG printf | |||
#endif | #endif | |||
// Uncomment the following definition for Apple's Project Builder | ||||
// #define TIXML_NEED_STREAM | ||||
#ifdef TIXML_USE_STL | #ifdef TIXML_USE_STL | |||
#include <string> | #include <string> | |||
#ifdef TIXML_NEED_STREAM | ||||
#include <istream> | ||||
#include <ostream> | ||||
#endif | ||||
#define TIXML_STRING std::string | #define TIXML_STRING std::string | |||
#define TIXML_ISTREAM std::istream | #define TIXML_ISTREAM std::istream | |||
#define TIXML_OSTREAM std::ostream | #define TIXML_OSTREAM std::ostream | |||
#else | #else | |||
#include "tinystr.h" | #include "tinystr.h" | |||
#define TIXML_STRING TiXmlString | #define TIXML_STRING TiXmlString | |||
#define TIXML_OSTREAM TiXmlOutStream | #define TIXML_OSTREAM TiXmlOutStream | |||
#endif | #endif | |||
class TiXmlDocument; | class TiXmlDocument; | |||
skipping to change at line 362 | skipping to change at line 369 | |||
#ifdef TIXML_USE_STL | #ifdef TIXML_USE_STL | |||
TiXmlNode* IterateChildren( const std::string& value, TiXmlNode* pre vious ) const { return IterateChildren (value.c_str (), previou s); } ///< STL std::string form. | TiXmlNode* IterateChildren( const std::string& value, TiXmlNode* pre vious ) const { return IterateChildren (value.c_str (), previou s); } ///< STL std::string form. | |||
#endif | #endif | |||
/** Add a new node related to this. Adds a child past the LastChild. | /** Add a new node related to this. Adds a child past the LastChild. | |||
Returns a pointer to the new object or NULL if an error occu red. | Returns a pointer to the new object or NULL if an error occu red. | |||
*/ | */ | |||
TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); | TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); | |||
/** Add a new node related to this. Adds a child past the LastChild. | ||||
NOTE: the node to be added is passed by pointer, and will be | ||||
henceforth owned (and deleted) by tinyXml. This method is ef | ||||
ficient | ||||
and avoids an extra copy, but should be used with care as it | ||||
uses a different memory model than the other insert function | ||||
s. | ||||
@sa InsertEndChild | ||||
*/ | ||||
TiXmlNode* LinkEndChild( TiXmlNode* addThis ); | ||||
/** Add a new node related to this. Adds a child before the specifie d child. | /** Add a new node related to this. Adds a child before the specifie d child. | |||
Returns a pointer to the new object or NULL if an error occu red. | Returns a pointer to the new object or NULL if an error occu red. | |||
*/ | */ | |||
TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode & addThis ); | TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode & addThis ); | |||
/** Add a new node related to this. Adds a child after the specified child. | /** Add a new node related to this. Adds a child after the specified child. | |||
Returns a pointer to the new object or NULL if an error occu red. | Returns a pointer to the new object or NULL if an error occu red. | |||
*/ | */ | |||
TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); | TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); | |||
skipping to change at line 454 | skipping to change at line 472 | |||
void* GetUserData() { re turn userData; } | void* GetUserData() { re turn userData; } | |||
protected: | protected: | |||
TiXmlNode( NodeType type ); | TiXmlNode( NodeType type ); | |||
#ifdef TIXML_USE_STL | #ifdef TIXML_USE_STL | |||
// The real work of the input operator. | // The real work of the input operator. | |||
virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0; | virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0; | |||
#endif | #endif | |||
// The node is passed in by ownership. This object will delete it. | ||||
TiXmlNode* LinkEndChild( TiXmlNode* addThis ); | ||||
// Figure out what is at *p, and parse it. Returns null if it is not an xml node. | // Figure out what is at *p, and parse it. Returns null if it is not an xml node. | |||
TiXmlNode* Identify( const char* start ); | TiXmlNode* Identify( const char* start ); | |||
void CopyToClone( TiXmlNode* target ) const { target->SetValue ( value.c_str() ); | void CopyToClone( TiXmlNode* target ) const { target->SetValue ( value.c_str() ); | |||
target->userData = userData; } | target->userData = userData; } | |||
// Internal Value function returning a TIXML_STRING | // Internal Value function returning a TIXML_STRING | |||
TIXML_STRING SValue() const { return value ; } | TIXML_STRING SValue() const { return value ; } | |||
TiXmlNode* parent; | TiXmlNode* parent; | |||
NodeType type; | NodeType type; | |||
skipping to change at line 744 | skipping to change at line 759 | |||
virtual ~TiXmlText() {} | virtual ~TiXmlText() {} | |||
#ifdef TIXML_USE_STL | #ifdef TIXML_USE_STL | |||
/// Constructor. | /// Constructor. | |||
TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TE XT) | TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TE XT) | |||
{ | { | |||
SetValue( initValue ); | SetValue( initValue ); | |||
} | } | |||
#endif | #endif | |||
// [internal use] | ||||
virtual void Print( FILE* cfile, int depth ) const; | ||||
protected : | protected : | |||
// [internal use] Creates a new Element and returns it. | // [internal use] Creates a new Element and returns it. | |||
virtual TiXmlNode* Clone() const; | virtual TiXmlNode* Clone() const; | |||
// [internal use] | ||||
virtual void Print( FILE* cfile, int depth ) const; | ||||
virtual void StreamOut ( TIXML_OSTREAM * out ) const; | virtual void StreamOut ( TIXML_OSTREAM * out ) const; | |||
// [internal use] | // [internal use] | |||
bool Blank() const; // returns true if all white space and new l ines | bool Blank() const; // returns true if all white space and new l ines | |||
/* [internal use] | /* [internal use] | |||
Attribtue parsing starts: First char of the text | Attribtue parsing starts: First char of the text | |||
returns: next char past '>' | returns: next char past '>' | |||
*/ | */ | |||
virtual const char* Parse( const char* p ); | virtual const char* Parse( const char* p ); | |||
// [internal use] | // [internal use] | |||
#ifdef TIXML_USE_STL | #ifdef TIXML_USE_STL | |||
End of changes. 6 change blocks. | ||||
5 lines changed or deleted | 23 lines changed or added | |||