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

#include <tinystr.h>

+ Inheritance diagram for TiXmlOutStream:
+ Collaboration diagram for TiXmlOutStream:

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
 

Public Types

typedef size_t size_type
 

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.

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

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

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 reserve(size_type cap)
Definition: tinystr.cpp:40
void set_size(size_type sz)
Definition: tinystr.h:203
size_t size_type
Definition: tinystr.h:74
size_type length() const
Definition: tinystr.h:137
char * finish() const
Definition: tinystr.h:205
+ 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.

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

Referenced by TiXmlString::operator=().

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 }
void swap(TiXmlString &other)
Definition: tinystr.h:195
size_type capacity() const
Definition: tinystr.h:146
void init(size_type sz)
Definition: tinystr.h:202
void set_size(size_type sz)
Definition: tinystr.h:203
char * start() const
Definition: tinystr.h:204
size_t size_type
Definition: tinystr.h:74
+ 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.

References TiXmlString::length(), TiXmlString::rep_, and TiXmlString::Rep::str.

149  {
150  assert(index < length());
151  return rep_->str[index];
152  }
Rep * rep_
Definition: tinystr.h:239
char str[1]
Definition: tinystr.h:209
size_type length() const
Definition: tinystr.h:137
+ 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.

References TiXmlString::rep_, and TiXmlString::Rep::str.

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

131 { return rep_->str; }
Rep * rep_
Definition: tinystr.h:239
char str[1]
Definition: tinystr.h:209
+ Here is the caller graph for this function:

◆ capacity()

size_type TiXmlString::capacity ( ) const
inlineinherited

Definition at line 146 of file tinystr.h.

References TiXmlString::Rep::capacity, and TiXmlString::rep_.

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

146 { return rep_->capacity; }
Rep * rep_
Definition: tinystr.h:239
size_type capacity
Definition: tinystr.h:208
+ Here is the caller graph for this function:

◆ clear()

void TiXmlString::clear ( )
inlineinherited

Definition at line 175 of file tinystr.h.

References TiXmlString::init(), and TiXmlString::quit().

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
void init(size_type sz)
Definition: tinystr.h:202
+ Here is the call graph for this function:

◆ data()

const char* TiXmlString::data ( ) const
inlineinherited

Definition at line 134 of file tinystr.h.

References TiXmlString::rep_, and TiXmlString::Rep::str.

Referenced by TiXmlString::operator+=().

134 { return rep_->str; }
Rep * rep_
Definition: tinystr.h:239
char str[1]
Definition: tinystr.h:209
+ Here is the caller graph for this function:

◆ empty()

bool TiXmlString::empty ( ) const
inlineinherited

Definition at line 143 of file tinystr.h.

References TiXmlString::rep_, and TiXmlString::Rep::size.

143 { return rep_->size == 0; }
size_type size
Definition: tinystr.h:208
Rep * rep_
Definition: tinystr.h:239

◆ find() [1/2]

size_type TiXmlString::find ( char  lookup) const
inlineinherited

Definition at line 161 of file tinystr.h.

References TiXmlString::find().

161 { return find(lookup, 0); }
size_type find(char lookup) const
Definition: tinystr.h:161
+ Here is the call 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.

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

Referenced by TiXmlString::find().

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  }
static const size_type npos
Definition: tinystr.h:77
size_t size_type
Definition: tinystr.h:74
size_type length() const
Definition: tinystr.h:137
const char * c_str() const
Definition: tinystr.h:131
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ length()

size_type TiXmlString::length ( ) const
inlineinherited

Definition at line 137 of file tinystr.h.

References TiXmlString::rep_, and TiXmlString::Rep::size.

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

137 { return rep_->size; }
size_type size
Definition: tinystr.h:208
Rep * rep_
Definition: tinystr.h:239
+ Here is the caller graph for this function:

◆ operator+=() [1/3]

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

Definition at line 118 of file tinystr.h.

Referenced by operator<<().

118  {
119  return append(suffix, static_cast< size_type >(strlen(suffix)));
120  }
TiXmlString & append(const char *str, size_type len)
Definition: tinystr.cpp:65
+ Here is the caller graph for this function:

◆ operator+=() [2/3]

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

Definition at line 123 of file tinystr.h.

References TiXmlString::append().

123 { return append(&single, 1); }
TiXmlString & append(const char *str, size_type len)
Definition: tinystr.cpp:65
+ 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.

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

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

126  {
127  return append(suffix.data(), suffix.length());
128  }
size_type length() const
Definition: tinystr.h:137
TiXmlString & append(const char *str, size_type len)
Definition: tinystr.cpp:65
const char * data() const
Definition: tinystr.h:134
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<<() [1/2]

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

Definition at line 280 of file tinystr.h.

References TiXmlString::operator+=().

280  {
281  *this += in;
282  return *this;
283  }
+ Here is the call graph for this function:

◆ operator<<() [2/2]

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

Definition at line 286 of file tinystr.h.

References TiXmlString::operator+=().

286  {
287  *this += in;
288  return *this;
289  }
+ 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.

References TiXmlString::length(), TiXmlString::rep_, and TiXmlString::Rep::str.

155  {
156  assert(index < length());
157  return rep_->str[index];
158  }
Rep * rep_
Definition: tinystr.h:239
char str[1]
Definition: tinystr.h:209
size_type length() const
Definition: tinystr.h:137
+ Here is the call graph for this function:

◆ reserve()

void TiXmlString::reserve ( size_type  cap)
inherited

Definition at line 40 of file tinystr.cpp.

References TiXmlString::capacity(), TiXmlString::init(), TiXmlString::length(), and TiXmlString::swap().

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

40  {
41  if (cap > capacity()) {
42  TiXmlString tmp;
43  tmp.init(length(), cap);
44  memcpy(tmp.start(), data(), length());
45  swap(tmp);
46  }
47 }
void swap(TiXmlString &other)
Definition: tinystr.h:195
size_type capacity() const
Definition: tinystr.h:146
void init(size_type sz)
Definition: tinystr.h:202
char * start() const
Definition: tinystr.h:204
size_type length() const
Definition: tinystr.h:137
const char * data() const
Definition: tinystr.h:134
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size()

size_type TiXmlString::size ( ) const
inlineinherited

Definition at line 140 of file tinystr.h.

References TiXmlString::rep_, and TiXmlString::Rep::size.

140 { return rep_->size; }
size_type size
Definition: tinystr.h:208
Rep * rep_
Definition: tinystr.h:239

◆ swap()

void TiXmlString::swap ( TiXmlString other)
inlineinherited

Definition at line 195 of file tinystr.h.

References TiXmlString::rep_.

Referenced by TiXmlString::assign(), and TiXmlString::reserve().

195  {
196  Rep* r = rep_;
197  rep_ = other.rep_;
198  other.rep_ = r;
199  }
Rep * rep_
Definition: tinystr.h:239
+ 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 TiXmlString::find().


The documentation for this class was generated from the following file: