mqtt_cpp
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | List of all members
MQTT_NS::buffer Class Reference

buffer that has string_view interface This class provides string_view interface. This class hold string_view target's lifetime optionally. More...

#include <buffer.hpp>

Inheritance diagram for MQTT_NS::buffer:
Inheritance graph
[legend]
Collaboration diagram for MQTT_NS::buffer:
Collaboration graph
[legend]

Public Member Functions

constexpr buffer (string_view sv=string_view())
 string_view constructor More...
 
 buffer (std::string)=delete
 string constructor (deleted) More...
 
 buffer (string_view sv, const_shared_ptr_array spa)
 string_view and lifetime constructor More...
 
buffer substr (std::size_t offset, std::size_t length=string_view::npos) const &
 get substring The returned buffer ragnge is the same as std::string_view::substr(). In addition the lifetime is shared between returned buffer and this buffer. More...
 
buffer substr (std::size_t offset, std::size_t length=string_view::npos) &&
 get substring The returned buffer ragnge is the same as std::string_view::substr(). In addition the lifetime is moved to returned buffer. More...
 
bool has_life () const
 check the buffer has lifetime. More...
 

Detailed Description

buffer that has string_view interface This class provides string_view interface. This class hold string_view target's lifetime optionally.

Constructor & Destructor Documentation

◆ buffer() [1/3]

constexpr MQTT_NS::buffer::buffer ( string_view  sv = string_view())
inlineexplicitconstexpr

string_view constructor

Parameters
svstring_view This constructor doesn't hold the sv target's lifetime. It behaves as string_view. Caller needs to manage the target lifetime.

◆ buffer() [2/3]

MQTT_NS::buffer::buffer ( std::string  )
explicitdelete

string constructor (deleted)

Parameters
stringThis constructor is intentionally deleted. Consider buffer(std::string("ABC")), the buffer points to dangling reference.

◆ buffer() [3/3]

MQTT_NS::buffer::buffer ( string_view  sv,
const_shared_ptr_array  spa 
)
inline

string_view and lifetime constructor

Parameters
svstring_view
spashared_ptr_array that holds sv target's lifetime If user creates buffer via this constructor, spa's lifetime is held by the buffer.

Member Function Documentation

◆ has_life()

bool MQTT_NS::buffer::has_life ( ) const
inline

check the buffer has lifetime.

Returns
true the buffer has lifetime. false the buffer doesn't have lifetime, This means the buffer is a pure view.

◆ substr() [1/2]

buffer MQTT_NS::buffer::substr ( std::size_t  offset,
std::size_t  length = string_view::npos 
) &&
inline

get substring The returned buffer ragnge is the same as std::string_view::substr(). In addition the lifetime is moved to returned buffer.

Parameters
offsetoffset point of the buffer
lengthlength of the buffer, If the length is string_view::npos then the length is from offset to the end of string.

◆ substr() [2/2]

buffer MQTT_NS::buffer::substr ( std::size_t  offset,
std::size_t  length = string_view::npos 
) const &
inline

get substring The returned buffer ragnge is the same as std::string_view::substr(). In addition the lifetime is shared between returned buffer and this buffer.

Parameters
offsetoffset point of the buffer
lengthlength of the buffer, If the length is string_view::npos then the length is from offset to the end of string.

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