alternative Standard Libary  0.29.8
std::basic_string< E, TAllocator, TStorage > Template-Klassenreferenz

#include <basic_string.hpp>

+ Klassendiagramm für std::basic_string< E, TAllocator, TStorage >:
+ Zusammengehörigkeiten von std::basic_string< E, TAllocator, TStorage >:

Öffentliche Typen

using value_type = typename TStorage::value_type
 
using size_type = typename TStorage::size_type
 
using const_iterator = typename TStorage::const_iterator
 
using allocator_type = typename TStorage::allocator_type
 
using self_type = basic_string< E, TAllocator, TStorage >
 

Öffentliche Methoden

 basic_string (const allocator_type &allocator=allocator_type())
 
 basic_string (const value_type *str, const allocator_type &allocator=allocator_type())
 
 basic_string (size_type len, const allocator_type &allocator=allocator_type())
 
 basic_string (const value_type *str, size_type len, const allocator_type &allocator=allocator_type())
 
 basic_string (const basic_string &str, const allocator_type &allocator=allocator_type())
 
 ~basic_string ()
 
size_type capacity () const
 
basic_stringoperator<< (const value_type *str)
 
basic_stringoperator<< (const value_type ch)
 
basic_stringoperator<< (const basic_string &str)
 
value_type operator[] (size_type i) const
 
basic_stringoperator= (const basic_string &rhs)
 
basic_stringoperator= (const value_type *str)
 
basic_stringassign (const value_type *str, size_type len)
 
basic_stringassign (const value_type *str)
 
basic_string substr (size_type begin, size_type end) const
 
basic_string substr (size_type begin) const
 
void append (const value_type *str, size_type len)
 
void append (const basic_string &str)
 
void append (const value_type *str)
 
void append (const value_type ch)
 
basic_stringoperator+= (const basic_string &rhs)
 
int compare (const value_type *str) const
 
int compare (const basic_string &rhs) const
 
const value_typec_str () const
 
const_iterator begin () const
 
const_iterator end () const
 
size_type length () const
 
value_typedata ()
 
bool empty () const
 
const allocator_typeget_allocator () const
 
value_typereserve (size_type capacity_hint)
 
void clear ()
 
void resize (size_type size)
 
void make_lower ()
 
void make_upper ()
 
size_type find_index_of (const value_type ch) const
 
size_type find_index_of_last (const value_type ch) const
 
size_type find (const value_type *needle) const
 
size_type rfind (const value_type *needle) const
 

Statische öffentliche Attribute

static const size_type npos = size_type(-1)
 

Ausführliche Beschreibung

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
class std::basic_string< E, TAllocator, TStorage >

Dokumentation der benutzerdefinierten Datentypen

◆ allocator_type

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
using std::basic_string< E, TAllocator, TStorage >::allocator_type = typename TStorage::allocator_type

◆ const_iterator

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
using std::basic_string< E, TAllocator, TStorage >::const_iterator = typename TStorage::const_iterator

◆ self_type

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
using std::basic_string< E, TAllocator, TStorage >::self_type = basic_string<E, TAllocator, TStorage >

◆ size_type

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
using std::basic_string< E, TAllocator, TStorage >::size_type = typename TStorage::size_type

◆ value_type

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
using std::basic_string< E, TAllocator, TStorage >::value_type = typename TStorage::value_type

Beschreibung der Konstruktoren und Destruktoren

◆ basic_string() [1/5]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
std::basic_string< E, TAllocator, TStorage >::basic_string ( const allocator_type allocator = allocator_type())
inlineexplicit
59  : TStorage(allocator)
60  {
61 
62  }

◆ basic_string() [2/5]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
std::basic_string< E, TAllocator, TStorage >::basic_string ( const value_type str,
const allocator_type allocator = allocator_type() 
)
inlineexplicit
64  : TStorage(str, allocator)
65  {
66 
67  }
std::string str(T begin, T end)
Definition: utils.hpp:39

◆ basic_string() [3/5]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
std::basic_string< E, TAllocator, TStorage >::basic_string ( size_type  len,
const allocator_type allocator = allocator_type() 
)
inline
69  : TStorage(len, allocator)
70  {
71 
72  }

◆ basic_string() [4/5]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
std::basic_string< E, TAllocator, TStorage >::basic_string ( const value_type str,
size_type  len,
const allocator_type allocator = allocator_type() 
)
inline
74  : TStorage(str, len, allocator)
75  {
76 
77  }
std::string str(T begin, T end)
Definition: utils.hpp:39

◆ basic_string() [5/5]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
std::basic_string< E, TAllocator, TStorage >::basic_string ( const basic_string< E, TAllocator, TStorage > &  str,
const allocator_type allocator = allocator_type() 
)
inline
79  : TStorage(str, allocator)
80  {
81 
82  }
std::string str(T begin, T end)
Definition: utils.hpp:39

◆ ~basic_string()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
std::basic_string< E, TAllocator, TStorage >::~basic_string ( )
inline
84  {
85 
86  }

Dokumentation der Elementfunktionen

◆ append() [1/4]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
void std::basic_string< E, TAllocator, TStorage >::append ( const value_type str,
size_type  len 
)
inline
153  {
154  if( !str || len == 0 || *str == 0 )
155  return;
156  TStorage::append(str, len);
157  }
std::string str(T begin, T end)
Definition: utils.hpp:39

◆ append() [2/4]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
void std::basic_string< E, TAllocator, TStorage >::append ( const basic_string< E, TAllocator, TStorage > &  str)
inline
159  {
160  append(str.c_str(), str.length());
161  }
size_type length() const
Definition: basic_string.hpp:213
const value_type * c_str() const
Definition: basic_string.hpp:199
void append(const value_type *str, size_type len)
Definition: basic_string.hpp:152
std::string str(T begin, T end)
Definition: utils.hpp:39

◆ append() [3/4]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
void std::basic_string< E, TAllocator, TStorage >::append ( const value_type str)
inline
163  {
164  append(str, strlen(str));
165  }
void append(const value_type *str, size_type len)
Definition: basic_string.hpp:152
std::string str(T begin, T end)
Definition: utils.hpp:39

◆ append() [4/4]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
void std::basic_string< E, TAllocator, TStorage >::append ( const value_type  ch)
inline
167  {
168  append(&ch, 1);
169  }
void append(const value_type *str, size_type len)
Definition: basic_string.hpp:152

◆ assign() [1/2]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
basic_string& std::basic_string< E, TAllocator, TStorage >::assign ( const value_type str,
size_type  len 
)
inline
132  {
133  TStorage::assign(str, len);
134  assert(invariant());
135  return *this;
136  }
std::string str(T begin, T end)
Definition: utils.hpp:39

◆ assign() [2/2]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
basic_string& std::basic_string< E, TAllocator, TStorage >::assign ( const value_type str)
inline
138  {
139  return assign(str, strlen(str));
140  }
basic_string & assign(const value_type *str, size_type len)
Definition: basic_string.hpp:131
std::string str(T begin, T end)
Definition: utils.hpp:39

◆ begin()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
const_iterator std::basic_string< E, TAllocator, TStorage >::begin ( ) const
inline
205  {
206  assert(invariant()); return c_str();
207  }
const value_type * c_str() const
Definition: basic_string.hpp:199

◆ c_str()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
const value_type* std::basic_string< E, TAllocator, TStorage >::c_str ( ) const
inline
200  {
201  assert(invariant());
202  return TStorage::c_str();
203  }

◆ capacity()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
size_type std::basic_string< E, TAllocator, TStorage >::capacity ( ) const
inline
89  {
90  return TStorage::capacity();
91  }

◆ clear()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
void std::basic_string< E, TAllocator, TStorage >::clear ( )
inline
236  {
237  TStorage::clear();
238  }

◆ compare() [1/2]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
int std::basic_string< E, TAllocator, TStorage >::compare ( const value_type str) const
inline
177  {
178  const size_type thisLen = length();
179  const size_type strLen = strlen(str);
180  if (thisLen < strLen)
181  return -1;
182  if (thisLen > strLen)
183  return 1;
184 
185  return strcompare(c_str(), str, thisLen);
186  }
size_type length() const
Definition: basic_string.hpp:213
const value_type * c_str() const
Definition: basic_string.hpp:199
typename TStorage::size_type size_type
Definition: basic_string.hpp:49
std::string str(T begin, T end)
Definition: utils.hpp:39

◆ compare() [2/2]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
int std::basic_string< E, TAllocator, TStorage >::compare ( const basic_string< E, TAllocator, TStorage > &  rhs) const
inline
188  {
189  const size_type thisLen = length();
190  const size_type rhsLen = rhs.length();
191  if (thisLen < rhsLen)
192  return -1;
193  if (thisLen > rhsLen)
194  return 1;
195 
196  return strcompare(c_str(), rhs.c_str(), thisLen);
197  }
size_type length() const
Definition: basic_string.hpp:213
const value_type * c_str() const
Definition: basic_string.hpp:199
typename TStorage::size_type size_type
Definition: basic_string.hpp:49

◆ data()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
value_type* std::basic_string< E, TAllocator, TStorage >::data ( )
inline
218  {
219  return TStorage::get_data();
220  }

◆ empty()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
bool std::basic_string< E, TAllocator, TStorage >::empty ( ) const
inline
222  {
223  return length() == 0;
224  }
size_type length() const
Definition: basic_string.hpp:213

◆ end()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
const_iterator std::basic_string< E, TAllocator, TStorage >::end ( ) const
inline
209  {
210  assert(invariant()); return c_str() + length();
211  }
size_type length() const
Definition: basic_string.hpp:213
const value_type * c_str() const
Definition: basic_string.hpp:199

◆ find()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
size_type std::basic_string< E, TAllocator, TStorage >::find ( const value_type needle) const
inline
301  {
302  const value_type* s(c_str());
303  size_type si(0);
304  while(*s)
305  {
306  const value_type* n = needle;
307  if( *s == *n ) //first character matches
308  {
309  const value_type* x = s;
310  size_type match = 0;
311  while(*x && *n)
312  {
313  if( *n == *x )
314  ++match;
315  ++n;
316  ++x;
317  }
318  if( match == strlen(needle) )
319  return si;
320  }
321  ++s;
322  ++si;
323  }
324  return basic_string::npos;
325  }
const value_type * c_str() const
Definition: basic_string.hpp:199
static const size_type npos
Definition: basic_string.hpp:56
typename TStorage::value_type value_type
Definition: basic_string.hpp:48
typename TStorage::size_type size_type
Definition: basic_string.hpp:49

◆ find_index_of()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
size_type std::basic_string< E, TAllocator, TStorage >::find_index_of ( const value_type  ch) const
inline
269  {
270  size_type retIndex(basic_string::npos);
271  const E* ptr = c_str();
272  size_type currentIndex(0);
273  while (*ptr != value_type(0))
274  {
275  if (*ptr == ch)
276  {
277  retIndex = currentIndex;
278  break;
279  }
280  ++ptr;
281  ++currentIndex;
282  }
283  return retIndex;
284  }
const value_type * c_str() const
Definition: basic_string.hpp:199
static const size_type npos
Definition: basic_string.hpp:56
typename TStorage::value_type value_type
Definition: basic_string.hpp:48
typename TStorage::size_type size_type
Definition: basic_string.hpp:49

◆ find_index_of_last()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
size_type std::basic_string< E, TAllocator, TStorage >::find_index_of_last ( const value_type  ch) const
inline
286  {
287  size_type retIndex(basic_string::npos);
288  const value_type* ptr = c_str();
289  size_type currentIndex(0);
290  while (*ptr != value_type(0))
291  {
292  if (*ptr == ch)
293  retIndex = currentIndex;
294  ++ptr;
295  ++currentIndex;
296  }
297  return retIndex;
298  }
const value_type * c_str() const
Definition: basic_string.hpp:199
static const size_type npos
Definition: basic_string.hpp:56
typename TStorage::value_type value_type
Definition: basic_string.hpp:48
typename TStorage::size_type size_type
Definition: basic_string.hpp:49

◆ get_allocator()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
const allocator_type& std::basic_string< E, TAllocator, TStorage >::get_allocator ( ) const
inline
227  {
228  return TStorage::get_allocator;
229  }

◆ length()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
size_type std::basic_string< E, TAllocator, TStorage >::length ( ) const
inline
214  {
215  return TStorage::length();
216  }

◆ make_lower()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
void std::basic_string< E, TAllocator, TStorage >::make_lower ( )
inline
244  {
245  const size_type len = length();
246  TStorage::make_unique(len);
247  static const int chDelta = 'a' - 'A';
248  E* data = TStorage::get_data();
249  for (size_type i = 0; i < len; ++i)
250  {
251  if (data[i] < 'a')
252  data[i] += chDelta;
253  }
254  }
size_type length() const
Definition: basic_string.hpp:213
typename TStorage::size_type size_type
Definition: basic_string.hpp:49
value_type * data()
Definition: basic_string.hpp:217

◆ make_upper()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
void std::basic_string< E, TAllocator, TStorage >::make_upper ( )
inline
256  {
257  const size_type len = length();
258  TStorage::make_unique(len);
259  static const int chDelta = 'a' - 'A';
260  E* data = TStorage::get_data();
261  for (size_type i = 0; i < len; ++i)
262  {
263  if (data[i] > 'Z')
264  data[i] -= chDelta;
265  }
266  }
size_type length() const
Definition: basic_string.hpp:213
typename TStorage::size_type size_type
Definition: basic_string.hpp:49
value_type * data()
Definition: basic_string.hpp:217

◆ operator+=()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
basic_string& std::basic_string< E, TAllocator, TStorage >::operator+= ( const basic_string< E, TAllocator, TStorage > &  rhs)
inline
171  {
172  append(rhs);
173  return *this;
174  }
void append(const value_type *str, size_type len)
Definition: basic_string.hpp:152

◆ operator<<() [1/3]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
basic_string& std::basic_string< E, TAllocator, TStorage >::operator<< ( const value_type str)
inline
93  {
94  append(str, strlen(str));
95  return *this;
96  }
void append(const value_type *str, size_type len)
Definition: basic_string.hpp:152
std::string str(T begin, T end)
Definition: utils.hpp:39

◆ operator<<() [2/3]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
basic_string& std::basic_string< E, TAllocator, TStorage >::operator<< ( const value_type  ch)
inline
98  {
99  append(&ch, 1);
100  return *this;
101  }
void append(const value_type *str, size_type len)
Definition: basic_string.hpp:152

◆ operator<<() [3/3]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
basic_string& std::basic_string< E, TAllocator, TStorage >::operator<< ( const basic_string< E, TAllocator, TStorage > &  str)
inline
103  {
104  append(str.c_str(), str.length());
105  return *this;
106  }
size_type length() const
Definition: basic_string.hpp:213
const value_type * c_str() const
Definition: basic_string.hpp:199
void append(const value_type *str, size_type len)
Definition: basic_string.hpp:152
std::string str(T begin, T end)
Definition: utils.hpp:39

◆ operator=() [1/2]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
basic_string& std::basic_string< E, TAllocator, TStorage >::operator= ( const basic_string< E, TAllocator, TStorage > &  rhs)
inline
118  {
119  assert(rhs.invariant());
120  if (this != &rhs)
121  {
122  TStorage::operator=((TStorage&)rhs);
123  }
124  assert(invariant());
125  return *this;
126  }

◆ operator=() [2/2]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
basic_string& std::basic_string< E, TAllocator, TStorage >::operator= ( const value_type str)
inline
128  {
129  return assign(str);
130  }
basic_string & assign(const value_type *str, size_type len)
Definition: basic_string.hpp:131
std::string str(T begin, T end)
Definition: utils.hpp:39

◆ operator[]()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
value_type std::basic_string< E, TAllocator, TStorage >::operator[] ( size_type  i) const
inline
111  {
112  assert(i < length());
113  assert(invariant());
114  return c_str()[i];
115  }
size_type length() const
Definition: basic_string.hpp:213
const value_type * c_str() const
Definition: basic_string.hpp:199

◆ reserve()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
value_type* std::basic_string< E, TAllocator, TStorage >::reserve ( size_type  capacity_hint)
inline
232  {
233  return TStorage::reserve(capacity_hint);
234  }

◆ resize()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
void std::basic_string< E, TAllocator, TStorage >::resize ( size_type  size)
inline
240  {
241  TStorage::resize(size);
242  }

◆ rfind()

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
size_type std::basic_string< E, TAllocator, TStorage >::rfind ( const value_type needle) const
inline
328  {
329  const value_type* s(c_str() + length());
330  size_type si(length()+1);
331 
332  while(--si >= 0)
333  {
334  if( *s-- == *needle )
335  {
336  const value_type* x = c_str() + si;
337  const value_type* n = needle;
338  size_type match = 0;
339  while(*x && *n)
340  {
341  if( *n == *x )
342  ++match;
343  ++n;
344  ++x;
345  }
346  if( match == strlen(needle) )
347  return si;
348  }
349  }
350  return basic_string::npos;
351  }
size_type length() const
Definition: basic_string.hpp:213
const value_type * c_str() const
Definition: basic_string.hpp:199
static const size_type npos
Definition: basic_string.hpp:56
typename TStorage::value_type value_type
Definition: basic_string.hpp:48
typename TStorage::size_type size_type
Definition: basic_string.hpp:49

◆ substr() [1/2]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
basic_string std::basic_string< E, TAllocator, TStorage >::substr ( size_type  begin,
size_type  end 
) const
inline
143  {
144  assert(end >= begin && end <= length() && begin >= 0);
145  return basic_string(c_str() + begin, end - begin);
146  }
size_type length() const
Definition: basic_string.hpp:213
basic_string(const allocator_type &allocator=allocator_type())
Definition: basic_string.hpp:58
const value_type * c_str() const
Definition: basic_string.hpp:199
const_iterator end() const
Definition: basic_string.hpp:208
const_iterator begin() const
Definition: basic_string.hpp:204

◆ substr() [2/2]

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
basic_string std::basic_string< E, TAllocator, TStorage >::substr ( size_type  begin) const
inline
148  {
149  return substr(begin, length());
150  }
size_type length() const
Definition: basic_string.hpp:213
basic_string substr(size_type begin, size_type end) const
Definition: basic_string.hpp:142
const_iterator begin() const
Definition: basic_string.hpp:204

Dokumentation der Datenelemente

◆ npos

template<typename E, class TAllocator = std::allocator, typename TStorage = std::simple_string_storage<E, TAllocator>>
const size_type std::basic_string< E, TAllocator, TStorage >::npos = size_type(-1)
static

Die Dokumentation für diese Klasse wurde erzeugt aufgrund der Datei: