tinystr.h | tinystr.h | |||
---|---|---|---|---|
skipping to change at line 216 | skipping to change at line 216 | |||
struct Rep | struct Rep | |||
{ | { | |||
size_type size, capacity; | size_type size, capacity; | |||
char str[1]; | char str[1]; | |||
}; | }; | |||
void init(size_type sz, size_type cap) | void init(size_type sz, size_type cap) | |||
{ | { | |||
if (cap) | if (cap) | |||
{ | { | |||
rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + | // Lee: the original form: | |||
cap)); | // rep_ = static_cast<Rep*>(operator new(sizeof | |||
(Rep) + cap)); | ||||
// doesn't work in some cases of new being overloade | ||||
d. Switching | ||||
// to the normal allocation, although use an 'int' f | ||||
or systems | ||||
// that are overly picky about structure alignment. | ||||
const size_type bytesNeeded = sizeof(Rep) + cap; | ||||
const size_type intsNeeded = ( bytesNeeded + sizeof( | ||||
int) - 1 ) / sizeof( int ); | ||||
rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] | ||||
); | ||||
rep_->str[ rep_->size = sz ] = '\0'; | rep_->str[ rep_->size = sz ] = '\0'; | |||
rep_->capacity = cap; | rep_->capacity = cap; | |||
} | } | |||
else | else | |||
{ | { | |||
rep_ = &nullrep_; | rep_ = &nullrep_; | |||
} | } | |||
} | } | |||
void quit() | void quit() | |||
{ | { | |||
if (rep_ != &nullrep_) | if (rep_ != &nullrep_) | |||
{ | { | |||
operator delete(rep_); | delete [] rep_; | |||
} | } | |||
} | } | |||
Rep * rep_; | Rep * rep_; | |||
static Rep nullrep_; | static Rep nullrep_; | |||
} ; | } ; | |||
inline bool operator == (const TiXmlString & a, const TiXmlString & b) | inline bool operator == (const TiXmlString & a, const TiXmlString & b) | |||
{ | { | |||
End of changes. 2 change blocks. | ||||
3 lines changed or deleted | 15 lines changed or added | |||
tinyxml.h | tinyxml.h | |||
---|---|---|---|---|
skipping to change at line 95 | skipping to change at line 95 | |||
class TiXmlElement; | class TiXmlElement; | |||
class TiXmlComment; | class TiXmlComment; | |||
class TiXmlUnknown; | class TiXmlUnknown; | |||
class TiXmlAttribute; | class TiXmlAttribute; | |||
class TiXmlText; | class TiXmlText; | |||
class TiXmlDeclaration; | class TiXmlDeclaration; | |||
class TiXmlParsingData; | class TiXmlParsingData; | |||
const int TIXML_MAJOR_VERSION = 2; | const int TIXML_MAJOR_VERSION = 2; | |||
const int TIXML_MINOR_VERSION = 4; | const int TIXML_MINOR_VERSION = 4; | |||
const int TIXML_PATCH_VERSION = 0; | const int TIXML_PATCH_VERSION = 1; | |||
/* Internal structure for tracking location of items | /* Internal structure for tracking location of items | |||
in the XML file. | in the XML file. | |||
*/ | */ | |||
struct TiXmlCursor | struct TiXmlCursor | |||
{ | { | |||
TiXmlCursor() { Clear(); } | TiXmlCursor() { Clear(); } | |||
void Clear() { row = col = -1; } | void Clear() { row = col = -1; } | |||
int row; // 0 based. | int row; // 0 based. | |||
skipping to change at line 950 | skipping to change at line 950 | |||
const TiXmlAttribute* FirstAttribute() const { return attributeSe t.First(); } ///< Access the first attribute in this element . | const TiXmlAttribute* FirstAttribute() const { return attributeSe t.First(); } ///< Access the first attribute in this element . | |||
TiXmlAttribute* FirstAttribute() { re turn attributeSet.First(); } | TiXmlAttribute* FirstAttribute() { re turn attributeSet.First(); } | |||
const TiXmlAttribute* LastAttribute() const { return attributeSe t.Last(); } ///< Access the last attribute in this element. | const TiXmlAttribute* LastAttribute() const { return attributeSe t.Last(); } ///< Access the last attribute in this element. | |||
TiXmlAttribute* LastAttribute() { re turn attributeSet.Last(); } | TiXmlAttribute* LastAttribute() { re turn attributeSet.Last(); } | |||
/** Convenience function for easy access to the text inside an eleme nt. Although easy | /** Convenience function for easy access to the text inside an eleme nt. Although easy | |||
and concise, GetText() is limited compared to getting the Ti XmlText child | and concise, GetText() is limited compared to getting the Ti XmlText child | |||
and accessing it directly. | and accessing it directly. | |||
If the first child of 'this' is a TiXmlText, the GetText() | If the first child of 'this' is a TiXmlText, the GetText() | |||
returs the character string of the Text node, else null is r eturned. | returns the character string of the Text node, else null is returned. | |||
This is a convenient method for getting the text of simple c ontained text: | This is a convenient method for getting the text of simple c ontained text: | |||
@verbatim | @verbatim | |||
<foo>This is text</foo> | <foo>This is text</foo> | |||
const char* str = fooElement->GetText(); | const char* str = fooElement->GetText(); | |||
@endverbatim | @endverbatim | |||
'str' will be a pointer to "This is text". | 'str' will be a pointer to "This is text". | |||
Note that this function can be misleading. If the element fo o was created from | Note that this function can be misleading. If the element fo o was created from | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 2 lines changed or added | |||