27 #ifndef TIXML_STRING_INCLUDED
28 #define TIXML_STRING_INCLUDED
37 #if defined(_MSC_VER) && (_MSC_VER >= 1200 )
39 #define TIXML_EXPLICIT explicit
40 #elif defined(__GNUC__) && (__GNUC__ >= 3 )
42 #define TIXML_EXPLICIT explicit
44 #define TIXML_EXPLICIT
62 static const size_type
npos;
80 init( static_cast<size_type>( strlen(copy) ));
81 memcpy(start(), copy,
length());
88 memcpy(start(), str, len);
99 return assign( copy, (size_type)strlen(copy));
111 return append(suffix, static_cast<size_type>( strlen(suffix) ));
117 return append(&single, 1);
128 const char *
c_str ()
const {
return rep_->str; }
131 const char *
data ()
const {
return rep_->str; }
134 size_type
length ()
const {
return rep_->size; }
137 size_type
size ()
const {
return rep_->size; }
140 bool empty ()
const {
return rep_->size == 0; }
143 size_type
capacity ()
const {
return rep_->capacity; }
147 const char&
at (size_type index)
const
149 assert( index <
length() );
150 return rep_->str[ index ];
156 assert( index <
length() );
157 return rep_->str[ index ];
161 size_type
find (
char lookup)
const
163 return find(lookup, 0);
167 size_type
find (
char tofind, size_type offset)
const
171 for (
const char* p =
c_str() + offset; *p !=
'\0'; ++p)
173 if (*p == tofind)
return static_cast< size_type
>( p -
c_str() );
206 void init(size_type sz) { init(sz, sz); }
207 void set_size(size_type sz) { rep_->str[ rep_->size = sz ] =
'\0'; }
208 char* start()
const {
return rep_->str; }
209 char* finish()
const {
return rep_->str + rep_->size; }
217 void init(size_type sz, size_type cap)
226 const size_type bytesNeeded =
sizeof(Rep) + cap;
227 const size_type intsNeeded = ( bytesNeeded +
sizeof(int) - 1 ) /
sizeof( int );
228 rep_ =
reinterpret_cast<Rep*
>(
new int[ intsNeeded ] );
230 rep_->str[ rep_->size = sz ] =
'\0';
231 rep_->capacity = cap;
241 if (rep_ != &nullrep_)
245 delete [] (
reinterpret_cast<int*
>( rep_ ) );
304 #endif // TIXML_STRING_INCLUDED
305 #endif // TIXML_USE_STL
const char & at(size_type index) const
Definition: tinystr.h:147
size_type find(char lookup) const
Definition: tinystr.h:161
const char * c_str() const
Definition: tinystr.h:128
TiXmlString()
Definition: tinystr.h:66
size_type find(char tofind, size_type offset) const
Definition: tinystr.h:167
void clear()
Definition: tinystr.h:178
char & operator[](size_type index) const
Definition: tinystr.h:154
size_type length() const
Definition: tinystr.h:134
bool operator>(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:266
#define TIXML_EXPLICIT
Definition: tinystr.h:44
bool operator>=(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:268
Definition: tinystr.h:284
const char * data() const
Definition: tinystr.h:131
size_type size() const
Definition: tinystr.h:137
TiXmlOutStream & operator<<(const TiXmlString &in)
Definition: tinystr.h:289
void reserve(size_type cap)
TiXmlString & append(const char *str, size_type len)
TiXmlString & operator+=(const char *suffix)
Definition: tinystr.h:109
bool operator<=(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:267
bool operator==(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:255
bool operator<(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:260
size_t size_type
Definition: tinystr.h:59
static const size_type npos
Definition: tinystr.h:62
bool operator!=(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:265
TiXmlString operator+(const TiXmlString &a, const TiXmlString &b)
TIXML_EXPLICIT TiXmlString(const char *copy)
Definition: tinystr.h:78
bool empty() const
Definition: tinystr.h:140
TIXML_EXPLICIT TiXmlString(const char *str, size_type len)
Definition: tinystr.h:85
TiXmlString & operator=(const char *copy)
Definition: tinystr.h:97
size_type capacity() const
Definition: tinystr.h:143
TiXmlString & assign(const char *str, size_type len)
void swap(TiXmlString &other)
Definition: tinystr.h:197
TiXmlString(const TiXmlString ©)
Definition: tinystr.h:71
~TiXmlString()
Definition: tinystr.h:92