PMDK C++ bindings  1.11.1
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

 basic_string_view () noexcept
 Default constructor with empty data.
 
 basic_string_view (const CharT *data, size_type size)
 Constructor initialized by data and its size. More...
 
 basic_string_view (const std::basic_string< CharT, Traits > &s)
 Constructor initialized by the basic string s. More...
 
 basic_string_view (const CharT *data)
 Constructor initialized by data. More...
 
const CharT * data () const noexcept
 Returns pointer to data stored in this pmem::obj::string_view. More...
 
size_type size () const noexcept
 Returns count of characters stored in this pmem::obj::string_view data. More...
 
const CharT & operator[] (size_type p) const noexcept
 Returns reference to a character at position. More...
 
int compare (const basic_string_view &other) const noexcept
 Compares this string_view with other. 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 >
pmem::obj::basic_string_view< CharT, Traits >::basic_string_view ( const CharT *  data,
size_type  size 
)
inline

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 >
pmem::obj::basic_string_view< CharT, Traits >::basic_string_view ( const std::basic_string< CharT, Traits > &  s)
inline

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 >
pmem::obj::basic_string_view< CharT, Traits >::basic_string_view ( const CharT *  data)
inline

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

◆ compare()

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.

◆ data()

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

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.

◆ operator[]()

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

Returns reference to a character at position.

Parameters
[in]p.
Returns
reference to a char.

◆ size()

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

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

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

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