async_mqtt 9.0.1
Loading...
Searching...
No Matches
async_mqtt::basic_packet_variant< PacketIdBytes > Class Template Reference

The varaint type of all packets and system_error. More...

Public Member Functions

 basic_packet_variant ()=default
 constructor the variant value is monostate
 
template<typename Packet , std::enable_if_t< !std::is_same_v< std::decay_t< Packet >, basic_packet_variant< PacketIdBytes > >, std::nullptr_t > = nullptr>
 basic_packet_variant (Packet &&packet)
 constructor
 
template<typename Func >
auto visit (Func &&func) const &
 visit to variant
 
template<typename Func >
auto visit (Func &&func) &
 visit to variant
 
template<typename Func >
auto visit (Func &&func) &&
 visit to variant
 
template<typename T >
decltype(auto) get ()
 Get by type. If not match, then throw std::bad_variant_access exception.
 
template<typename T >
decltype(auto) get () const
 Get by type. If not match, then throw std::bad_variant_access exception.
 
template<typename T >
decltype(auto) get_if ()
 Get by type pointer.
 
template<typename T >
decltype(auto) get_if () const
 Get by type pointer.
 
std::optional< control_packet_typetype () const
 Get control_packet_type.
 
std::vector< as::const_buffer > const_buffer_sequence () const
 Create const buffer sequence it is for boost asio APIs.
 

Friends

bool operator< (basic_packet_variant< PacketIdBytes > const &lhs, basic_packet_variant< PacketIdBytes > const &rhs)
 less than operator
 
bool operator== (basic_packet_variant< PacketIdBytes > const &lhs, basic_packet_variant< PacketIdBytes > const &rhs)
 equal operator
 

Related Symbols

(Note that these are not member symbols.)

using packet_variant = basic_packet_variant<2>
 type alias of basic_packet_variant (PacketIdBytes=2).
 
template<std::size_t PacketIdBytes>
std::ostream & operator<< (std::ostream &o, basic_packet_variant< PacketIdBytes > const &v)
 stream output operator
 

Detailed Description

template<std::size_t PacketIdBytes>
class async_mqtt::basic_packet_variant< PacketIdBytes >

The varaint type of all packets and system_error.

Thread Safety

  • Distinct objects: Safe
  • Shared objects: Unsafe

Requirements

Constructor & Destructor Documentation

◆ basic_packet_variant()

template<std::size_t PacketIdBytes>
template<typename Packet , std::enable_if_t< !std::is_same_v< std::decay_t< Packet >, basic_packet_variant< PacketIdBytes > >, std::nullptr_t > = nullptr>
async_mqtt::basic_packet_variant< PacketIdBytes >::basic_packet_variant ( Packet && packet)

constructor

Parameters
packetpacket

Member Function Documentation

◆ const_buffer_sequence()

template<std::size_t PacketIdBytes>
std::vector< as::const_buffer > async_mqtt::basic_packet_variant< PacketIdBytes >::const_buffer_sequence ( ) const

Create const buffer sequence it is for boost asio APIs.

Returns
const buffer sequence

◆ get() [1/2]

template<std::size_t PacketIdBytes>
template<typename T >
decltype(auto) async_mqtt::basic_packet_variant< PacketIdBytes >::get ( )

Get by type. If not match, then throw std::bad_variant_access exception.

Returns
actual packet

◆ get() [2/2]

template<std::size_t PacketIdBytes>
template<typename T >
decltype(auto) async_mqtt::basic_packet_variant< PacketIdBytes >::get ( ) const

Get by type. If not match, then throw std::bad_variant_access exception.

Returns
actual packet

◆ get_if() [1/2]

template<std::size_t PacketIdBytes>
template<typename T >
decltype(auto) async_mqtt::basic_packet_variant< PacketIdBytes >::get_if ( )

Get by type pointer.

Returns
actual packet pointer. If not match then return nullptr.

◆ get_if() [2/2]

template<std::size_t PacketIdBytes>
template<typename T >
decltype(auto) async_mqtt::basic_packet_variant< PacketIdBytes >::get_if ( ) const

Get by type pointer.

Returns
actual packet pointer. If not match then return nullptr.

◆ type()

template<std::size_t PacketIdBytes>
std::optional< control_packet_type > async_mqtt::basic_packet_variant< PacketIdBytes >::type ( ) const

Get control_packet_type.

Returns
If packet is stored then return its control_packet_type, If error then return std::nullopt.

◆ visit() [1/3]

template<std::size_t PacketIdBytes>
template<typename Func >
auto async_mqtt::basic_packet_variant< PacketIdBytes >::visit ( Func && func) &

visit to variant

Parameters
funcVisitor function

◆ visit() [2/3]

template<std::size_t PacketIdBytes>
template<typename Func >
auto async_mqtt::basic_packet_variant< PacketIdBytes >::visit ( Func && func) &&

visit to variant

Parameters
funcVisitor function

◆ visit() [3/3]

template<std::size_t PacketIdBytes>
template<typename Func >
auto async_mqtt::basic_packet_variant< PacketIdBytes >::visit ( Func && func) const &

visit to variant

Parameters
funcVisitor function

Friends And Related Symbol Documentation

◆ operator<

template<std::size_t PacketIdBytes>
bool operator< ( basic_packet_variant< PacketIdBytes > const & lhs,
basic_packet_variant< PacketIdBytes > const & rhs )
friend

less than operator

Parameters
lhscompare target
rhscompare target
Returns
true if the lhs less than the rhs, otherwise false.

◆ operator<<()

template<std::size_t PacketIdBytes>
std::ostream & operator<< ( std::ostream & o,
basic_packet_variant< PacketIdBytes > const & v )
related

stream output operator

Parameters
ooutput stream
vtarget
Returns
output stream

◆ operator==

template<std::size_t PacketIdBytes>
bool operator== ( basic_packet_variant< PacketIdBytes > const & lhs,
basic_packet_variant< PacketIdBytes > const & rhs )
friend

equal operator

Parameters
lhscompare target
rhscompare target
Returns
true if the lhs equal to the rhs, otherwise false.

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