Paho C++  1.0
The Paho MQTT C++ Client Library
 All Classes Files Functions Variables Typedefs Friends
mqtt::buffer_view< T > Class Template Reference

A reference to a contiguous sequence of items, with no ownership. More...

#include <buffer_view.h>

Public Types

using value_type = T
 The type of items to be held in the queue. More...
 
using size_type = size_t
 The type used to specify number of items in the container. More...
 

Public Member Functions

 buffer_view (const value_type *data, size_type n)
 Constructs a buffer view. More...
 
 buffer_view (const std::basic_string< value_type > &str)
 Constructs a buffer view to a whole string. More...
 
const value_typedata () const
 Gets a pointer the first item in the view. More...
 
size_type size () const
 Gets the number of items in the view. More...
 
size_type length () const
 Gets the number of items in the view. More...
 
const value_typeoperator[] (size_t i) const
 Access an item in the view. More...
 
std::basic_string< value_typestr () const
 Gets a copy of the view as a string. More...
 
string to_string () const
 Gets a copy of the view as a string. More...
 

Detailed Description

template<typename T>
class mqtt::buffer_view< T >

A reference to a contiguous sequence of items, with no ownership.

This simply contains a pointer to a const array of items, and a size. This is a similar, but simplified version of the std::string_view class(es) in the C++17 standard.

Member Typedef Documentation

template<typename T >
using mqtt::buffer_view< T >::size_type = size_t

The type used to specify number of items in the container.

template<typename T >
using mqtt::buffer_view< T >::value_type = T

The type of items to be held in the queue.

Constructor & Destructor Documentation

template<typename T >
mqtt::buffer_view< T >::buffer_view ( const value_type data,
size_type  n 
)
inline

Constructs a buffer view.

Parameters
dataThe data pointer
nThe number of items
template<typename T >
mqtt::buffer_view< T >::buffer_view ( const std::basic_string< value_type > &  str)
inline

Constructs a buffer view to a whole string.

This the starting pointer and length of the whole string.

Parameters
strThe string.

Member Function Documentation

template<typename T >
const value_type* mqtt::buffer_view< T >::data ( ) const
inline

Gets a pointer the first item in the view.

Returns
A const pointer the first item in the view.
template<typename T >
size_type mqtt::buffer_view< T >::length ( ) const
inline

Gets the number of items in the view.

Returns
The number of items in the view.
template<typename T >
const value_type& mqtt::buffer_view< T >::operator[] ( size_t  i) const
inline

Access an item in the view.

Parameters
iThe index of the item.
Returns
A const reference to the requested item.
template<typename T >
size_type mqtt::buffer_view< T >::size ( ) const
inline

Gets the number of items in the view.

Returns
The number of items in the view.
template<typename T >
std::basic_string<value_type> mqtt::buffer_view< T >::str ( ) const
inline

Gets a copy of the view as a string.

Returns
A copy of the view as a string.
template<typename T >
string mqtt::buffer_view< T >::to_string ( ) const
inline

Gets a copy of the view as a string.

Returns
A copy of the view as a string.

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