#include <cow_string_storage.hpp>
template<typename E, class TAllocator>
class std::cow_string_storage< E, TAllocator >
◆ allocator_type
template<typename E , class TAllocator >
◆ const_iterator
template<typename E , class TAllocator >
◆ size_type
template<typename E , class TAllocator >
◆ value_type
template<typename E , class TAllocator >
◆ cow_string_storage() [1/4]
template<typename E , class TAllocator >
79 : m_allocator(allocator)
◆ cow_string_storage() [2/4]
template<typename E , class TAllocator >
84 : m_allocator(allocator)
86 const int len = strlen(
str);
87 construct_string(len);
90 get_rep()->
size =
static_cast<short>(len);
E value_type
Definition: cow_string_storage.hpp:71
static const size_t kMaxCapacity
Definition: cow_string_storage.hpp:62
short size
Definition: cow_string_storage.hpp:58
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
◆ cow_string_storage() [3/4]
template<typename E , class TAllocator >
94 : m_allocator(allocator)
96 construct_string(len);
99 get_rep()->
size =
static_cast<short>(len);
E value_type
Definition: cow_string_storage.hpp:71
static const size_t kMaxCapacity
Definition: cow_string_storage.hpp:62
short size
Definition: cow_string_storage.hpp:58
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
◆ cow_string_storage() [4/4]
template<typename E , class TAllocator >
111 : m_data(rhs.m_data), m_allocator(allocator)
113 if (rhs.is_dynamic())
119 const int len = rhs.length();
120 construct_string(len);
123 get_rep()->
size =
static_cast<short>(len);
E value_type
Definition: cow_string_storage.hpp:71
static const size_t kMaxCapacity
Definition: cow_string_storage.hpp:62
void add_ref()
Definition: cow_string_storage.hpp:40
short size
Definition: cow_string_storage.hpp:58
static void MemCpy(void *to, const void *from, size_t bytes)
Definition: PLATFORM.cpp:39
◆ ~cow_string_storage()
template<typename E , class TAllocator >
130 RDE_ASSERT(get_rep()->refs == 1);
◆ append()
template<typename E , class TAllocator >
168 const size_type newCapacity = prevLen + len;
170 string_rep* rep = get_rep();
171 assert(rep->capacity >=
short(newCapacity));
173 assert(
short(newLen) <= rep->capacity);
176 rep->size = short(newLen);
E value_type
Definition: cow_string_storage.hpp:71
int size_type
Definition: cow_string_storage.hpp:72
void make_unique(size_type capacity_hint)
Definition: cow_string_storage.hpp:217
size_type length() const
Definition: cow_string_storage.hpp:183
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
◆ assign()
template<typename E , class TAllocator >
146 assert(
str != m_data);
148 construct_string(len);
150 get_rep()->
size = short(len);
E value_type
Definition: cow_string_storage.hpp:71
short size
Definition: cow_string_storage.hpp:58
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
◆ c_str()
template<typename E , class TAllocator >
◆ clear()
template<typename E , class TAllocator >
void resize(size_type len)
Definition: cow_string_storage.hpp:153
◆ get_allocator()
template<typename E , class TAllocator >
187 {
return m_allocator; }
◆ get_data()
template<typename E , class TAllocator >
◆ invariant()
template<typename E , class TAllocator >
210 string_rep* rep = get_rep();
211 assert(rep->refs >= 1);
212 assert(rep->size <= rep->capacity);
214 assert(m_data[
length()] == 0);
size_type length() const
Definition: cow_string_storage.hpp:183
◆ length()
template<typename E , class TAllocator >
185 return get_rep()->
size;
short size
Definition: cow_string_storage.hpp:58
◆ make_unique()
template<typename E , class TAllocator >
219 string_rep* rep = get_rep();
220 assert(rep->refs >= 1);
222 if (capacity_hint != 0)
232 if (rep->refs > 1 ||
short(capacity_hint) > rep->capacity)
234 if (capacity_hint > 0)
237 void* newMem = m_allocator.allocate(toAlloc);
238 string_rep* newRep =
reinterpret_cast<string_rep*
>(newMem);
239 newRep->init(
short(capacity_hint));
242 newRep->size = rep->size;
243 newData[rep->size] = 0;
250 string_rep* rep =
reinterpret_cast<string_rep*
>(m_buffer);
252 m_data =
reinterpret_cast<value_type*
>(rep + 1);
static const unsigned long kGranularity
Definition: cow_string_storage.hpp:76
E value_type
Definition: cow_string_storage.hpp:71
static const size_t kMaxCapacity
Definition: cow_string_storage.hpp:62
int size_type
Definition: cow_string_storage.hpp:72
static void MemCpy(void *to, const void *from, size_t bytes)
Definition: PLATFORM.cpp:39
◆ operator=()
template<typename E , class TAllocator >
135 if (m_data != rhs.m_data)
void add_ref()
Definition: cow_string_storage.hpp:40
◆ ow_string_storage()
template<typename E , class TAllocator >
103 : m_allocator(allocator)
105 construct_string(len);
107 get_rep()->
size =
static_cast<short>(len);
static const size_t kMaxCapacity
Definition: cow_string_storage.hpp:62
short size
Definition: cow_string_storage.hpp:58
◆ reserve()
template<typename E , class TAllocator >
void make_unique(size_type capacity_hint)
Definition: cow_string_storage.hpp:217
◆ resize() [1/2]
template<typename E , class TAllocator >
158 string_rep* rep = get_rep();
159 assert(rep->capacity >=
short(newCapacity));
161 assert(
short(newLen) <= rep->capacity);
163 rep->size = short(newLen);
int size_type
Definition: cow_string_storage.hpp:72
void make_unique(size_type capacity_hint)
Definition: cow_string_storage.hpp:217
size_type length() const
Definition: cow_string_storage.hpp:183
◆ resize() [2/2]
template<typename E , class TAllocator >
200 string_rep* rep = get_rep();
202 rep->size = (short)size;
void make_unique(size_type capacity_hint)
Definition: cow_string_storage.hpp:217
◆ kGranularity
template<typename E , class TAllocator >
Die Dokumentation für diese Klasse wurde erzeugt aufgrund der Datei: