aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
TiXmlOutStream Class Reference

#include <tinystr.h>

Inheritance diagram for TiXmlOutStream:
Collaboration diagram for TiXmlOutStream:

Public Types

typedef size_t size_type

Public Member Functions

TiXmlOutStreamoperator<< (const TiXmlString &in)
TiXmlOutStreamoperator<< (const char *in)
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

Private Member Functions

void init (size_type sz)
void init (size_type sz, size_type cap)
void set_size (size_type sz)
char * start () const
char * finish () const
void quit ()

Private Attributes

Reprep_

Static Private Attributes

static Rep nullrep_ = {0, 0, {'\0'}}

Detailed Description

Definition at line 277 of file tinystr.h.

Member Typedef Documentation

◆ size_type

typedef size_t TiXmlString::size_type
inherited

Definition at line 74 of file tinystr.h.

Member Function Documentation

◆ append()

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

Definition at line 65 of file tinystr.cpp.

65 {
66 size_type newsize = length() + len;
67
68 if (newsize > capacity()) {
69 reserve(newsize + capacity());
70 }
71
72 memmove(finish(), str, len);
73 set_size(newsize);
74 return *this;
75}
size_type capacity() const
Definition tinystr.h:146
void set_size(size_type sz)
Definition tinystr.h:203
size_type length() const
Definition tinystr.h:137
void reserve(size_type cap)
Definition tinystr.cpp:40
size_t size_type
Definition tinystr.h:74
char * finish() const
Definition tinystr.h:205

References TiXmlString(), capacity(), finish(), length(), reserve(), and set_size().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assign()

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

Definition at line 49 of file tinystr.cpp.

49 {
50 size_type cap = capacity();
51
52 if (len > cap || cap > 3 * (len + 8)) {
53 TiXmlString tmp;
54 tmp.init(len);
55 memcpy(tmp.start(), str, len);
56 swap(tmp);
57 } else {
58 memmove(start(), str, len);
59 set_size(len);
60 }
61
62 return *this;
63}
TiXmlString()
Definition tinystr.h:80
void init(size_type sz)
Definition tinystr.h:202
char * start() const
Definition tinystr.h:204
void swap(TiXmlString &other)
Definition tinystr.h:195

References TiXmlString(), capacity(), init(), set_size(), start(), and swap().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ at()

const char & TiXmlString::at ( size_type index) const
inlineinherited

Definition at line 149 of file tinystr.h.

149 {
150 assert(index < length());
151 return rep_->str[index];
152 }
Rep * rep_
Definition tinystr.h:239

References length(), and rep_.

Here is the call graph for this function:

◆ c_str()

const char * TiXmlString::c_str ( ) const
inlineinherited

Definition at line 131 of file tinystr.h.

131{ return rep_->str; }

References rep_.

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

Here is the caller graph for this function:

◆ capacity()

size_type TiXmlString::capacity ( ) const
inlineinherited

Definition at line 146 of file tinystr.h.

146{ return rep_->capacity; }

References rep_.

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

Here is the caller graph for this function:

◆ clear()

void TiXmlString::clear ( )
inlineinherited

Definition at line 175 of file tinystr.h.

175 {
176 // Lee:
177 // The original was just too strange, though correct:
178 // TiXmlString().replace(*this);
179 // Instead use the quit & re-init:
180 quit();
181 init(0, 0);
182 }
void quit()
Definition tinystr.h:230

References init(), and quit().

Here is the call graph for this function:

◆ data()

const char * TiXmlString::data ( ) const
inlineinherited

Definition at line 134 of file tinystr.h.

134{ return rep_->str; }

References rep_.

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

Here is the caller graph for this function:

◆ empty()

bool TiXmlString::empty ( ) const
inlineinherited

Definition at line 143 of file tinystr.h.

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

References rep_.

◆ find() [1/2]

size_type TiXmlString::find ( char lookup) const
inlineinherited

Definition at line 161 of file tinystr.h.

161{ return find(lookup, 0); }
size_type find(char lookup) const
Definition tinystr.h:161

References find().

Referenced by find().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find() [2/2]

size_type TiXmlString::find ( char tofind,
size_type offset ) const
inlineinherited

Definition at line 165 of file tinystr.h.

165 {
166 if (offset >= length()) return npos;
167
168 for (const char* p = c_str() + offset; *p != '\0'; ++p) {
169 if (*p == tofind) return static_cast< size_type >(p - c_str());
170 }
171
172 return npos;
173 }
const char * c_str() const
Definition tinystr.h:131
static const size_type npos
Definition tinystr.h:77

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

Here is the call graph for this function:

◆ finish()

char * TiXmlString::finish ( ) const
inlineprivateinherited

Definition at line 205 of file tinystr.h.

205{ return rep_->str + rep_->size; }

References rep_.

Referenced by append().

Here is the caller graph for this function:

◆ init() [1/2]

void TiXmlString::init ( size_type sz)
inlineprivateinherited

Definition at line 202 of file tinystr.h.

202{ init(sz, sz); }

References init().

Referenced by TiXmlString(), TiXmlString(), TiXmlString(), assign(), clear(), init(), and reserve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init() [2/2]

void TiXmlString::init ( size_type sz,
size_type cap )
inlineprivateinherited

Definition at line 212 of file tinystr.h.

212 {
213 if (cap) {
214 // Lee: the original form:
215 // rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
216 // doesn't work in some cases of new being overloaded. Switching
217 // to the normal allocation, although use an 'int' for systems
218 // that are overly picky about structure alignment.
219 const size_type bytesNeeded = sizeof(Rep) + cap;
220 const size_type intsNeeded = (bytesNeeded + sizeof(int) - 1) / sizeof(int);
221 rep_ = reinterpret_cast< Rep* >(new int[intsNeeded]);
222
223 rep_->str[rep_->size = sz] = '\0';
224 rep_->capacity = cap;
225 } else {
226 rep_ = &nullrep_;
227 }
228 }
static Rep nullrep_
Definition tinystr.h:38

References nullrep_, and rep_.

◆ length()

size_type TiXmlString::length ( ) const
inlineinherited

Definition at line 137 of file tinystr.h.

137{ return rep_->size; }

References rep_.

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

Here is the caller graph for this function:

◆ operator+=() [1/3]

TiXmlString & TiXmlString::operator+= ( char single)
inlineinherited

Definition at line 123 of file tinystr.h.

123{ return append(&single, 1); }
TiXmlString & append(const char *str, size_type len)
Definition tinystr.cpp:65

References TiXmlString(), and append().

Here is the call graph for this function:

◆ operator+=() [2/3]

TiXmlString & TiXmlString::operator+= ( const char * suffix)
inlineinherited

Definition at line 118 of file tinystr.h.

118 {
119 return append(suffix, static_cast< size_type >(strlen(suffix)));
120 }

References TiXmlString(), and append().

Here is the call graph for this function:

◆ operator+=() [3/3]

TiXmlString & TiXmlString::operator+= ( const TiXmlString & suffix)
inlineinherited

Definition at line 126 of file tinystr.h.

126 {
127 return append(suffix.data(), suffix.length());
128 }
const char * data() const
Definition tinystr.h:134

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

Here is the call graph for this function:

◆ operator<<() [1/2]

TiXmlOutStream & TiXmlOutStream::operator<< ( const char * in)
inline

Definition at line 286 of file tinystr.h.

286 {
287 *this += in;
288 return *this;
289 }

◆ operator<<() [2/2]

TiXmlOutStream & TiXmlOutStream::operator<< ( const TiXmlString & in)
inline

Definition at line 280 of file tinystr.h.

280 {
281 *this += in;
282 return *this;
283 }

References TiXmlString::TiXmlString().

Here is the call graph for this function:

◆ operator[]()

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

Definition at line 155 of file tinystr.h.

155 {
156 assert(index < length());
157 return rep_->str[index];
158 }

References length(), and rep_.

Here is the call graph for this function:

◆ quit()

void TiXmlString::quit ( )
inlineprivateinherited

Definition at line 230 of file tinystr.h.

230 {
231 if (rep_ != &nullrep_) {
232 // The rep_ is really an array of ints. (see the allocator, above).
233 // Cast it back before delete, so the compiler won't incorrectly call
234 // destructors.
235 delete[](reinterpret_cast< int* >(rep_));
236 }
237 }

References nullrep_, and rep_.

Referenced by ~TiXmlString(), and clear().

Here is the caller graph for this function:

◆ reserve()

void TiXmlString::reserve ( size_type cap)
inherited

Definition at line 40 of file tinystr.cpp.

40 {
41 if (cap > capacity()) {
42 TiXmlString tmp;
43 tmp.init(length(), cap);
44 memcpy(tmp.start(), data(), length());
45 swap(tmp);
46 }
47}

References TiXmlString(), capacity(), data(), init(), length(), start(), and swap().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_size()

void TiXmlString::set_size ( size_type sz)
inlineprivateinherited

Definition at line 203 of file tinystr.h.

203{ rep_->str[rep_->size = sz] = '\0'; }

References rep_.

Referenced by append(), and assign().

Here is the caller graph for this function:

◆ size()

size_type TiXmlString::size ( ) const
inlineinherited

Definition at line 140 of file tinystr.h.

140{ return rep_->size; }

References rep_.

◆ start()

char * TiXmlString::start ( ) const
inlineprivateinherited

Definition at line 204 of file tinystr.h.

204{ return rep_->str; }

References rep_.

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

Here is the caller graph for this function:

◆ swap()

void TiXmlString::swap ( TiXmlString & other)
inlineinherited

Definition at line 195 of file tinystr.h.

195 {
196 Rep* r = rep_;
197 rep_ = other.rep_;
198 other.rep_ = r;
199 }

References TiXmlString(), and rep_.

Referenced by assign(), and reserve().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ npos

const TiXmlString::size_type TiXmlString::npos
staticinherited
Initial value:
=
static_cast< TiXmlString::size_type >(-1)

Definition at line 77 of file tinystr.h.

Referenced by find().

◆ nullrep_

TiXmlString::Rep TiXmlString::nullrep_ = {0, 0, {'\0'}}
staticprivateinherited

Definition at line 38 of file tinystr.h.

Referenced by TiXmlString(), init(), and quit().

◆ rep_

Rep* TiXmlString::rep_
privateinherited

The documentation for this class was generated from the following file:
  • agrum/base/external/tinyxml/ticpp/tinystr.h