#include <OBTtinystr.h>
Public Types | |
typedef size_t | size_type |
Public Member Functions | |
TiXmlString () | |
TiXmlString (const TiXmlString ©) | |
TIXML_EXPLICIT | TiXmlString (const char *copy) |
TIXML_EXPLICIT | TiXmlString (const char *str, size_type len) |
~TiXmlString () | |
TiXmlString & | operator= (const char *copy) |
TiXmlString & | operator= (const TiXmlString ©) |
TiXmlString & | operator+= (const char *suffix) |
TiXmlString & | operator+= (char single) |
TiXmlString & | operator+= (const TiXmlString &suffix) |
const char * | c_str () const |
const char * | data () const |
size_type | length () const |
size_type | size () const |
bool | empty () const |
size_type | capacity () const |
const char & | at (size_type index) const |
char & | operator[] (size_type index) const |
size_type | find (char lookup) const |
size_type | find (char tofind, size_type offset) const |
void | clear () |
void | reserve (size_type cap) |
TiXmlString & | assign (const char *str, size_type len) |
TiXmlString & | append (const char *str, size_type len) |
void | swap (TiXmlString &other) |
Static Public Attributes | |
static const size_type | npos = static_cast< TiXmlString::size_type >(-1) |
Private Member Functions | |
void | init (size_type sz) |
void | set_size (size_type sz) |
char * | start () const |
char * | finish () const |
void | init (size_type sz, size_type cap) |
void | quit () |
Private Attributes | |
Rep * | rep_ |
Static Private Attributes | |
static Rep | nullrep_ = { 0, 0, { '\0' } } |
Classes | |
struct | Rep |
Definition at line 68 of file tmp/OBTtinystr.h.
typedef size_t xmlTiny::TiXmlString::size_type |
Definition at line 72 of file tmp/OBTtinystr.h.
xmlTiny::TiXmlString::TiXmlString | ( | ) | [inline] |
xmlTiny::TiXmlString::TiXmlString | ( | const TiXmlString & | copy | ) | [inline] |
TIXML_EXPLICIT xmlTiny::TiXmlString::TiXmlString | ( | const char * | copy | ) | [inline] |
TIXML_EXPLICIT xmlTiny::TiXmlString::TiXmlString | ( | const char * | str, | |
size_type | len | |||
) | [inline] |
xmlTiny::TiXmlString::~TiXmlString | ( | ) | [inline] |
TiXmlString& xmlTiny::TiXmlString::operator= | ( | const char * | copy | ) | [inline] |
TiXmlString& xmlTiny::TiXmlString::operator= | ( | const TiXmlString & | copy | ) | [inline] |
TiXmlString& xmlTiny::TiXmlString::operator+= | ( | const char * | suffix | ) | [inline] |
Definition at line 124 of file tmp/OBTtinystr.h.
References append().
00125 { 00126 return append(suffix, static_cast<size_type>( strlen(suffix) )); 00127 }
TiXmlString& xmlTiny::TiXmlString::operator+= | ( | char | single | ) | [inline] |
Definition at line 130 of file tmp/OBTtinystr.h.
References append().
00131 { 00132 return append(&single, 1); 00133 }
TiXmlString& xmlTiny::TiXmlString::operator+= | ( | const TiXmlString & | suffix | ) | [inline] |
const char* xmlTiny::TiXmlString::c_str | ( | ) | const [inline] |
Definition at line 143 of file tmp/OBTtinystr.h.
References rep_, and xmlTiny::TiXmlString::Rep::str.
Referenced by find(), xmlTiny::operator<(), and xmlTiny::operator==().
const char* xmlTiny::TiXmlString::data | ( | ) | const [inline] |
Definition at line 146 of file tmp/OBTtinystr.h.
References rep_, and xmlTiny::TiXmlString::Rep::str.
Referenced by operator+=(), reserve(), and TiXmlString().
size_type xmlTiny::TiXmlString::length | ( | ) | const [inline] |
Definition at line 149 of file tmp/OBTtinystr.h.
References rep_, and xmlTiny::TiXmlString::Rep::size.
Referenced by append(), at(), find(), xmlTiny::operator+(), operator+=(), operator=(), xmlTiny::operator==(), operator[](), reserve(), and TiXmlString().
size_type xmlTiny::TiXmlString::size | ( | ) | const [inline] |
Definition at line 152 of file tmp/OBTtinystr.h.
References rep_, and xmlTiny::TiXmlString::Rep::size.
bool xmlTiny::TiXmlString::empty | ( | ) | const [inline] |
Definition at line 155 of file tmp/OBTtinystr.h.
References rep_, and xmlTiny::TiXmlString::Rep::size.
size_type xmlTiny::TiXmlString::capacity | ( | ) | const [inline] |
Definition at line 158 of file tmp/OBTtinystr.h.
References xmlTiny::TiXmlString::Rep::capacity, and rep_.
Referenced by append(), assign(), and reserve().
const char& xmlTiny::TiXmlString::at | ( | size_type | index | ) | const [inline] |
Definition at line 162 of file tmp/OBTtinystr.h.
References length(), rep_, and xmlTiny::TiXmlString::Rep::str.
char& xmlTiny::TiXmlString::operator[] | ( | size_type | index | ) | const [inline] |
Definition at line 169 of file tmp/OBTtinystr.h.
References length(), rep_, and xmlTiny::TiXmlString::Rep::str.
size_type xmlTiny::TiXmlString::find | ( | char | lookup | ) | const [inline] |
Definition at line 182 of file tmp/OBTtinystr.h.
References c_str(), length(), and npos.
00183 { 00184 if (offset >= length()) return npos; 00185 00186 for (const char* p = c_str() + offset; *p != '\0'; ++p) 00187 { 00188 if (*p == tofind) return static_cast< size_type >( p - c_str() ); 00189 } 00190 return npos; 00191 }
void xmlTiny::TiXmlString::clear | ( | ) | [inline] |
void xmlTiny::TiXmlString::reserve | ( | size_type | cap | ) |
Definition at line 44 of file tmp/OBTtinystr.cpp.
References capacity(), data(), init(), length(), start(), and swap().
Referenced by append(), and xmlTiny::operator+().
00045 { 00046 if (cap > capacity()) 00047 { 00048 TiXmlString tmp; 00049 tmp.init(length(), cap); 00050 memcpy(tmp.start(), data(), length()); 00051 swap(tmp); 00052 } 00053 }
TiXmlString & xmlTiny::TiXmlString::assign | ( | const char * | str, | |
size_type | len | |||
) |
Definition at line 56 of file tmp/OBTtinystr.cpp.
References capacity(), init(), set_size(), start(), and swap().
Referenced by operator=().
00057 { 00058 size_type cap = capacity(); 00059 if (len > cap || cap > 3*(len + 8)) 00060 { 00061 TiXmlString tmp; 00062 tmp.init(len); 00063 memcpy(tmp.start(), str, len); 00064 swap(tmp); 00065 } 00066 else 00067 { 00068 memmove(start(), str, len); 00069 set_size(len); 00070 } 00071 return *this; 00072 }
TiXmlString & xmlTiny::TiXmlString::append | ( | const char * | str, | |
size_type | len | |||
) |
Definition at line 75 of file tmp/OBTtinystr.cpp.
References capacity(), finish(), length(), reserve(), and set_size().
Referenced by xmlTiny::operator+(), and operator+=().
00076 { 00077 size_type newsize = length() + len; 00078 if (newsize > capacity()) 00079 { 00080 reserve (newsize + capacity()); 00081 } 00082 memmove(finish(), str, len); 00083 set_size(newsize); 00084 return *this; 00085 }
void xmlTiny::TiXmlString::swap | ( | TiXmlString & | other | ) | [inline] |
void xmlTiny::TiXmlString::init | ( | size_type | sz | ) | [inline, private] |
Definition at line 221 of file tmp/OBTtinystr.h.
Referenced by assign(), clear(), reserve(), and TiXmlString().
00221 { init(sz, sz); }
void xmlTiny::TiXmlString::set_size | ( | size_type | sz | ) | [inline, private] |
Definition at line 222 of file tmp/OBTtinystr.h.
References rep_, xmlTiny::TiXmlString::Rep::size, and xmlTiny::TiXmlString::Rep::str.
Referenced by append(), and assign().
char* xmlTiny::TiXmlString::start | ( | ) | const [inline, private] |
Definition at line 223 of file tmp/OBTtinystr.h.
References rep_, and xmlTiny::TiXmlString::Rep::str.
Referenced by assign(), operator=(), reserve(), and TiXmlString().
char* xmlTiny::TiXmlString::finish | ( | ) | const [inline, private] |
Definition at line 224 of file tmp/OBTtinystr.h.
References rep_, xmlTiny::TiXmlString::Rep::size, and xmlTiny::TiXmlString::Rep::str.
Referenced by append().
Definition at line 232 of file tmp/OBTtinystr.h.
References xmlTiny::TiXmlString::Rep::capacity, nullrep_, rep_, xmlTiny::TiXmlString::Rep::size, and xmlTiny::TiXmlString::Rep::str.
00233 { 00234 if (cap) 00235 { 00236 // Lee: the original form: 00237 // rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap)); 00238 // doesn't work in some cases of new being overloaded. Switching 00239 // to the normal allocation, although use an 'int' for systems 00240 // that are overly picky about structure alignment. 00241 const size_type bytesNeeded = sizeof(Rep) + cap; 00242 const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); 00243 rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] ); 00244 00245 rep_->str[ rep_->size = sz ] = '\0'; 00246 rep_->capacity = cap; 00247 } 00248 else 00249 { 00250 rep_ = &nullrep_; 00251 } 00252 }
void xmlTiny::TiXmlString::quit | ( | ) | [inline, private] |
Definition at line 254 of file tmp/OBTtinystr.h.
References nullrep_, and rep_.
Referenced by clear(), and ~TiXmlString().
00255 { 00256 if (rep_ != &nullrep_) 00257 { 00258 // The rep_ is really an array of ints. (see the allocator, above). 00259 // Cast it back before delete, so the compiler won't incorrectly call destructors. 00260 delete [] ( reinterpret_cast<int*>( rep_ ) ); 00261 } 00262 }
const TiXmlString::size_type xmlTiny::TiXmlString::npos = static_cast< TiXmlString::size_type >(-1) [static] |
Rep* xmlTiny::TiXmlString::rep_ [private] |
Definition at line 264 of file tmp/OBTtinystr.h.
Referenced by at(), c_str(), capacity(), data(), empty(), finish(), init(), length(), operator[](), quit(), set_size(), size(), start(), and swap().
TiXmlString::Rep xmlTiny::TiXmlString::nullrep_ = { 0, 0, { '\0' } } [static, private] |