36 #ifndef TIXML_STRING_INCLUDED 37 #define TIXML_STRING_INCLUDED 46 #if defined(_MSC_VER) && (_MSC_VER >= 1200 ) 48 #define TIXML_EXPLICIT explicit 49 #elif defined(__GNUC__) && (__GNUC__ >= 3 ) 51 #define TIXML_EXPLICIT explicit 53 #define TIXML_EXPLICIT 71 static const size_type
npos;
89 init( static_cast<size_type>( strlen(copy) ));
90 memcpy(start(), copy,
length());
97 memcpy(start(), str, len);
108 return assign( copy, (size_type)strlen(copy));
120 return append(suffix, static_cast<size_type>( strlen(suffix) ));
126 return append(&single, 1);
137 const char *
c_str ()
const {
return rep_->str; }
140 const char *
data ()
const {
return rep_->str; }
143 size_type
length ()
const {
return rep_->size; }
146 size_type
size ()
const {
return rep_->size; }
149 bool empty ()
const {
return rep_->size == 0; }
152 size_type
capacity ()
const {
return rep_->capacity; }
156 const char&
at (size_type index)
const 158 assert( index <
length() );
159 return rep_->str[ index ];
165 assert( index <
length() );
166 return rep_->str[ index ];
170 size_type
find (
char lookup)
const 172 return find(lookup, 0);
176 size_type
find (
char tofind, size_type offset)
const 180 for (
const char* p =
c_str() + offset; *p !=
'\0'; ++p)
182 if (*p == tofind)
return static_cast< size_type
>( p -
c_str() );
215 void init(size_type sz) { init(sz, sz); }
216 void set_size(size_type sz) { rep_->str[ rep_->size = sz ] =
'\0'; }
217 char* start()
const {
return rep_->str; }
218 char* finish()
const {
return rep_->str + rep_->size; }
226 void init(size_type sz, size_type cap)
235 const size_type bytesNeeded =
sizeof(Rep) + cap;
236 const size_type intsNeeded = ( bytesNeeded +
sizeof(int) - 1 ) /
sizeof( int );
237 rep_ =
reinterpret_cast<Rep*
>(
new int[ intsNeeded ] );
239 rep_->str[ rep_->size = sz ] =
'\0';
240 rep_->capacity = cap;
250 if (rep_ != &nullrep_)
254 delete [] (
reinterpret_cast<int*
>( rep_ ) );
313 #endif // TIXML_STRING_INCLUDED 314 #endif // TIXML_USE_STL static const size_type npos
bool operator>(const TiXmlString &a, const TiXmlString &b)
void swap(TiXmlString &other)
size_type find(char tofind, size_type offset) const
TiXmlString operator+(const TiXmlString &a, const TiXmlString &b)
const char & at(size_type index) const
bool operator<(const TiXmlString &a, const TiXmlString &b)
TiXmlString(const TiXmlString ©)
size_type capacity() const
TiXmlString & operator+=(const char *suffix)
TIXML_EXPLICIT TiXmlString(const char *str, size_type len)
TiXmlString & assign(const char *str, size_type len)
TiXmlString & operator=(const char *copy)
void reserve(size_type cap)
char & operator[](size_type index) const
size_type find(char lookup) const
const char * c_str() const
bool operator==(const TiXmlString &a, const TiXmlString &b)
Log & operator<<(Log &log, T data)
TiXmlString & append(const char *str, size_type len)
bool operator>=(const TiXmlString &a, const TiXmlString &b)
TIXML_EXPLICIT TiXmlString(const char *copy)
const char * data() const
bool operator!=(const TiXmlString &a, const TiXmlString &b)
bool operator<=(const TiXmlString &a, const TiXmlString &b)