#include <shared_cow_string.hpp>
|
| shared_cow_string (const allocator_type &alloc) |
|
template<typename Iter > |
| shared_cow_string (Iter begin, Iter end, const allocator_type &alloc) |
|
| shared_cow_string (const char *ptr, std::size_t size, const allocator_type &alloc) |
|
| shared_cow_string (std::size_t size, boost::container::default_init_t, const allocator_type &alloc) |
|
| shared_cow_string (const shared_cow_string &other) |
|
| shared_cow_string (shared_cow_string &&other) |
|
shared_cow_string & | operator= (const shared_cow_string &other) |
|
shared_cow_string & | operator= (shared_cow_string &&other) |
|
| ~shared_cow_string () |
|
void | resize (std::size_t new_size, boost::container::default_init_t) |
|
template<typename F > |
void | resize_and_fill (std::size_t new_size, F &&f) |
|
void | assign (const char *ptr, std::size_t size) |
|
void | assign (const unsigned char *ptr, std::size_t size) |
|
const char * | data () const |
|
std::size_t | size () const |
|
const_iterator | begin () const |
|
const_iterator | end () const |
|
int | compare (std::size_t start, std::size_t count, const char *other, std::size_t other_size) const |
|
bool | operator== (const shared_cow_string &rhs) const |
|
bool | operator!= (const shared_cow_string &rhs) const |
|
const allocator_type & | get_allocator () const |
|
Definition at line 18 of file shared_cow_string.hpp.
◆ allocator_type
◆ const_iterator
◆ iterator
◆ shared_cow_string() [1/6]
chainbase::shared_cow_string::shared_cow_string |
( |
const allocator_type & | alloc | ) |
|
|
inlineexplicit |
◆ shared_cow_string() [2/6]
template<typename Iter >
chainbase::shared_cow_string::shared_cow_string |
( |
Iter | begin, |
|
|
Iter | end, |
|
|
const allocator_type & | alloc ) |
|
inlineexplicit |
Definition at line 30 of file shared_cow_string.hpp.
31 std::size_t
size = std::distance(begin, end);
32 impl* new_data = (impl*)&*_alloc.allocate(
sizeof(impl) +
size + 1);
33 new_data->reference_count = 1;
34 new_data->size =
size;
35 std::copy(begin, end, new_data->data);
36 new_data->data[
size] =
'\0';
37 _data = new_data;
38 }
shared_cow_string(const allocator_type &alloc)
◆ shared_cow_string() [3/6]
chainbase::shared_cow_string::shared_cow_string |
( |
const char * | ptr, |
|
|
std::size_t | size, |
|
|
const allocator_type & | alloc ) |
|
inlineexplicit |
Definition at line 39 of file shared_cow_string.hpp.
40 impl* new_data = (impl*)&*_alloc.allocate(
sizeof(impl) +
size + 1);
41 new_data->reference_count = 1;
42 new_data->size =
size;
43 std::memcpy(new_data->data, ptr,
size);
44 new_data->data[
size] =
'\0';
45 _data = new_data;
46 }
◆ shared_cow_string() [4/6]
chainbase::shared_cow_string::shared_cow_string |
( |
std::size_t | size, |
|
|
boost::container::default_init_t | , |
|
|
const allocator_type & | alloc ) |
|
inlineexplicit |
Definition at line 47 of file shared_cow_string.hpp.
48 impl* new_data = (impl*)&*_alloc.allocate(
sizeof(impl) +
size + 1);
49 new_data->reference_count = 1;
50 new_data->size =
size;
51 new_data->data[
size] =
'\0';
52 _data = new_data;
53 }
◆ shared_cow_string() [5/6]
Definition at line 54 of file shared_cow_string.hpp.
55 if(_data != nullptr) {
56 ++_data->reference_count;
57 }
58 }
◆ shared_cow_string() [6/6]
◆ ~shared_cow_string()
chainbase::shared_cow_string::~shared_cow_string |
( |
| ) |
|
|
inline |
◆ assign() [1/2]
void chainbase::shared_cow_string::assign |
( |
const char * | ptr, |
|
|
std::size_t | size ) |
|
inline |
Definition at line 90 of file shared_cow_string.hpp.
90 {
91 impl* new_data = (impl*)&*_alloc.allocate(
sizeof(impl) +
size + 1);
92 new_data->reference_count = 1;
93 new_data->size =
size;
95 std::memcpy(new_data->data, ptr,
size);
96 new_data->data[
size] =
'\0';
97 dec_refcount();
98 _data = new_data;
99 }
◆ assign() [2/2]
void chainbase::shared_cow_string::assign |
( |
const unsigned char * | ptr, |
|
|
std::size_t | size ) |
|
inline |
◆ begin()
◆ compare()
int chainbase::shared_cow_string::compare |
( |
std::size_t | start, |
|
|
std::size_t | count, |
|
|
const char * | other, |
|
|
std::size_t | other_size ) const |
|
inline |
Definition at line 116 of file shared_cow_string.hpp.
116 {
117 std::size_t sz =
size();
118 if(start > sz) BOOST_THROW_EXCEPTION(std::out_of_range{"shared_cow_string::compare"});
120 std::size_t cmp_len = std::min(
count, other_size);
122 int result = std::char_traits<char>::compare(start_ptr, other, cmp_len);
123 if (result != 0) return result;
124 else if (
count < other_size)
return -1;
125 else if(
count > other_size)
return 1;
126 else return 0;
127 }
◆ data()
const char * chainbase::shared_cow_string::data |
( |
| ) |
const |
|
inline |
Definition at line 103 of file shared_cow_string.hpp.
103 {
104 if (_data) return _data->data;
105 else return nullptr;
106 }
◆ end()
Definition at line 112 of file shared_cow_string.hpp.
112 {
113 if (_data) return _data->data + _data->size;
114 else return nullptr;
115 }
◆ get_allocator()
const allocator_type & chainbase::shared_cow_string::get_allocator |
( |
| ) |
const |
|
inline |
◆ operator!=()
◆ operator=() [1/2]
◆ operator=() [2/2]
Definition at line 66 of file shared_cow_string.hpp.
66 {
67 if (this != &other) {
68 dec_refcount();
70 other._data =
nullptr;
71 }
72 return *this;
73 }
◆ operator==()
◆ resize()
void chainbase::shared_cow_string::resize |
( |
std::size_t | new_size, |
|
|
boost::container::default_init_t | ) |
|
inline |
Definition at line 77 of file shared_cow_string.hpp.
77 {
78 impl* new_data = (impl*)&*_alloc.allocate(sizeof(impl) + new_size + 1);
79 new_data->reference_count = 1;
80 new_data->size = new_size;
81 new_data->data[new_size] = '\0';
82 dec_refcount();
83 _data = new_data;
84 }
◆ resize_and_fill()
template<typename F >
void chainbase::shared_cow_string::resize_and_fill |
( |
std::size_t | new_size, |
|
|
F && | f ) |
|
inline |
Definition at line 86 of file shared_cow_string.hpp.
86 {
87 resize(new_size, boost::container::default_init);
88 static_cast<F&&
>(
f)(_data->data, new_size);
89 }
void resize(std::size_t new_size, boost::container::default_init_t)
◆ size()
std::size_t chainbase::shared_cow_string::size |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following file: