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

#include <simple_string_storage.hpp>

Öffentliche Typen

using value_type = E
 
using size_type = int
 
using allocator_type = TAllocator
 
using const_iterator = const value_type *
 

Öffentliche Methoden

 simple_string_storage (const allocator_type &allocator)
 
 simple_string_storage (const value_type *str, const allocator_type &allocator)
 
 simple_string_storage (const value_type *str, size_type len, const allocator_type &allocator)
 
 simple_string_storage (size_type len, const allocator_type &allocator)
 
 simple_string_storage (const simple_string_storage &rhs, const allocator_type &allocator)
 
 ~simple_string_storage ()
 
simple_string_storageoperator= (const simple_string_storage &rhs)
 
void assign (const value_type *str, size_type len)
 
void resize (size_type len)
 
void append (const value_type *str, size_type len)
 
const value_typec_str () const
 
size_type length () const
 
size_type capacity () const
 
void clear ()
 
const allocator_typeget_allocator () const
 
void make_unique (size_type)
 
value_typeget_data ()
 

Statische öffentliche Attribute

static const unsigned long kGranularity = 32
 

Geschützte Methoden

bool invariant () const
 

Ausführliche Beschreibung

template<typename E, class TAllocator>
class std::simple_string_storage< E, TAllocator >

Dokumentation der benutzerdefinierten Datentypen

◆ allocator_type

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

◆ const_iterator

template<typename E, class TAllocator>
using std::simple_string_storage< E, TAllocator >::const_iterator = const value_type*

◆ size_type

template<typename E, class TAllocator>
using std::simple_string_storage< E, TAllocator >::size_type = int

◆ value_type

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

Beschreibung der Konstruktoren und Destruktoren

◆ simple_string_storage() [1/5]

template<typename E, class TAllocator>
std::simple_string_storage< E, TAllocator >::simple_string_storage ( const allocator_type allocator)
inlineexplicit
50  : m_length(0), m_allocator(allocator)
51  {
52  m_data = construct_string(0, m_capacity);
53  }

◆ simple_string_storage() [2/5]

template<typename E, class TAllocator>
std::simple_string_storage< E, TAllocator >::simple_string_storage ( const value_type str,
const allocator_type allocator 
)
inline
55  : m_allocator(allocator)
56  {
57  const int len = strlen(str);
58  m_data = construct_string(len, m_capacity);
59  std::Sys::MemCpy(m_data, str, len*sizeof(value_type));
60  m_length = len;
61  m_data[len] = 0;
62  }
static void MemCpy(void *to, const void *from, size_t bytes)
Definition: PLATFORM.cpp:39
std::string str(T begin, T end)
Definition: utils.hpp:39
E value_type
Definition: simple_string_storage.hpp:43

◆ simple_string_storage() [3/5]

template<typename E, class TAllocator>
std::simple_string_storage< E, TAllocator >::simple_string_storage ( const value_type str,
size_type  len,
const allocator_type allocator 
)
inline
64  : m_allocator(allocator)
65  {
66  m_data = construct_string(len, m_capacity);
67  std::Sys::MemCpy(m_data, str, len*sizeof(value_type));
68  m_length = len;
69  m_data[len] = 0;
70  }
static void MemCpy(void *to, const void *from, size_t bytes)
Definition: PLATFORM.cpp:39
std::string str(T begin, T end)
Definition: utils.hpp:39
E value_type
Definition: simple_string_storage.hpp:43

◆ simple_string_storage() [4/5]

template<typename E, class TAllocator>
std::simple_string_storage< E, TAllocator >::simple_string_storage ( size_type  len,
const allocator_type allocator 
)
inline
72  : m_allocator(allocator)
73  {
74  m_data = construct_string(len, m_capacity);
75  m_length = len;
76  m_data[len] = 0;
77  }

◆ simple_string_storage() [5/5]

template<typename E, class TAllocator>
std::simple_string_storage< E, TAllocator >::simple_string_storage ( const simple_string_storage< E, TAllocator > &  rhs,
const allocator_type allocator 
)
inline
79  : m_data(0), m_capacity(0), m_length(0), m_allocator(allocator)
80  {
81  assign(rhs.c_str(), rhs.length());
82  }
void assign(const value_type *str, size_type len)
Definition: simple_string_storage.hpp:97

◆ ~simple_string_storage()

template<typename E, class TAllocator>
std::simple_string_storage< E, TAllocator >::~simple_string_storage ( )
inline
84  {
85  release_string();
86  }

Dokumentation der Elementfunktionen

◆ append()

template<typename E, class TAllocator>
void std::simple_string_storage< E, TAllocator >::append ( const value_type str,
size_type  len 
)
inline
128  {
129  const size_type prevLen = length();
130  const size_type newLen = prevLen + len;
131  if (m_capacity <= newLen + 1)
132  {
133  size_type newCapacity;
134  value_type* newData = construct_string(newLen, newCapacity);
135  Sys::MemCpy(newData, m_data, prevLen * sizeof(value_type));
136  release_string();
137  m_data = newData;
138  m_capacity = newCapacity;
139  }
140  Sys::MemCpy(m_data + prevLen, str, len * sizeof(value_type));
141  m_data[newLen] = 0;
142  m_length = newLen;
143  assert(invariant());
144  }
int size_type
Definition: simple_string_storage.hpp:44
bool invariant() const
Definition: simple_string_storage.hpp:171
size_type length() const
Definition: simple_string_storage.hpp:151
static void MemCpy(void *to, const void *from, size_t bytes)
Definition: PLATFORM.cpp:39
std::string str(T begin, T end)
Definition: utils.hpp:39
E value_type
Definition: simple_string_storage.hpp:43

◆ assign()

template<typename E, class TAllocator>
void std::simple_string_storage< E, TAllocator >::assign ( const value_type str,
size_type  len 
)
inline
98  {
99  //assert(str != m_data);
100  if (m_capacity <= len + 1)
101  {
102  release_string();
103  m_data = construct_string(len, m_capacity);
104  }
105  std::Sys::MemCpy(m_data, str, len*sizeof(value_type));
106  m_length = len;
107  m_data[len] = 0;
108  }
static void MemCpy(void *to, const void *from, size_t bytes)
Definition: PLATFORM.cpp:39
std::string str(T begin, T end)
Definition: utils.hpp:39
E value_type
Definition: simple_string_storage.hpp:43

◆ c_str()

template<typename E, class TAllocator>
const value_type* std::simple_string_storage< E, TAllocator >::c_str ( ) const
inline
147  {
148  return m_data;
149  }

◆ capacity()

template<typename E, class TAllocator>
size_type std::simple_string_storage< E, TAllocator >::capacity ( ) const
inline
156 { return m_capacity; }

◆ clear()

template<typename E, class TAllocator>
void std::simple_string_storage< E, TAllocator >::clear ( )
inline
159  {
160  release_string();
161  m_data = construct_string(0, m_capacity);
162  m_length = 0;
163  }

◆ get_allocator()

template<typename E, class TAllocator>
const allocator_type& std::simple_string_storage< E, TAllocator >::get_allocator ( ) const
inline
165 { return m_allocator; }

◆ get_data()

template<typename E, class TAllocator>
value_type* std::simple_string_storage< E, TAllocator >::get_data ( )
inline
168 { return m_data; }

◆ invariant()

template<typename E, class TAllocator>
bool std::simple_string_storage< E, TAllocator >::invariant ( ) const
inlineprotected
172  {
173  assert(m_data);
174  assert(m_length <= m_capacity);
175  if (length() != 0)
176  assert(m_data[length()] == 0);
177  return true;
178  }
size_type length() const
Definition: simple_string_storage.hpp:151

◆ length()

template<typename E, class TAllocator>
size_type std::simple_string_storage< E, TAllocator >::length ( ) const
inline
152  {
153  return m_length;
154  }

◆ make_unique()

template<typename E, class TAllocator>
void std::simple_string_storage< E, TAllocator >::make_unique ( size_type  )
inline
167 {}

◆ operator=()

template<typename E, class TAllocator>
simple_string_storage& std::simple_string_storage< E, TAllocator >::operator= ( const simple_string_storage< E, TAllocator > &  rhs)
inline
89  {
90  if (m_data != rhs.c_str())
91  {
92  assign(rhs.c_str(), rhs.length());
93  }
94  return *this;
95  }
void assign(const value_type *str, size_type len)
Definition: simple_string_storage.hpp:97

◆ resize()

template<typename E, class TAllocator>
void std::simple_string_storage< E, TAllocator >::resize ( size_type  len)
inline
110  {
111  const size_type prevLen = length();
112  const size_type newLen = len;
113  if (m_capacity <= newLen + 1)
114  {
115  size_type newCapacity;
116  value_type* newData = construct_string(newLen, newCapacity);
117  std::Sys::MemCpy(newData, m_data, prevLen * sizeof(value_type));
118  release_string();
119  m_data = newData;
120  m_capacity = newCapacity;
121  }
122  m_data[newLen] = 0;
123  m_length = newLen;
124  assert(invariant());
125  }
int size_type
Definition: simple_string_storage.hpp:44
bool invariant() const
Definition: simple_string_storage.hpp:171
size_type length() const
Definition: simple_string_storage.hpp:151
static void MemCpy(void *to, const void *from, size_t bytes)
Definition: PLATFORM.cpp:39
E value_type
Definition: simple_string_storage.hpp:43

Dokumentation der Datenelemente

◆ kGranularity

template<typename E, class TAllocator>
const unsigned long std::simple_string_storage< E, TAllocator >::kGranularity = 32
static

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