PMDK C++ bindings
1.12.1-rc1
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Our partial std::string_view implementation. More...
#include <libpmemobj++/string_view.hpp>
Public Member Functions | |
constexpr | basic_string_view () noexcept |
Default constructor with empty data. | |
constexpr | basic_string_view (const CharT *data, size_type size) |
Constructor initialized by data and its size. More... | |
constexpr | basic_string_view (const std::basic_string< CharT, Traits > &s) |
Constructor initialized by the basic string s. More... | |
constexpr | basic_string_view (const CharT *data) |
Constructor initialized by data. More... | |
constexpr const_iterator | begin () const noexcept |
Returns an iterator to the first character of the view. More... | |
constexpr const_iterator | cbegin () const noexcept |
Returns an iterator to the first character of the view. More... | |
constexpr const_iterator | end () const noexcept |
Returns an iterator to the character following the last character of the view. More... | |
constexpr const_iterator | cend () const noexcept |
Returns an iterator to the character following the last character of the view. More... | |
constexpr const CharT * | data () const noexcept |
Returns pointer to data stored in this pmem::obj::string_view. More... | |
constexpr size_type | size () const noexcept |
Returns count of characters stored in this pmem::obj::string_view data. More... | |
constexpr size_type | length () const noexcept |
Returns count of characters stored in this pmem::obj::string_view data. More... | |
constexpr bool | empty () const noexcept |
Returns that view is empty or not. More... | |
constexpr size_type | max_size () const noexcept |
Returns the largest possible number of char-like objects that can be referred to by a basic_string_view. More... | |
const CharT & | at (size_type pos) const |
Returns reference to the character at position. More... | |
constexpr const CharT & | operator[] (size_type pos) const noexcept |
Returns reference to a character at position. More... | |
constexpr const_reference | front () const noexcept |
Returns reference to the first character in the view. More... | |
constexpr const_reference | back () const noexcept |
Returns reference to the last character in the view. More... | |
void | remove_prefix (size_type n) |
Moves the start of the view forward by n characters. More... | |
void | remove_suffix (size_type n) |
Moves the end of the view back by n characters. More... | |
void | swap (basic_string_view &v) noexcept |
Exchanges the view with that of v. More... | |
constexpr basic_string_view | substr (size_type pos=0, size_type count=npos) const |
Returns a view of the substring [pos, pos + rcount), where rcount is the smaller of count and size() - pos. More... | |
size_type | copy (CharT *dest, size_type count, size_type pos=0) const |
Copies the substring [pos, pos + rcount) to the character array pointed to by dest, where rcount is the smaller of count and size() - pos. More... | |
int | compare (size_type pos1, size_type n1, basic_string_view sv) const |
Compares two character sequences. More... | |
int | compare (size_type pos1, size_type n1, basic_string_view sv, size_type pos2, size_type n2) const |
Compares two character sequences. More... | |
int | compare (const CharT *s) const noexcept |
Compares two character sequences. More... | |
int | compare (size_type pos1, size_type n1, const CharT *s) const |
Compares two character sequences. More... | |
int | compare (size_type pos1, size_type n1, const CharT *s, size_type n2) const |
Compares two character sequences. More... | |
int | compare (const basic_string_view &other) const noexcept |
Compares this string_view with other. More... | |
size_type | find (CharT ch, size_type pos=0) const noexcept |
Finds the first character ch. More... | |
size_type | find (const CharT *s, size_type pos=0) const |
Finds the first substring equal to the C-style string pointed to by s. More... | |
size_type | find (const CharT *s, size_type pos, size_type count) const |
Finds the first substring equal to the range [s, s+count). More... | |
size_type | rfind (basic_string_view str, size_type pos=npos) const noexcept |
Finds the last substring equal to str. More... | |
size_type | rfind (const CharT *s, size_type pos, size_type count) const |
Finds the last substring equal to the range [s, s+count). More... | |
size_type | rfind (const CharT *s, size_type pos=npos) const |
Finds the last substring equal to the C-style string pointed to by s. More... | |
size_type | rfind (CharT ch, size_type pos=npos) const noexcept |
Finds the last character equal to ch. More... | |
size_type | find_first_of (basic_string_view str, size_type pos=0) const noexcept |
Finds the first character equal to any of the characters in str. More... | |
size_type | find_first_of (const CharT *s, size_type pos, size_type count) const |
Finds the first character equal to any of the characters in the range [s, s+count). More... | |
size_type | find_first_of (const CharT *s, size_type pos=0) const |
Finds the first character equal to any of the characters in the C-style string pointed to by s. More... | |
size_type | find_first_of (CharT ch, size_type pos=0) const noexcept |
Finds the first character equal to ch. More... | |
size_type | find_first_not_of (basic_string_view str, size_type pos=0) const noexcept |
Finds the first character equal to none of the characters in str. More... | |
size_type | find_first_not_of (const CharT *s, size_type pos, size_type count) const |
Finds the first character equal to none of the characters in the range [s, s+count). More... | |
size_type | find_first_not_of (const CharT *s, size_type pos=0) const |
Finds the first character equal to none of the characters in the C-style string pointed to by s. More... | |
size_type | find_first_not_of (CharT ch, size_type pos=0) const noexcept |
Finds the first character not equal to ch. More... | |
size_type | find_last_of (basic_string_view str, size_type pos=npos) const noexcept |
Finds the last character equal to any of the characters in str. More... | |
size_type | find_last_of (const CharT *s, size_type pos, size_type count) const |
Finds the last character equal to any of the characters in the range [s, s+count). More... | |
size_type | find_last_of (const CharT *s, size_type pos=npos) const |
Finds the last character equal to any of the characters in the C-style string pointed to by s. More... | |
size_type | find_last_of (CharT ch, size_type pos=npos) const noexcept |
Finds the last character equal to ch. More... | |
size_type | find_last_not_of (basic_string_view str, size_type pos=npos) const noexcept |
Finds the last character equal to none of the characters in str. More... | |
size_type | find_last_not_of (const CharT *s, size_type pos, size_type count) const |
Finds the last character equal to none of the characters in the range [s, s+count). More... | |
size_type | find_last_not_of (const CharT *s, size_type pos=npos) const |
Finds the last character equal to none of the characters in the C-style string pointed to by s. More... | |
size_type | find_last_not_of (CharT ch, size_type pos=npos) const noexcept |
Finds the last character not equal to ch. More... | |
Our partial std::string_view implementation.
If C++17's std::string_view implementation is not available, this one is used to avoid unnecessary string copying.
|
inlineconstexpr |
Constructor initialized by data and its size.
[in] | data | pointer to the C-like string to initialize with, it can contain null characters. |
[in] | size | length of the given data. |
|
inlineconstexpr |
Constructor initialized by the basic string s.
[in] | s | reference to the string to initialize with. |
|
inlineconstexpr |
Constructor initialized by data.
Size of the data will be set using Traits::length().
[in] | data | pointer to C-like string (char *) to initialize with, it has to end with the terminating null character. |
|
inline |
Returns reference to the character at position.
[in] | pos | and performs bound checking. |
std::out_of_range | when out of bounds occurs. |
|
inlineconstexprnoexcept |
Returns reference to the last character in the view.
The behavior is undefined if empty() == true.
|
constexprnoexcept |
Returns an iterator to the first character of the view.
|
constexprnoexcept |
Returns an iterator to the first character of the view.
|
constexprnoexcept |
Returns an iterator to the character following the last character of the view.
This character acts as a placeholder, attempting to access it results in undefined behavior.
|
inlinenoexcept |
Compares this string_view with other.
Works in the same way as std::basic_string::compare.
|
inlinenoexcept |
Compares two character sequences.
[in] | s | pointer to the character string to compare to |
|
inline |
Compares two character sequences.
[in] | pos1 | position of the first character in this view to compare |
[in] | n1 | number of characters of this view to compare |
[in] | sv | view to compare |
|
inline |
Compares two character sequences.
[in] | pos1 | position of the first character in this view to compare |
[in] | n1 | number of characters of this view to compare |
[in] | pos2 | position of the first character of the given view to compare |
[in] | n2 | number of characters of the given view to compare |
[in] | sv | view to compare |
|
inline |
Compares two character sequences.
[in] | pos1 | position of the first character in this view to compare |
[in] | n1 | number of characters of this view to compare |
[in] | s | pointer to the character string to compare to |
|
inline |
Compares two character sequences.
[in] | pos1 | position of the first character in this view to compare |
[in] | n1 | number of characters of this view to compare |
[in] | s | pointer to the character string to compare to |
[in] | n2 | number of characters of the given string to compare |
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::copy | ( | CharT * | dest, |
size_type | count, | ||
size_type | pos = 0 |
||
) | const |
Copies the substring [pos, pos + rcount) to the character array pointed to by dest, where rcount is the smaller of count and size() - pos.
[in] | dest | pointer to the destination character string |
[in] | pos | position of the first character |
[in] | count | requested substring length |
std::out_of_range | if pos > size() |
|
inlineconstexprnoexcept |
Returns pointer to data stored in this pmem::obj::string_view.
It may not contain the terminating null character.
|
inlineconstexprnoexcept |
Returns that view is empty or not.
|
constexprnoexcept |
Returns an iterator to the character following the last character of the view.
This character acts as a placeholder, attempting to access it results in undefined behavior.
|
noexcept |
Finds the first character ch.
[in] | ch | character to search for |
[in] | pos | position at which to start the search |
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find | ( | const CharT * | s, |
size_type | pos, | ||
size_type | count | ||
) | const |
Finds the first substring equal to the range [s, s+count).
This range may contain null characters.
[in] | s | pointer to the C-style string to search for |
[in] | pos | position at which to start the search |
[in] | count | length of the substring to search for |
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find | ( | const CharT * | s, |
size_type | pos = 0 |
||
) | const |
Finds the first substring equal to the C-style string pointed to by s.
The length of the string is determined by the first null character.
[in] | s | pointer to the C-style string to search for |
[in] | pos | position at which to start the search |
|
noexcept |
Finds the first character equal to none of the characters in str.
[in] | str | string identifying characters to search for |
[in] | pos | position at which to start the search |
|
noexcept |
Finds the first character not equal to ch.
[in] | ch | character to search for |
[in] | pos | position at which to start the search |
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_first_not_of | ( | const CharT * | s, |
size_type | pos, | ||
size_type | count | ||
) | const |
Finds the first character equal to none of the characters in the range [s, s+count).
This range can include null characters.
[in] | s | pointer to the C-style string identifying characters to search for |
[in] | pos | position at which to start the search |
[in] | count | length of the C-style string identifying characters to search for |
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_first_not_of | ( | const CharT * | s, |
size_type | pos = 0 |
||
) | const |
Finds the first character equal to none of the characters in the C-style string pointed to by s.
The length of the string is determined by the first null character
[in] | s | pointer to the C-style string identifying characters to search for |
[in] | pos | position at which to start the search |
|
noexcept |
Finds the first character equal to any of the characters in str.
[in] | str | string identifying characters to search for |
[in] | pos | position at which to start the search |
|
noexcept |
Finds the first character equal to ch.
[in] | ch | character to search for |
[in] | pos | position at which to start the search |
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_first_of | ( | const CharT * | s, |
size_type | pos, | ||
size_type | count | ||
) | const |
Finds the first character equal to any of the characters in the range [s, s+count).
This range can include null characters.
[in] | s | pointer to the C-style string identifying characters to search for |
[in] | pos | position at which to start the search |
[in] | count | length of the C-style string identifying characters to search for |
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_first_of | ( | const CharT * | s, |
size_type | pos = 0 |
||
) | const |
Finds the first character equal to any of the characters in the C-style string pointed to by s.
The length of the string is determined by the first null character
[in] | s | pointer to the C-style string identifying characters to search for |
[in] | pos | position at which to start the search |
|
noexcept |
Finds the last character equal to none of the characters in str.
[in] | str | string identifying characters to search for |
[in] | pos | position at which to start the search |
|
noexcept |
Finds the last character not equal to ch.
[in] | ch | character to search for |
[in] | pos | position at which to start the search |
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_last_not_of | ( | const CharT * | s, |
size_type | pos, | ||
size_type | count | ||
) | const |
Finds the last character equal to none of the characters in the range [s, s+count).
This range can include null characters.
[in] | s | pointer to the C-style string identifying characters to search for |
[in] | pos | position at which to start the search |
[in] | count | length of the C-style string identifying characters to search for |
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_last_not_of | ( | const CharT * | s, |
size_type | pos = npos |
||
) | const |
Finds the last character equal to none of the characters in the C-style string pointed to by s.
The length of the string is determined by the first null character
[in] | s | pointer to the C-style string identifying characters to search for |
[in] | pos | position at which to start the search |
|
noexcept |
Finds the last character equal to any of the characters in str.
[in] | str | string identifying characters to search for |
[in] | pos | position at which to start the search |
|
noexcept |
Finds the last character equal to ch.
[in] | ch | character to search for |
[in] | pos | position at which to start the search |
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_last_of | ( | const CharT * | s, |
size_type | pos, | ||
size_type | count | ||
) | const |
Finds the last character equal to any of the characters in the range [s, s+count).
This range can include null characters.
[in] | s | pointer to the C-style string identifying characters to search for |
[in] | pos | position at which to start the search |
[in] | count | length of the C-style string identifying characters to search for |
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_last_of | ( | const CharT * | s, |
size_type | pos = npos |
||
) | const |
Finds the last character equal to any of the characters in the C-style string pointed to by s.
The length of the string is determined by the first null character
[in] | s | pointer to the C-style string identifying characters to search for |
[in] | pos | position at which to start the search |
|
inlineconstexprnoexcept |
Returns reference to the first character in the view.
The behavior is undefined if empty() == true.
|
inlineconstexprnoexcept |
Returns count of characters stored in this pmem::obj::string_view data.
|
inlineconstexprnoexcept |
Returns the largest possible number of char-like objects that can be referred to by a basic_string_view.
|
inlineconstexprnoexcept |
Returns reference to a character at position.
[in] | pos | . |
void pmem::obj::basic_string_view< CharT, Traits >::remove_prefix | ( | size_type | n | ) |
Moves the start of the view forward by n characters.
The behavior is undefined if n > size().
[in] | n | number of characters to remove from the start of the view |
void pmem::obj::basic_string_view< CharT, Traits >::remove_suffix | ( | size_type | n | ) |
Moves the end of the view back by n characters.
The behavior is undefined if n > size().
[in] | n | number of characters to remove from the end of the view |
|
noexcept |
Finds the last substring equal to str.
If npos or any value not smaller than size()-1 is passed as pos, whole string will be searched.
[in] | str | string to search for |
[in] | pos | position at which to start the search |
|
noexcept |
Finds the last character equal to ch.
If npos or any value not smaller than size()-1 is passed as pos, whole string will be searched.
[in] | ch | character to search for |
[in] | pos | position at which to start the search |
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::rfind | ( | const CharT * | s, |
size_type | pos, | ||
size_type | count | ||
) | const |
Finds the last substring equal to the range [s, s+count).
This range can include null characters. When pos is specified, the search only includes sequences of characters that begin at or before position pos, ignoring any possible match beginning after pos. If npos or any value not smaller than size()-1 is passed as pos, whole string will be searched.
[in] | s | pointer to the C-style string to search for |
[in] | pos | position at which to start the search |
[in] | count | length of the substring to search for |
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::rfind | ( | const CharT * | s, |
size_type | pos = npos |
||
) | const |
Finds the last substring equal to the C-style string pointed to by s.
The length of the string is determined by the first null character. If npos or any value not smaller than size()-1 is passed as pos, whole string will be searched.
[in] | s | pointer to the C-style string to search for |
[in] | pos | position at which to start the search |
|
inlineconstexprnoexcept |
Returns count of characters stored in this pmem::obj::string_view data.
|
constexpr |
|
noexcept |
Exchanges the view with that of v.
[in] | v | view to swap with |