PMDK C++ bindings  1.6.1
This is the C++ bindings documentation for PMDK's libpmemobj.
Public Member Functions | Private Member Functions | Private Attributes | List of all members
pmem::obj::experimental::basic_string< CharT, Traits > Class Template Reference

pmem::obj::experimental::string - EXPERIMENTAL persistent container with std::basic_string compatible interface. More...

#include <libpmemobj++/experimental/basic_string.hpp>

Public Member Functions

 basic_string ()
 Default constructor. More...
 
 basic_string (size_type count, CharT ch)
 Construct the container with count copies of elements with value ch. More...
 
 basic_string (const basic_string &other, size_type pos, size_type count=npos)
 Construct the string with a substring [pos, min(pos+count, other.size()) of other. More...
 
 basic_string (const CharT *s, size_type count)
 Construct the string with the first count elements of C-style string s. More...
 
 basic_string (const CharT *s)
 Construct the string with the contents of s. More...
 
template<typename InputIt , typename Enable = typename std::enable_if< pmem::detail::is_input_iterator<InputIt>::value>::type>
 basic_string (InputIt first, InputIt last)
 Construct the string with the contents of the range [first, last). More...
 
 basic_string (const basic_string &other)
 Copy constructor. More...
 
 basic_string (basic_string &&other)
 Move constructor. More...
 
 basic_string (std::initializer_list< CharT > ilist)
 Construct the container with the contents of the initializer list init. More...
 
 ~basic_string ()
 Destructor. More...
 
basic_stringoperator= (const basic_string &other)
 Copy assignment operator. More...
 
basic_stringoperator= (basic_string &&other)
 Move assignment operator. More...
 
basic_stringoperator= (const CharT *s)
 Replace the contents with copy of C-style string s transactionally. More...
 
basic_stringoperator= (CharT ch)
 Replace the contents with character ch transactionally. More...
 
basic_stringoperator= (std::initializer_list< CharT > ilist)
 Replace the contents with those of the initializer list ilist transactionally. More...
 
basic_stringassign (size_type count, CharT ch)
 Replace the contents with count copies of character ch transactionally. More...
 
basic_stringassign (const basic_string &other)
 Replace the string with the copy of the contents of other transactionally. More...
 
basic_stringassign (const basic_string &other, size_type pos, size_type count=npos)
 Replace the contents with a substring [pos, std::min(pos+count, other.size()) of other transactionally. More...
 
basic_stringassign (const CharT *s, size_type count)
 Replace the contents with the first count elements of C-style string s transactionally. More...
 
basic_stringassign (const CharT *s)
 Replace the contents with copy of C-style string s transactionally. More...
 
template<typename InputIt , typename Enable = typename pmem::detail::is_input_iterator< InputIt>::type>
basic_stringassign (InputIt first, InputIt last)
 Replace the contents with copies of elements in the range [first, last) transactionally. More...
 
basic_stringassign (basic_string &&other)
 Replace the string with the contents of other using move semantics transactionally. More...
 
basic_stringassign (std::initializer_list< CharT > ilist)
 Replaces the contents with those of the initializer list ilist transactionally. More...
 
iterator begin ()
 Return an iterator to the beginning. More...
 
const_iterator begin () const noexcept
 Return const iterator to the beginning. More...
 
const_iterator cbegin () const noexcept
 Return const iterator to the beginning. More...
 
iterator end ()
 Return an iterator to past the end. More...
 
const_iterator end () const noexcept
 Return const iterator to past the end. More...
 
const_iterator cend () const noexcept
 Return const iterator to past the end. More...
 
reverse_iterator rbegin ()
 Return a reverse iterator to the beginning. More...
 
const_reverse_iterator rbegin () const noexcept
 Return a const reverse iterator to the beginning. More...
 
const_reverse_iterator crbegin () const noexcept
 Return a const reverse iterator to the beginning. More...
 
reverse_iterator rend ()
 Return a reverse iterator to the end. More...
 
const_reverse_iterator rend () const noexcept
 Return a const reverse iterator to the end. More...
 
const_reverse_iterator crend () const noexcept
 Return a const reverse iterator to the end. More...
 
reference at (size_type n)
 Access element at specific index with bounds checking and snapshot it if there is an active transaction. More...
 
const_reference at (size_type n) const
 Access element at specific index with bounds checking. More...
 
const_reference const_at (size_type n) const
 Access element at specific index with bounds checking. More...
 
reference operator[] (size_type n)
 Access element at specific index and snapshot it if there is an active transaction. More...
 
const_reference operator[] (size_type n) const
 Access element at specific index. More...
 
CharT & front ()
 Access first element and snapshot it if there is an active transaction. More...
 
const CharT & front () const
 Access first element. More...
 
const CharT & cfront () const
 Access first element. More...
 
CharT & back ()
 Access last element and snapshot it if there is an active transaction. More...
 
const CharT & back () const
 Access last element. More...
 
const CharT & cback () const
 Access last element. More...
 
size_type size () const noexcept
 
CharT * data ()
 
int compare (size_type pos, size_type count1, const CharT *s, size_type count2) const
 Compares [pos, pos + count1) substring of this to [s, s + count2) substring of s. More...
 
int compare (const basic_string &other) const
 Compares this string to other. More...
 
int compare (size_type pos, size_type count, const basic_string &other) const
 Compares [pos, pos + count) substring of this to other. More...
 
int compare (size_type pos1, size_type count1, const basic_string &other, size_type pos2, size_type count2=npos) const
 Compares [pos1, pos1 + count1) substring of this to [pos2, pos2 + count2) substring of other. More...
 
int compare (const CharT *s) const
 Compares this string to s. More...
 
int compare (size_type pos, size_type count, const CharT *s) const
 Compares [pos, pos + count) substring of this to s. More...
 
const CharT * cdata () const noexcept
 
const CharT * data () const noexcept
 
const CharT * c_str () const noexcept
 
size_type length () const noexcept
 
size_type max_size () const noexcept
 
size_type capacity () const noexcept
 
bool empty () const noexcept
 

Private Member Functions

template<typename InputIt , typename Enable = typename std::enable_if< pmem::detail::is_input_iterator<InputIt>::value>::type>
size_type get_size (InputIt first, InputIt last) const
 Overload of generic get_size method used to calculate size based on provided parameters. More...
 
size_type get_size (size_type count, value_type ch) const
 Overload of generic get_size method used to calculate size based on provided parameters. More...
 
size_type get_size (const basic_string &other) const
 Overload of generic get_size method used to calculate size based on provided parameters. More...
 
template<typename... Args>
pointer replace (Args &&... args)
 Generic function which replaces current content based on provided parameters. More...
 
template<typename... Args>
pointer initialize (Args &&... args)
 Generic function which initializes memory based on provided parameters - forwards parameters to initialize function of either data_large or data_sso. More...
 
template<typename InputIt , typename Enable = typename std::enable_if< pmem::detail::is_input_iterator<InputIt>::value>::type>
pointer assign_sso_data (InputIt first, InputIt last)
 Initialize sso data. More...
 
pointer assign_sso_data (size_type count, value_type ch)
 Initialize sso data. More...
 
pointer assign_sso_data (basic_string &&other)
 Initialize sso data. More...
 
template<typename InputIt , typename Enable = typename std::enable_if< pmem::detail::is_input_iterator<InputIt>::value>::type>
pointer assign_large_data (InputIt first, InputIt last)
 Initialize data_large - call constructor of data_large. More...
 
pointer assign_large_data (size_type count, value_type ch)
 Initialize data_large - call constructor of data_large. More...
 
pointer assign_large_data (basic_string &&other)
 Initialize data_large - call constructor of data_large. More...
 
pool_base get_pool () const
 Return pool_base instance and assert that object is on pmem.
 
void check_pmem () const
 
void check_tx_stage_work () const
 
void check_pmem_tx () const
 

Private Attributes

union {
}; 
 This union holds sso data inside of an array and non sso data inside a vector. More...
 

Detailed Description

template<typename CharT, typename Traits = std::char_traits<CharT>>
class pmem::obj::experimental::basic_string< CharT, Traits >

pmem::obj::experimental::string - EXPERIMENTAL persistent container with std::basic_string compatible interface.

The implementation is NOT complete.

Constructor & Destructor Documentation

◆ basic_string() [1/9]

template<typename CharT , typename Traits = std::char_traits<CharT>>
pmem::obj::experimental::basic_string< CharT, Traits >::basic_string ( )
inline

Default constructor.

Construct an empty container.

Precondition
must be called in transaction scope.
Exceptions
pmem::pool_errorif an object is not in persistent memory.
pmem::transaction_errorif constructor wasn't called in transaction.

◆ basic_string() [2/9]

template<typename CharT , typename Traits = std::char_traits<CharT>>
pmem::obj::experimental::basic_string< CharT, Traits >::basic_string ( size_type  count,
CharT  ch 
)
inline

Construct the container with count copies of elements with value ch.

Parameters
[in]countnumber of elements to construct.
[in]chvalue of all constructed elements.
Precondition
must be called in transaction scope.
Exceptions
pmem::pool_errorif an object is not in persistent memory.
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.
pmem::transaction_errorif constructor wasn't called in transaction.

◆ basic_string() [3/9]

template<typename CharT , typename Traits = std::char_traits<CharT>>
pmem::obj::experimental::basic_string< CharT, Traits >::basic_string ( const basic_string< CharT, Traits > &  other,
size_type  pos,
size_type  count = npos 
)
inline

Construct the string with a substring [pos, min(pos+count, other.size()) of other.

Parameters
[in]otherstring from which substring will be copied.
[in]posstart position of substring in other.
[in]countlength of substring.
Precondition
must be called in transaction scope.
Exceptions
std::out_of_rangeis pos > other.size()
pmem::pool_errorif an object is not in persistent memory.
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.
pmem::transaction_errorif constructor wasn't called in transaction.

◆ basic_string() [4/9]

template<typename CharT , typename Traits = std::char_traits<CharT>>
pmem::obj::experimental::basic_string< CharT, Traits >::basic_string ( const CharT *  s,
size_type  count 
)
inline

Construct the string with the first count elements of C-style string s.

Parameters
[in]spointer to source string.
[in]countlength of the resulting string.
Precondition
must be called in transaction scope.
Exceptions
pmem::pool_errorif an object is not in persistent memory.
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.
pmem::transaction_errorif constructor wasn't called in transaction.

◆ basic_string() [5/9]

template<typename CharT , typename Traits = std::char_traits<CharT>>
pmem::obj::experimental::basic_string< CharT, Traits >::basic_string ( const CharT *  s)
inline

Construct the string with the contents of s.

Parameters
[in]spointer to source string.
Precondition
must be called in transaction scope.
Exceptions
pmem::pool_errorif an object is not in persistent memory.
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.
pmem::transaction_errorif constructor wasn't called in transaction.

◆ basic_string() [6/9]

template<typename CharT , typename Traits = std::char_traits<CharT>>
template<typename InputIt , typename Enable = typename std::enable_if< pmem::detail::is_input_iterator<InputIt>::value>::type>
pmem::obj::experimental::basic_string< CharT, Traits >::basic_string ( InputIt  first,
InputIt  last 
)
inline

Construct the string with the contents of the range [first, last).

This constructor only participates in overload resolution if InputIt satisfies InputIterator.

Parameters
[in]firstiterator to beginning of the range.
[in]lastiterator to end of the range.
Precondition
must be called in transaction scope.
Exceptions
pmem::pool_errorif an object is not in persistent memory.
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.
pmem::transaction_errorif constructor wasn't called in transaction.

◆ basic_string() [7/9]

template<typename CharT , typename Traits = std::char_traits<CharT>>
pmem::obj::experimental::basic_string< CharT, Traits >::basic_string ( const basic_string< CharT, Traits > &  other)
inline

Copy constructor.

Construct the string with the copy of the contents of other.

Parameters
[in]otherreference to the string to be copied.
Precondition
must be called in transaction scope.
Exceptions
pmem::pool_errorif an object is not in persistent memory.
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.
pmem::transaction_errorif constructor wasn't called in transaction.

◆ basic_string() [8/9]

template<typename CharT , typename Traits = std::char_traits<CharT>>
pmem::obj::experimental::basic_string< CharT, Traits >::basic_string ( basic_string< CharT, Traits > &&  other)
inline

Move constructor.

Construct the string with the contents of other using move semantics.

Parameters
[in]otherrvalue reference to the string to be moved from.
Precondition
must be called in transaction scope.
Exceptions
pmem::pool_errorif an object is not in persistent memory.
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.
pmem::transaction_errorif constructor wasn't called in transaction.

◆ basic_string() [9/9]

template<typename CharT , typename Traits = std::char_traits<CharT>>
pmem::obj::experimental::basic_string< CharT, Traits >::basic_string ( std::initializer_list< CharT >  ilist)
inline

Construct the container with the contents of the initializer list init.

Parameters
[in]ilistinitializer list with content to be constructed.
Precondition
must be called in transaction scope.
Exceptions
pmem::pool_errorif an object is not in persistent memory.
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.
pmem::transaction_errorif constructor wasn't called in transaction.

◆ ~basic_string()

template<typename CharT , typename Traits = std::char_traits<CharT>>
pmem::obj::experimental::basic_string< CharT, Traits >::~basic_string ( )
inline

Destructor.

XXX: implement free_data()

Member Function Documentation

◆ assign() [1/8]

template<typename CharT , typename Traits = std::char_traits<CharT>>
basic_string& pmem::obj::experimental::basic_string< CharT, Traits >::assign ( basic_string< CharT, Traits > &&  other)
inline

Replace the string with the contents of other using move semantics transactionally.

Other is left in valid state with size equal to 0.

Parameters
[in]otherrvalue reference to the string to be moved from.
Exceptions
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.

◆ assign() [2/8]

template<typename CharT , typename Traits = std::char_traits<CharT>>
basic_string& pmem::obj::experimental::basic_string< CharT, Traits >::assign ( const basic_string< CharT, Traits > &  other)
inline

Replace the string with the copy of the contents of other transactionally.

Parameters
[in]otherreference to the string to be copied.
Exceptions
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.

◆ assign() [3/8]

template<typename CharT , typename Traits = std::char_traits<CharT>>
basic_string& pmem::obj::experimental::basic_string< CharT, Traits >::assign ( const basic_string< CharT, Traits > &  other,
size_type  pos,
size_type  count = npos 
)
inline

Replace the contents with a substring [pos, std::min(pos+count, other.size()) of other transactionally.

Parameters
[in]otherstring from which substring will be copied.
[in]posstart position of substring in other.
[in]countlength of substring.
Exceptions
std::out_of_rangeis pos > other.size()
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.

◆ assign() [4/8]

template<typename CharT , typename Traits = std::char_traits<CharT>>
basic_string& pmem::obj::experimental::basic_string< CharT, Traits >::assign ( const CharT *  s)
inline

Replace the contents with copy of C-style string s transactionally.

Parameters
[in]spointer to source string.
Exceptions
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.

◆ assign() [5/8]

template<typename CharT , typename Traits = std::char_traits<CharT>>
basic_string& pmem::obj::experimental::basic_string< CharT, Traits >::assign ( const CharT *  s,
size_type  count 
)
inline

Replace the contents with the first count elements of C-style string s transactionally.

Parameters
[in]spointer to source string.
[in]countlength of the string.
Exceptions
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.

◆ assign() [6/8]

template<typename CharT , typename Traits = std::char_traits<CharT>>
template<typename InputIt , typename Enable = typename pmem::detail::is_input_iterator< InputIt>::type>
basic_string& pmem::obj::experimental::basic_string< CharT, Traits >::assign ( InputIt  first,
InputIt  last 
)
inline

Replace the contents with copies of elements in the range [first, last) transactionally.

This function participates in overload resolution only if InputIt satisfies InputIterator.

Parameters
[in]firstiterator to beginning of the range.
[in]lastiterator to end of the range.
Exceptions
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.

◆ assign() [7/8]

template<typename CharT , typename Traits = std::char_traits<CharT>>
basic_string& pmem::obj::experimental::basic_string< CharT, Traits >::assign ( size_type  count,
CharT  ch 
)
inline

Replace the contents with count copies of character ch transactionally.

Parameters
[in]countnumber of characters.
[in]chcharacter.
Exceptions
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.

◆ assign() [8/8]

template<typename CharT , typename Traits = std::char_traits<CharT>>
basic_string& pmem::obj::experimental::basic_string< CharT, Traits >::assign ( std::initializer_list< CharT >  ilist)
inline

Replaces the contents with those of the initializer list ilist transactionally.

Parameters
[in]ilistinitializer_list of characters.
Exceptions
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.

◆ assign_large_data() [1/3]

template<typename CharT , typename Traits = std::char_traits<CharT>>
pointer pmem::obj::experimental::basic_string< CharT, Traits >::assign_large_data ( basic_string< CharT, Traits > &&  other)
inlineprivate

Initialize data_large - call constructor of data_large.

Overload for rvalue reference of basic_string.

◆ assign_large_data() [2/3]

template<typename CharT , typename Traits = std::char_traits<CharT>>
template<typename InputIt , typename Enable = typename std::enable_if< pmem::detail::is_input_iterator<InputIt>::value>::type>
pointer pmem::obj::experimental::basic_string< CharT, Traits >::assign_large_data ( InputIt  first,
InputIt  last 
)
inlineprivate

Initialize data_large - call constructor of data_large.

Overload for pair of iterators.

◆ assign_large_data() [3/3]

template<typename CharT , typename Traits = std::char_traits<CharT>>
pointer pmem::obj::experimental::basic_string< CharT, Traits >::assign_large_data ( size_type  count,
value_type  ch 
)
inlineprivate

Initialize data_large - call constructor of data_large.

Overload for (count, value).

◆ assign_sso_data() [1/3]

template<typename CharT , typename Traits = std::char_traits<CharT>>
pointer pmem::obj::experimental::basic_string< CharT, Traits >::assign_sso_data ( basic_string< CharT, Traits > &&  other)
inlineprivate

Initialize sso data.

Overload for rvalue reference of basic_string.

◆ assign_sso_data() [2/3]

template<typename CharT , typename Traits = std::char_traits<CharT>>
template<typename InputIt , typename Enable = typename std::enable_if< pmem::detail::is_input_iterator<InputIt>::value>::type>
pointer pmem::obj::experimental::basic_string< CharT, Traits >::assign_sso_data ( InputIt  first,
InputIt  last 
)
inlineprivate

Initialize sso data.

Overload for pair of iterators

◆ assign_sso_data() [3/3]

template<typename CharT , typename Traits = std::char_traits<CharT>>
pointer pmem::obj::experimental::basic_string< CharT, Traits >::assign_sso_data ( size_type  count,
value_type  ch 
)
inlineprivate

Initialize sso data.

Overload for (count, value).

◆ at() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
reference pmem::obj::experimental::basic_string< CharT, Traits >::at ( size_type  n)
inline

Access element at specific index with bounds checking and snapshot it if there is an active transaction.

Parameters
[in]nindex number.
Returns
reference to element number n in underlying array.
Exceptions
std::out_of_rangeif n is not within the range of the container.
pmem::transaction_errorwhen adding the object to the transaction failed.

◆ at() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
const_reference pmem::obj::experimental::basic_string< CharT, Traits >::at ( size_type  n) const
inline

Access element at specific index with bounds checking.

Parameters
[in]nindex number.
Returns
const_reference to element number n in underlying array.
Exceptions
std::out_of_rangeif n is not within the range of the container.

◆ back() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
CharT& pmem::obj::experimental::basic_string< CharT, Traits >::back ( )
inline

Access last element and snapshot it if there is an active transaction.

Returns
reference to last element in string.
Exceptions
pmem::transaction_errorwhen adding the object to the transaction failed.

◆ back() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
const CharT& pmem::obj::experimental::basic_string< CharT, Traits >::back ( ) const
inline

Access last element.

Returns
const reference to last element in string.

◆ begin() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
iterator pmem::obj::experimental::basic_string< CharT, Traits >::begin ( )
inline

Return an iterator to the beginning.

Returns
an iterator pointing to the first element in the string.

◆ begin() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
const_iterator pmem::obj::experimental::basic_string< CharT, Traits >::begin ( ) const
inlinenoexcept

Return const iterator to the beginning.

Returns
const iterator pointing to the first element in the string.

◆ c_str()

template<typename CharT , typename Traits = std::char_traits<CharT>>
const CharT* pmem::obj::experimental::basic_string< CharT, Traits >::c_str ( ) const
inlinenoexcept
Returns
pointer to underlying data.

◆ capacity()

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type pmem::obj::experimental::basic_string< CharT, Traits >::capacity ( ) const
inlinenoexcept
Returns
number of characters that can be held in currently allocated storage.

◆ cback()

template<typename CharT , typename Traits = std::char_traits<CharT>>
const CharT& pmem::obj::experimental::basic_string< CharT, Traits >::cback ( ) const
inline

Access last element.

In contradiction to back(), cback() will return const_reference not depending on the const-qualification of the object it is called on. std::basic_string doesn't provide cback() method.

Returns
const reference to last element in string.

◆ cbegin()

template<typename CharT , typename Traits = std::char_traits<CharT>>
const_iterator pmem::obj::experimental::basic_string< CharT, Traits >::cbegin ( ) const
inlinenoexcept

Return const iterator to the beginning.

Returns
const iterator pointing to the first element in the string.

◆ cdata()

template<typename CharT , typename Traits = std::char_traits<CharT>>
const CharT* pmem::obj::experimental::basic_string< CharT, Traits >::cdata ( ) const
inlinenoexcept
Returns
const pointer to underlying data.

◆ cend()

template<typename CharT , typename Traits = std::char_traits<CharT>>
const_iterator pmem::obj::experimental::basic_string< CharT, Traits >::cend ( ) const
inlinenoexcept

Return const iterator to past the end.

Returns
const_iterator referring to the past-the-end element in the string.

◆ cfront()

template<typename CharT , typename Traits = std::char_traits<CharT>>
const CharT& pmem::obj::experimental::basic_string< CharT, Traits >::cfront ( ) const
inline

Access first element.

In contradiction to front(), cfront() will return const_reference not depending on the const-qualification of the object it is called on. std::basic_string doesn't provide cfront() method.

Returns
const reference to first element in string.

◆ check_pmem()

template<typename CharT , typename Traits = std::char_traits<CharT>>
void pmem::obj::experimental::basic_string< CharT, Traits >::check_pmem ( ) const
inlineprivate
Exceptions
pmem::pool_errorif an object is not in persistent memory.

◆ check_pmem_tx()

template<typename CharT , typename Traits = std::char_traits<CharT>>
void pmem::obj::experimental::basic_string< CharT, Traits >::check_pmem_tx ( ) const
inlineprivate
Exceptions
pmem::pool_errorif an object is not in persistent memory.
pmem::transaction_errorif called outside of a transaction.

◆ check_tx_stage_work()

template<typename CharT , typename Traits = std::char_traits<CharT>>
void pmem::obj::experimental::basic_string< CharT, Traits >::check_tx_stage_work ( ) const
inlineprivate
Exceptions
pmem::transaction_errorif called outside of a transaction.

◆ compare() [1/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
int pmem::obj::experimental::basic_string< CharT, Traits >::compare ( const basic_string< CharT, Traits > &  other) const
inline

Compares this string to other.

Parameters
[in]otherstring to compare to.
Returns
negative value if *this < other in lexicographical order, zero if *this == other and positive value if *this > other.

◆ compare() [2/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
int pmem::obj::experimental::basic_string< CharT, Traits >::compare ( const CharT *  s) const
inline

Compares this string to s.

Parameters
[in]sC-style string to compare to.
Returns
negative value if *this < s in lexicographical order, zero if *this == s and positive value if *this > s.

◆ compare() [3/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
int pmem::obj::experimental::basic_string< CharT, Traits >::compare ( size_type  pos,
size_type  count,
const basic_string< CharT, Traits > &  other 
) const
inline

Compares [pos, pos + count) substring of this to other.

If count > size() - pos, substring is equal to [pos, size()).

Parameters
[in]posbeginning of the substring.
[in]countlength of the substring.
[in]otherstring to compare to.
Returns
negative value if substring < other in lexicographical order, zero if substring == other and positive value if substring > other.
Exceptions
std::out_of_rangeis pos > size()

◆ compare() [4/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
int pmem::obj::experimental::basic_string< CharT, Traits >::compare ( size_type  pos,
size_type  count,
const CharT *  s 
) const
inline

Compares [pos, pos + count) substring of this to s.

If count > size() - pos, substring is equal to [pos, size()).

Parameters
[in]posbeginning of the substring.
[in]countlength of the substring.
[in]sC-style string to compare to.
Returns
negative value if substring < s in lexicographical order, zero if substring == s and positive value if substring > s.
Exceptions
std::out_of_rangeis pos > size()

◆ compare() [5/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
int pmem::obj::experimental::basic_string< CharT, Traits >::compare ( size_type  pos,
size_type  count1,
const CharT *  s,
size_type  count2 
) const
inline

Compares [pos, pos + count1) substring of this to [s, s + count2) substring of s.

If count > size() - pos, substring is equal to [pos, size()).

Parameters
[in]posbeginning of substring of this.
[in]count1length of substring of this.
[in]sC-style string to compare to.
[in]count2length of substring of s.
Returns
negative value if substring of *this < substring of s in lexicographical order, zero if substring of *this == substring of s and positive value if substring of *this > substring of s.
Exceptions
std::out_of_rangeis pos > size()

◆ compare() [6/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
int pmem::obj::experimental::basic_string< CharT, Traits >::compare ( size_type  pos1,
size_type  count1,
const basic_string< CharT, Traits > &  other,
size_type  pos2,
size_type  count2 = npos 
) const
inline

Compares [pos1, pos1 + count1) substring of this to [pos2, pos2 + count2) substring of other.

If count1 > size() - pos, substring is equal to [pos1, size()).

Parameters
[in]pos1beginning of substring of this.
[in]count1length of substring of this.
[in]otherstring to compare to.
[in]pos2beginning of substring of other.
[in]count2length of substring of other.
Returns
negative value if substring of *this < substring of other in lexicographical order, zero if substring of *this == substring of other and positive value if substring of *this > substring of other.
Exceptions
std::out_of_rangeis pos1 > size() or pos2 > other.size()

◆ const_at()

template<typename CharT , typename Traits = std::char_traits<CharT>>
const_reference pmem::obj::experimental::basic_string< CharT, Traits >::const_at ( size_type  n) const
inline

Access element at specific index with bounds checking.

In contradiction to at(), const_at() will return const_reference not depending on the const-qualification of the object it is called on. std::basic_string doesn't provide const_at() method.

Parameters
[in]nindex number.
Returns
const_reference to element number n in underlying array.
Exceptions
std::out_of_rangeif n is not within the range of the container.

◆ crbegin()

template<typename CharT , typename Traits = std::char_traits<CharT>>
const_reverse_iterator pmem::obj::experimental::basic_string< CharT, Traits >::crbegin ( ) const
inlinenoexcept

Return a const reverse iterator to the beginning.

Returns
a const reverse iterator pointing to the last element in non-reversed string.

◆ crend()

template<typename CharT , typename Traits = std::char_traits<CharT>>
const_reverse_iterator pmem::obj::experimental::basic_string< CharT, Traits >::crend ( ) const
inlinenoexcept

Return a const reverse iterator to the end.

Returns
const reverse iterator referring to character preceding first character in the non-reversed string.

◆ data() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
CharT* pmem::obj::experimental::basic_string< CharT, Traits >::data ( )
inline
Returns
pointer to underlying data.
Exceptions
transaction_errorwhen adding data to the transaction failed.

◆ data() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
const CharT* pmem::obj::experimental::basic_string< CharT, Traits >::data ( ) const
inlinenoexcept
Returns
pointer to underlying data.

◆ empty()

template<typename CharT , typename Traits = std::char_traits<CharT>>
bool pmem::obj::experimental::basic_string< CharT, Traits >::empty ( ) const
inlinenoexcept
Returns
true if string is empty, false otherwise.

◆ end() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
iterator pmem::obj::experimental::basic_string< CharT, Traits >::end ( )
inline

Return an iterator to past the end.

Returns
iterator referring to the past-the-end element in the string.

◆ end() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
const_iterator pmem::obj::experimental::basic_string< CharT, Traits >::end ( ) const
inlinenoexcept

Return const iterator to past the end.

Returns
const_iterator referring to the past-the-end element in the string.

◆ front() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
CharT& pmem::obj::experimental::basic_string< CharT, Traits >::front ( )
inline

Access first element and snapshot it if there is an active transaction.

Returns
reference to first element in string.
Exceptions
pmem::transaction_errorwhen adding the object to the transaction failed.

◆ front() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
const CharT& pmem::obj::experimental::basic_string< CharT, Traits >::front ( ) const
inline

Access first element.

Returns
const reference to first element in string.

◆ get_size() [1/3]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type pmem::obj::experimental::basic_string< CharT, Traits >::get_size ( const basic_string< CharT, Traits > &  other) const
inlineprivate

Overload of generic get_size method used to calculate size based on provided parameters.

Return size of other basic_string

◆ get_size() [2/3]

template<typename CharT , typename Traits = std::char_traits<CharT>>
template<typename InputIt , typename Enable = typename std::enable_if< pmem::detail::is_input_iterator<InputIt>::value>::type>
size_type pmem::obj::experimental::basic_string< CharT, Traits >::get_size ( InputIt  first,
InputIt  last 
) const
inlineprivate

Overload of generic get_size method used to calculate size based on provided parameters.

Return std::distance(first, last) for pair of iterators.

◆ get_size() [3/3]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type pmem::obj::experimental::basic_string< CharT, Traits >::get_size ( size_type  count,
value_type  ch 
) const
inlineprivate

Overload of generic get_size method used to calculate size based on provided parameters.

Return count for (count, value)

◆ initialize()

template<typename CharT , typename Traits = std::char_traits<CharT>>
template<typename... Args>
pointer pmem::obj::experimental::basic_string< CharT, Traits >::initialize ( Args &&...  args)
inlineprivate

Generic function which initializes memory based on provided parameters - forwards parameters to initialize function of either data_large or data_sso.

Allowed parameters are:

  • size_type count, CharT value
  • InputIt first, InputIt last
  • basic_string &&
Precondition
must be called in transaction scope.

◆ length()

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type pmem::obj::experimental::basic_string< CharT, Traits >::length ( ) const
inlinenoexcept
Returns
number of CharT elements in the string.

◆ max_size()

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type pmem::obj::experimental::basic_string< CharT, Traits >::max_size ( ) const
inlinenoexcept
Returns
maximum number of elements the string is able to hold.

◆ operator=() [1/5]

template<typename CharT , typename Traits = std::char_traits<CharT>>
basic_string& pmem::obj::experimental::basic_string< CharT, Traits >::operator= ( basic_string< CharT, Traits > &&  other)
inline

Move assignment operator.

Replace the string with the contents of other using move semantics transactionally.

Parameters
[in]otherrvalue reference to the string to be moved from.
Exceptions
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.

◆ operator=() [2/5]

template<typename CharT , typename Traits = std::char_traits<CharT>>
basic_string& pmem::obj::experimental::basic_string< CharT, Traits >::operator= ( CharT  ch)
inline

Replace the contents with character ch transactionally.

Parameters
[in]chcharacter.
Exceptions
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.

◆ operator=() [3/5]

template<typename CharT , typename Traits = std::char_traits<CharT>>
basic_string& pmem::obj::experimental::basic_string< CharT, Traits >::operator= ( const basic_string< CharT, Traits > &  other)
inline

Copy assignment operator.

Replace the string with contents of other transactionally.

Parameters
[in]otherreference to the string to be copied.
Exceptions
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.

◆ operator=() [4/5]

template<typename CharT , typename Traits = std::char_traits<CharT>>
basic_string& pmem::obj::experimental::basic_string< CharT, Traits >::operator= ( const CharT *  s)
inline

Replace the contents with copy of C-style string s transactionally.

Parameters
[in]spointer to source string.
Exceptions
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.

◆ operator=() [5/5]

template<typename CharT , typename Traits = std::char_traits<CharT>>
basic_string& pmem::obj::experimental::basic_string< CharT, Traits >::operator= ( std::initializer_list< CharT >  ilist)
inline

Replace the contents with those of the initializer list ilist transactionally.

Parameters
[in]ilistinitializer_list of characters.
Exceptions
pmem::transaction_alloc_errorwhen allocating memory for underlying storage in transaction failed.

◆ operator[]() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
reference pmem::obj::experimental::basic_string< CharT, Traits >::operator[] ( size_type  n)
inline

Access element at specific index and snapshot it if there is an active transaction.

No bounds checking is performed.

Parameters
[in]nindex number.
Returns
reference to element number n in underlying array.
Exceptions
pmem::transaction_errorwhen adding the object to the transaction failed.

◆ operator[]() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
const_reference pmem::obj::experimental::basic_string< CharT, Traits >::operator[] ( size_type  n) const
inline

Access element at specific index.

No bounds checking is performed.

Parameters
[in]nindex number.
Returns
const_reference to element number n in underlying array.

◆ rbegin() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
reverse_iterator pmem::obj::experimental::basic_string< CharT, Traits >::rbegin ( )
inline

Return a reverse iterator to the beginning.

Returns
a reverse iterator pointing to the last element in non-reversed string.

◆ rbegin() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
const_reverse_iterator pmem::obj::experimental::basic_string< CharT, Traits >::rbegin ( ) const
inlinenoexcept

Return a const reverse iterator to the beginning.

Returns
a const reverse iterator pointing to the last element in non-reversed string.

◆ rend() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
reverse_iterator pmem::obj::experimental::basic_string< CharT, Traits >::rend ( )
inline

Return a reverse iterator to the end.

Returns
reverse iterator referring to character preceding first character in the non-reversed string.

◆ rend() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
const_reverse_iterator pmem::obj::experimental::basic_string< CharT, Traits >::rend ( ) const
inlinenoexcept

Return a const reverse iterator to the end.

Returns
const reverse iterator referring to character preceding first character in the non-reversed string.

◆ replace()

template<typename CharT , typename Traits = std::char_traits<CharT>>
template<typename... Args>
pointer pmem::obj::experimental::basic_string< CharT, Traits >::replace ( Args &&...  args)
inlineprivate

Generic function which replaces current content based on provided parameters.

Allowed parameters are:

  • size_type count, CharT value
  • InputIt first, InputIt last
  • basic_string &&

◆ size()

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type pmem::obj::experimental::basic_string< CharT, Traits >::size ( ) const
inlinenoexcept
Returns
number of CharT elements in the string.

Member Data Documentation

◆ @3

union { ... }

This union holds sso data inside of an array and non sso data inside a vector.

If vector is used, it must be manually created and destroyed.


The documentation for this class was generated from the following file: