Inherits pmem::obj::experimental::basic_inline_string_base< CharT, Traits >.
|
| basic_inline_string (basic_string_view< CharT, Traits > v) |
|
| basic_inline_string (size_type capacity) |
|
| basic_inline_string (const basic_inline_string &rhs) |
|
basic_inline_string & | operator= (const basic_inline_string &rhs) |
|
| operator basic_string_view< CharT, Traits > () const |
| Conversion operator to string_view.
|
|
size_type | size () const noexcept |
|
size_type | capacity () const noexcept |
|
pointer | data () |
| Returns pointer to the underlying data and if there is an active transaction add entire data to a transaction. More...
|
|
const_pointer | data () const noexcept |
|
const_pointer | cdata () const noexcept |
| Returns const pointer to the underlying data. More...
|
|
int | compare (basic_string_view< CharT, Traits > rhs) const noexcept |
| Compares this inline_string with other. More...
|
|
reference | operator[] (size_type p) |
| Returns reference to a character at position. More...
|
|
const_reference | operator[] (size_type p) const noexcept |
| Returns reference to a character at position. More...
|
|
reference | at (size_type p) |
| Returns reference to a character at position. More...
|
|
const_reference | at (size_type p) const |
| Returns reference to a character at position. More...
|
|
slice< pointer > | range (size_type p, size_type count) |
| Returns slice and snapshots (if there is an active transaction) requested range. More...
|
|
basic_inline_string_base & | assign (basic_string_view< CharT, Traits > rhs) |
| Transactionally assign content of basic_string_view. More...
|
|
template<typename CharT, typename Traits = std::char_traits<CharT>>
class pmem::obj::experimental::basic_inline_string< CharT, Traits >
Pmem-only variation of pmem::obj::string, where data is kept right next to the inline_string structure.
- Note
- It can be kept only on pmem.
pmem::obj::experimental::basic_inline_string serves similar purpose to pmem::obj::string, but keeps the data within the same allocation as inline_string itself. It means, the data is always kept right after the inline_string structure.
Creating an object of inline_string must be hence done as follows:
- Allocate memory of sizeof(inline_string) + size of the characters string + sizeof('\0')
- Use emplace new() to create inline_string
Example:
struct Object {
Object(int x, const char *s) : x(x), s(s)
{
}
int x;
};
struct root {
};
void
{
if (r->o)
return;
auto value = "example";
auto req_capacity =
sizeof(Object) + strlen(value) + sizeof('\0');
new (r->o.get()) Object(1, value);
});
std::cout << r->o->s.data() << std::endl;
}
void
{
auto new_value = "some new, longer value";
if (r->o->s.capacity() >= strlen(new_value)) {
r->o->s.assign(new_value);
} else {
auto ptr =
strlen(new_value) + 1));
new (ptr.get()) Object(r->o->x, new_value);
pmem::obj::delete_persistent<Object>(r->o);
r->o = ptr;
});
}
std::cout << r->o->s.data() << std::endl;
}
(EXPERIMENTAL) Encapsulates the information about the persistent memory allocation model using PMDK's...
Definition: allocator.hpp:467
static void run(obj::pool_base &pool, std::function< void()> tx, Locks &... locks)
Execute a closure-like transaction and lock locks.
Definition: transaction.hpp:676
Pmem-only variation of pmem::obj::string, where data is kept right next to the inline_string structur...
Definition: inline_string.hpp:162
Persistent pointer class.
Definition: persistent_ptr.hpp:153
PMEMobj pool class.
Definition: pool.hpp:482
persistent_ptr< T > root()
Retrieves pool's root object.
Definition: pool.hpp:644
pointer allocate(size_type cnt, const_void_pointer=0)
Allocate storage for cnt objects of type T.
Definition: allocator.hpp:247
template<typename CharT , typename Traits >
basic_inline_string_base< CharT, Traits >::const_pointer pmem::obj::experimental::basic_inline_string_base< CharT, Traits >::cdata |
|
noexceptinherited |
Returns const pointer to the underlying data.
In contradiction to data(), cdata() will return const_pointer not depending on the const-qualification of the object it is called on.
- Returns
- const_pointer to the data (equal to (this + 1))