PMDK C++ bindings  1.12-git53.g67ba2be4
This is the C++ bindings documentation for PMDK's libpmemobj.
Public Member Functions | List of all members
pmem::obj::basic_string_view< CharT, Traits > Class Template Reference

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...
 

Detailed Description

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

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.

Constructor & Destructor Documentation

◆ basic_string_view() [1/3]

template<typename CharT , typename Traits >
constexpr pmem::obj::basic_string_view< CharT, Traits >::basic_string_view ( const CharT *  data,
size_type  size 
)
inlineconstexpr

Constructor initialized by data and its size.

Parameters
[in]datapointer to the C-like string to initialize with, it can contain null characters.
[in]sizelength of the given data.

◆ basic_string_view() [2/3]

template<typename CharT , typename Traits >
constexpr pmem::obj::basic_string_view< CharT, Traits >::basic_string_view ( const std::basic_string< CharT, Traits > &  s)
inlineconstexpr

Constructor initialized by the basic string s.

Parameters
[in]sreference to the string to initialize with.

◆ basic_string_view() [3/3]

template<typename CharT , typename Traits >
constexpr pmem::obj::basic_string_view< CharT, Traits >::basic_string_view ( const CharT *  data)
inlineconstexpr

Constructor initialized by data.

Size of the data will be set using Traits::length().

Parameters
[in]datapointer to C-like string (char *) to initialize with, it has to end with the terminating null character.

Member Function Documentation

◆ at()

template<typename CharT , typename Traits = std::char_traits<CharT>>
const CharT & pmem::obj::basic_string_view< CharT, Traits >::at ( size_type  pos) const
inline

Returns reference to the character at position.

Parameters
[in]posand performs bound checking.
Returns
reference to the char.
Exceptions
std::out_of_rangewhen out of bounds occurs.

◆ back()

template<typename CharT , typename Traits >
constexpr const CharT & pmem::obj::basic_string_view< CharT, Traits >::back
inlineconstexprnoexcept

Returns reference to the last character in the view.

The behavior is undefined if empty() == true.

Returns
reference to the last character.

◆ begin()

template<typename CharT , typename Traits >
constexpr basic_string_view< CharT, Traits >::const_iterator pmem::obj::basic_string_view< CharT, Traits >::begin
constexprnoexcept

Returns an iterator to the first character of the view.

Returns
const_iterator to the first character

◆ cbegin()

template<typename CharT , typename Traits >
constexpr basic_string_view< CharT, Traits >::const_iterator pmem::obj::basic_string_view< CharT, Traits >::cbegin
constexprnoexcept

Returns an iterator to the first character of the view.

Returns
const_iterator to the first character

◆ cend()

template<typename CharT , typename Traits >
constexpr basic_string_view< CharT, Traits >::const_iterator pmem::obj::basic_string_view< CharT, Traits >::cend
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.

Returns
const_iterator to the character following the last character.

◆ compare() [1/6]

template<typename CharT , typename Traits >
int pmem::obj::basic_string_view< CharT, Traits >::compare ( const basic_string_view< CharT, Traits > &  other) const
inlinenoexcept

Compares this string_view with other.

Works in the same way as std::basic_string::compare.

Returns
0 if both character sequences compare equal, positive value if this is lexicographically greater than other, negative value if this is lexicographically less than other.

◆ compare() [2/6]

template<typename CharT , typename Traits >
int pmem::obj::basic_string_view< CharT, Traits >::compare ( const CharT *  s) const
inlinenoexcept

Compares two character sequences.

Parameters
[in]spointer to the character string to compare to
Returns
negative value if this view is less than the other character sequence, zero if the both character sequences are equal, positive value if this view is greater than the other character sequence.

◆ compare() [3/6]

template<typename CharT , typename Traits >
int pmem::obj::basic_string_view< CharT, Traits >::compare ( size_type  pos1,
size_type  n1,
basic_string_view< CharT, Traits >  sv 
) const
inline

Compares two character sequences.

Parameters
[in]pos1position of the first character in this view to compare
[in]n1number of characters of this view to compare
[in]svview to compare
Returns
negative value if this view is less than the other character sequence, zero if the both character sequences are equal, positive value if this view is greater than the other character sequence.

◆ compare() [4/6]

template<typename CharT , typename Traits >
int pmem::obj::basic_string_view< CharT, Traits >::compare ( size_type  pos1,
size_type  n1,
basic_string_view< CharT, Traits >  sv,
size_type  pos2,
size_type  n2 
) const
inline

Compares two character sequences.

Parameters
[in]pos1position of the first character in this view to compare
[in]n1number of characters of this view to compare
[in]pos2position of the first character of the given view to compare
[in]n2number of characters of the given view to compare
[in]svview to compare
Returns
negative value if this view is less than the other character sequence, zero if the both character sequences are equal, positive value if this view is greater than the other character sequence.

◆ compare() [5/6]

template<typename CharT , typename Traits >
int pmem::obj::basic_string_view< CharT, Traits >::compare ( size_type  pos1,
size_type  n1,
const CharT *  s 
) const
inline

Compares two character sequences.

Parameters
[in]pos1position of the first character in this view to compare
[in]n1number of characters of this view to compare
[in]spointer to the character string to compare to
Returns
negative value if this view is less than the other character sequence, zero if the both character sequences are equal, positive value if this view is greater than the other character sequence.

◆ compare() [6/6]

template<typename CharT , typename Traits >
int pmem::obj::basic_string_view< CharT, Traits >::compare ( size_type  pos1,
size_type  n1,
const CharT *  s,
size_type  n2 
) const
inline

Compares two character sequences.

Parameters
[in]pos1position of the first character in this view to compare
[in]n1number of characters of this view to compare
[in]spointer to the character string to compare to
[in]n2number of characters of the given string to compare
Returns
negative value if this view is less than the other character sequence, zero if the both character sequences are equal, positive value if this view is greater than the other character sequence.

◆ copy()

template<typename CharT , typename Traits >
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.

Parameters
[in]destpointer to the destination character string
[in]posposition of the first character
[in]countrequested substring length
Returns
number of characters copied.
Exceptions
std::out_of_rangeif pos > size()

◆ data()

template<typename CharT , typename Traits >
constexpr const CharT * pmem::obj::basic_string_view< CharT, Traits >::data
inlineconstexprnoexcept

Returns pointer to data stored in this pmem::obj::string_view.

It may not contain the terminating null character.

Returns
pointer to C-like string (char *), it may not end with null character.

◆ empty()

template<typename CharT , typename Traits >
constexpr bool pmem::obj::basic_string_view< CharT, Traits >::empty
inlineconstexprnoexcept

Returns that view is empty or not.

Returns
true when size() == 0.

◆ end()

template<typename CharT , typename Traits >
constexpr basic_string_view< CharT, Traits >::const_iterator pmem::obj::basic_string_view< CharT, Traits >::end
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.

Returns
const_iterator to the character following the last character.

◆ find() [1/3]

template<typename CharT , typename Traits >
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find ( CharT  ch,
size_type  pos = 0 
) const
noexcept

Finds the first character ch.

Parameters
[in]chcharacter to search for
[in]posposition at which to start the search
Returns
Position of the first character equal to ch, or npos if no such character is found.

◆ find() [2/3]

template<typename CharT , typename Traits >
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.

Parameters
[in]spointer to the C-style string to search for
[in]posposition at which to start the search
[in]countlength of the substring to search for
Returns
Position of the first character of the found substring or npos if no such substring is found.

◆ find() [3/3]

template<typename CharT , typename Traits >
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.

Parameters
[in]spointer to the C-style string to search for
[in]posposition at which to start the search
Returns
Position of the first character of the found substring or npos if no such substring is found.

◆ find_first_not_of() [1/4]

template<typename CharT , typename Traits >
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_first_not_of ( basic_string_view< CharT, Traits >  str,
size_type  pos = 0 
) const
noexcept

Finds the first character equal to none of the characters in str.

Parameters
[in]strstring identifying characters to search for
[in]posposition at which to start the search
Returns
The position of the first character that does not match. If no such characters are found, the function returns npos.

◆ find_first_not_of() [2/4]

template<typename CharT , typename Traits >
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_first_not_of ( CharT  ch,
size_type  pos = 0 
) const
noexcept

Finds the first character not equal to ch.

Parameters
[in]chcharacter to search for
[in]posposition at which to start the search
Returns
The position of the first character that does not match. If no such characters are found, the function returns npos.

◆ find_first_not_of() [3/4]

template<typename CharT , typename Traits >
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.

Parameters
[in]spointer to the C-style string identifying characters to search for
[in]posposition at which to start the search
[in]countlength of the C-style string identifying characters to search for
Returns
The position of the first character that does not match. If no such characters are found, the function returns npos.

◆ find_first_not_of() [4/4]

template<typename CharT , typename Traits >
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

Parameters
[in]spointer to the C-style string identifying characters to search for
[in]posposition at which to start the search
Returns
The position of the first character that does not match. If no such characters are found, the function returns npos.

◆ find_first_of() [1/4]

template<typename CharT , typename Traits >
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_first_of ( basic_string_view< CharT, Traits >  str,
size_type  pos = 0 
) const
noexcept

Finds the first character equal to any of the characters in str.

Parameters
[in]strstring identifying characters to search for
[in]posposition at which to start the search
Returns
The position of the first character that matches. If no matches are found, the function returns npos.

◆ find_first_of() [2/4]

template<typename CharT , typename Traits >
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_first_of ( CharT  ch,
size_type  pos = 0 
) const
noexcept

Finds the first character equal to ch.

Parameters
[in]chcharacter to search for
[in]posposition at which to start the search
Returns
The position of the first character that matches. If no matches are found, the function returns npos.

◆ find_first_of() [3/4]

template<typename CharT , typename Traits >
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.

Parameters
[in]spointer to the C-style string identifying characters to search for
[in]posposition at which to start the search
[in]countlength of the C-style string identifying characters to search for
Returns
The position of the first character that matches. If no matches are found, the function returns npos.

◆ find_first_of() [4/4]

template<typename CharT , typename Traits >
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

Parameters
[in]spointer to the C-style string identifying characters to search for
[in]posposition at which to start the search
Returns
The position of the first character that matches. If no matches are found, the function returns npos.

◆ find_last_not_of() [1/4]

template<typename CharT , typename Traits >
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_last_not_of ( basic_string_view< CharT, Traits >  str,
size_type  pos = npos 
) const
noexcept

Finds the last character equal to none of the characters in str.

Parameters
[in]strstring identifying characters to search for
[in]posposition at which to start the search
Returns
The position of the first character that does not match. If no such characters are found, the function returns npos.

◆ find_last_not_of() [2/4]

template<typename CharT , typename Traits >
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_last_not_of ( CharT  ch,
size_type  pos = npos 
) const
noexcept

Finds the last character not equal to ch.

Parameters
[in]chcharacter to search for
[in]posposition at which to start the search
Returns
The position of the first character that does not match. If no such characters are found, the function returns npos.

◆ find_last_not_of() [3/4]

template<typename CharT , typename Traits >
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.

Parameters
[in]spointer to the C-style string identifying characters to search for
[in]posposition at which to start the search
[in]countlength of the C-style string identifying characters to search for
Returns
The position of the first character that does not match. If no such characters are found, the function returns npos.

◆ find_last_not_of() [4/4]

template<typename CharT , typename Traits >
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

Parameters
[in]spointer to the C-style string identifying characters to search for
[in]posposition at which to start the search
Returns
Position of the first character not equal to any of the characters in the given string, or npos if no such character is found.

◆ find_last_of() [1/4]

template<typename CharT , typename Traits >
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_last_of ( basic_string_view< CharT, Traits >  str,
size_type  pos = npos 
) const
noexcept

Finds the last character equal to any of the characters in str.

Parameters
[in]strstring identifying characters to search for
[in]posposition at which to start the search
Returns
The position of the last character that matches. If no matches are found, the function returns npos.

◆ find_last_of() [2/4]

template<typename CharT , typename Traits >
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::find_last_of ( CharT  ch,
size_type  pos = npos 
) const
noexcept

Finds the last character equal to ch.

Parameters
[in]chcharacter to search for
[in]posposition at which to start the search
Returns
The position of the last character that matches. If no matches are found, the function returns npos.

◆ find_last_of() [3/4]

template<typename CharT , typename Traits >
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.

Parameters
[in]spointer to the C-style string identifying characters to search for
[in]posposition at which to start the search
[in]countlength of the C-style string identifying characters to search for
Returns
The position of the last character that matches. If no matches are found, the function returns npos.

◆ find_last_of() [4/4]

template<typename CharT , typename Traits >
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

Parameters
[in]spointer to the C-style string identifying characters to search for
[in]posposition at which to start the search
Returns
The position of the last character that matches. If no matches are found, the function returns npos.

◆ front()

template<typename CharT , typename Traits >
constexpr const CharT & pmem::obj::basic_string_view< CharT, Traits >::front
inlineconstexprnoexcept

Returns reference to the first character in the view.

The behavior is undefined if empty() == true.

Returns
reference to the first character.

◆ length()

template<typename CharT , typename Traits >
constexpr basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::length
inlineconstexprnoexcept

Returns count of characters stored in this pmem::obj::string_view data.

Returns
the number of CharT elements in the view.

◆ max_size()

template<typename CharT , typename Traits >
constexpr basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::max_size
inlineconstexprnoexcept

Returns the largest possible number of char-like objects that can be referred to by a basic_string_view.

Returns
maximum number of characters.

◆ operator[]()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const CharT & pmem::obj::basic_string_view< CharT, Traits >::operator[] ( size_type  pos) const
inlineconstexprnoexcept

Returns reference to a character at position.

Parameters
[in]pos.
Returns
reference to the char.

◆ remove_prefix()

template<typename CharT , typename Traits >
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().

Parameters
[in]nnumber of characters to remove from the start of the view

◆ remove_suffix()

template<typename CharT , typename Traits >
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().

Parameters
[in]nnumber of characters to remove from the end of the view

◆ rfind() [1/4]

template<typename CharT , typename Traits >
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::rfind ( basic_string_view< CharT, Traits >  str,
size_type  pos = npos 
) const
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.

Parameters
[in]strstring to search for
[in]posposition at which to start the search
Returns
Position (as an offset from the start of the string) of the first character of the found substring or npos if no such substring is found

◆ rfind() [2/4]

template<typename CharT , typename Traits >
basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::rfind ( CharT  ch,
size_type  pos = npos 
) const
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.

Parameters
[in]chcharacter to search for
[in]posposition at which to start the search
Returns
Position (as an offset from the start of the string) of the first character equal to ch or npos if no such character is found

◆ rfind() [3/4]

template<typename CharT , typename Traits >
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.

Parameters
[in]spointer to the C-style string to search for
[in]posposition at which to start the search
[in]countlength of the substring to search for
Returns
Position (as an offset from the start of the string) of the first character of the found substring or npos if no such substring is found. If searching for an empty string returns pos unless pos > size(), in which case returns size().

◆ rfind() [4/4]

template<typename CharT , typename Traits >
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.

Parameters
[in]spointer to the C-style string to search for
[in]posposition at which to start the search
Returns
Position (as an offset from the start of the string) of the first character of the found substring or npos if no such substring is found

◆ size()

template<typename CharT , typename Traits >
constexpr basic_string_view< CharT, Traits >::size_type pmem::obj::basic_string_view< CharT, Traits >::size
inlineconstexprnoexcept

Returns count of characters stored in this pmem::obj::string_view data.

Returns
the number of CharT elements in the view.

◆ substr()

template<typename CharT , typename Traits >
constexpr basic_string_view< CharT, Traits > pmem::obj::basic_string_view< CharT, Traits >::substr ( size_type  pos = 0,
size_type  count = npos 
) const
constexpr

Returns a view of the substring [pos, pos + rcount), where rcount is the smaller of count and size() - pos.

Parameters
[in]posposition of the first character
[in]countrequested length
Returns
view of the substring [pos, pos + rcount).
Exceptions
std::out_of_rangeif pos > size()

◆ swap()

template<typename CharT , typename Traits >
void pmem::obj::basic_string_view< CharT, Traits >::swap ( basic_string_view< CharT, Traits > &  v)
noexcept

Exchanges the view with that of v.

Parameters
[in]vview to swap with

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