TiXmlString Class Reference

#include <tinystr.h>

Inheritance diagram for TiXmlString:
Inheritance graph
[legend]
Collaboration diagram for TiXmlString:
Collaboration graph
[legend]

List of all members.

Classes

struct  Rep

Public Types

typedef vcl_size_t size_type

Public Member Functions

 TiXmlString ()
 TiXmlString (const TiXmlString &copy)
TIXML_EXPLICIT TiXmlString (const char *copy)
TIXML_EXPLICIT TiXmlString (const char *str, size_type len)
 ~TiXmlString ()
TiXmlStringoperator= (const char *copy)
TiXmlStringoperator= (const TiXmlString &copy)
TiXmlStringoperator+= (const char *suffix)
TiXmlStringoperator+= (char single)
TiXmlStringoperator+= (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)
TiXmlStringassign (const char *str, size_type len)
TiXmlStringappend (const char *str, size_type len)
void swap (TiXmlString &other)

Static Public Attributes

static const size_type npos = static_cast< TiXmlString::size_type >(-1)

Detailed Description

Definition at line 73 of file tinystr.h.


Member Typedef Documentation

typedef vcl_size_t TiXmlString::size_type

Definition at line 77 of file tinystr.h.


Constructor & Destructor Documentation

TiXmlString::TiXmlString (  )  [inline]

Definition at line 84 of file tinystr.h.

00084                        : rep_(&nullrep_)
00085         {
00086         }

TiXmlString::TiXmlString ( const TiXmlString copy  )  [inline]

Definition at line 89 of file tinystr.h.

References data(), and length().

00089                                                 : rep_(0)
00090         {
00091                 init(copy.length());
00092                 memcpy(start(), copy.data(), length());
00093         }

TIXML_EXPLICIT TiXmlString::TiXmlString ( const char *  copy  )  [inline]

Definition at line 96 of file tinystr.h.

References length().

00096                                                         : rep_(0)
00097         {
00098                 init( static_cast<size_type>( strlen(copy) ));
00099                 memcpy(start(), copy, length());
00100         }

TIXML_EXPLICIT TiXmlString::TiXmlString ( const char *  str,
size_type  len 
) [inline]

Definition at line 103 of file tinystr.h.

00103                                                                       : rep_(0)
00104         {
00105                 init(len);
00106                 memcpy(start(), str, len);
00107         }

TiXmlString::~TiXmlString (  )  [inline]

Definition at line 110 of file tinystr.h.

00111         {
00112                 quit();
00113         }


Member Function Documentation

TiXmlString & TiXmlString::append ( const char *  str,
size_type  len 
)

Definition at line 73 of file tinystr.cpp.

References capacity(), length(), and reserve().

Referenced by operator+(), and operator+=().

00074 {
00075         size_type newsize = length() + len;
00076         if (newsize > capacity())
00077         {
00078                 reserve (newsize + capacity());
00079         }
00080         memmove(finish(), str, len);
00081         set_size(newsize);
00082         return *this;
00083 }

TiXmlString & TiXmlString::assign ( const char *  str,
size_type  len 
)

Definition at line 54 of file tinystr.cpp.

References capacity(), and swap().

Referenced by operator=().

00055 {
00056         size_type cap = capacity();
00057         if (len > cap || cap > 3*(len + 8))
00058         {
00059                 TiXmlString tmp;
00060                 tmp.init(len);
00061                 memcpy(tmp.start(), str, len);
00062                 swap(tmp);
00063         }
00064         else
00065         {
00066                 memmove(start(), str, len);
00067                 set_size(len);
00068         }
00069         return *this;
00070 }

const char& TiXmlString::at ( size_type  index  )  const [inline]

Definition at line 167 of file tinystr.h.

References length().

00168         {
00169                 assert( index < length() );
00170                 return rep_->str[ index ];
00171         }

const char* TiXmlString::c_str (  )  const [inline]

Definition at line 148 of file tinystr.h.

Referenced by find(), operator<(), and operator==().

00148 { return rep_->str; }

size_type TiXmlString::capacity (  )  const [inline]

Definition at line 163 of file tinystr.h.

Referenced by append(), assign(), and reserve().

00163 { return rep_->capacity; }

void TiXmlString::clear (  )  [inline]

Definition at line 198 of file tinystr.h.

00199         {
00200                 //Lee:
00201                 //The original was just too strange, though correct:
00202                 //      TiXmlString().swap(*this);
00203                 //Instead use the quit & re-init:
00204                 quit();
00205                 init(0,0);
00206         }

const char* TiXmlString::data (  )  const [inline]

Definition at line 151 of file tinystr.h.

Referenced by operator+=(), reserve(), and TiXmlString().

00151 { return rep_->str; }

bool TiXmlString::empty (  )  const [inline]

Definition at line 160 of file tinystr.h.

00160 { return rep_->size == 0; }

size_type TiXmlString::find ( char  tofind,
size_type  offset 
) const [inline]

Definition at line 187 of file tinystr.h.

References c_str(), length(), and npos.

00188         {
00189                 if (offset >= length()) return npos;
00190 
00191                 for (const char* p = c_str() + offset; *p != '\0'; ++p)
00192                 {
00193                    if (*p == tofind) return static_cast< size_type >( p - c_str() );
00194                 }
00195                 return npos;
00196         }

size_type TiXmlString::find ( char  lookup  )  const [inline]

Definition at line 181 of file tinystr.h.

00182         {
00183                 return find(lookup, 0);
00184         }

size_type TiXmlString::length (  )  const [inline]

Definition at line 154 of file tinystr.h.

Referenced by append(), at(), find(), operator+(), operator+=(), operator=(), operator==(), operator[](), reserve(), and TiXmlString().

00154 { return rep_->size; }

TiXmlString& TiXmlString::operator+= ( const TiXmlString suffix  )  [inline]

Definition at line 141 of file tinystr.h.

References append(), data(), and length().

00142         {
00143                 return append(suffix.data(), suffix.length());
00144         }

TiXmlString& TiXmlString::operator+= ( char  single  )  [inline]

Definition at line 135 of file tinystr.h.

References append().

00136         {
00137                 return append(&single, 1);
00138         }

TiXmlString& TiXmlString::operator+= ( const char *  suffix  )  [inline]

Definition at line 129 of file tinystr.h.

References append().

00130         {
00131                 return append(suffix, static_cast<size_type>( strlen(suffix) ));
00132         }

TiXmlString& TiXmlString::operator= ( const TiXmlString copy  )  [inline]

Definition at line 122 of file tinystr.h.

References assign(), and length().

00123         {
00124                 return assign(copy.start(), copy.length());
00125         }

TiXmlString& TiXmlString::operator= ( const char *  copy  )  [inline]

Definition at line 116 of file tinystr.h.

References assign().

00117         {
00118                 return assign( copy, (size_type)strlen(copy));
00119         }

char& TiXmlString::operator[] ( size_type  index  )  const [inline]

Definition at line 174 of file tinystr.h.

References length().

00175         {
00176                 assert( index < length() );
00177                 return rep_->str[ index ];
00178         }

void TiXmlString::reserve ( size_type  cap  ) 

Definition at line 42 of file tinystr.cpp.

References capacity(), data(), length(), and swap().

Referenced by append(), and operator+().

00043 {
00044         if (cap > capacity())
00045         {
00046                 TiXmlString tmp;
00047                 tmp.init(length(), cap);
00048                 memcpy(tmp.start(), data(), length());
00049                 swap(tmp);
00050         }
00051 }

size_type TiXmlString::size (  )  const [inline]

Definition at line 157 of file tinystr.h.

00157 { return rep_->size; }

void TiXmlString::swap ( TiXmlString other  )  [inline]

Definition at line 217 of file tinystr.h.

Referenced by assign(), and reserve().

00218         {
00219                 Rep* r = rep_;
00220                 rep_ = other.rep_;
00221                 other.rep_ = r;
00222         }


Member Data Documentation

Definition at line 80 of file tinystr.h.

Referenced by find().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Generated on Tue Oct 19 14:38:49 2010 for mitk by  doxygen 1.6.3