PMEMKV  1.2.1-git1.g9b6e240
This is the C++ documentation for PMEMKV.
Public Member Functions | Private Attributes | List of all members
pmem::kv::string_view Class Reference

Our brief std::string_view implementation. More...

#include </pmemkv/doc_update/pmemkv/src/libpmemkv.hpp>

Public Member Functions

 string_view () noexcept
 Default constructor with empty data. More...
 
 string_view (const char *data, size_t size)
 Constructor initialized by data and its size. More...
 
 string_view (const std::string &s)
 Constructor initialized by the string s. More...
 
 string_view (const char *data)
 Constructor initialized by data. More...
 
 string_view (const string_view &rhs) noexcept=default
 
string_viewoperator= (const string_view &rhs) noexcept=default
 
const char * data () const noexcept
 Returns pointer to data stored in this pmem::kv::string_view. More...
 
std::size_t size () const noexcept
 Returns count of characters stored in this pmem::kv::string_view data. More...
 
int compare (const string_view &other) noexcept
 Compares this string_view with other. More...
 

Private Attributes

const char * _data
 
std::size_t _size
 

Detailed Description

Our brief 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

◆ string_view() [1/5]

pmem::kv::string_view::string_view ( )
inlinenoexcept

Default constructor with empty data.

◆ string_view() [2/5]

pmem::kv::string_view::string_view ( const char *  data,
size_t  size 
)
inline

Constructor initialized by data and its size.

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

◆ string_view() [3/5]

pmem::kv::string_view::string_view ( const std::string &  s)
inline

Constructor initialized by the string s.

Parameters
[in]sreference to the string to initialize with

◆ string_view() [4/5]

pmem::kv::string_view::string_view ( const char *  data)
inline

Constructor initialized by data.

Size of the data will be set using std::char_traits<char>::length().

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

◆ string_view() [5/5]

pmem::kv::string_view::string_view ( const string_view rhs)
defaultnoexcept

Member Function Documentation

◆ compare()

int pmem::kv::string_view::compare ( const string_view other)
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()

const char * pmem::kv::string_view::data ( ) const
inlinenoexcept

Returns pointer to data stored in this pmem::kv::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=()

string_view& pmem::kv::string_view::operator= ( const string_view rhs)
defaultnoexcept

◆ size()

std::size_t pmem::kv::string_view::size ( ) const
inlinenoexcept

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

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

Member Data Documentation

◆ _data

const char* pmem::kv::string_view::_data
private

◆ _size

std::size_t pmem::kv::string_view::_size
private

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