Nets v3.0.0
StreamMessage Class Reference

Network stream message container. (TCP). More...

#include <stream-message.hpp>

Public Member Functions

 StreamMessage () noexcept
 Creates a new empty stream message.
 StreamMessage (::StreamMessage streamMessage) noexcept
 Creates a new stream message. (TCP).
const uint8_tgetEnd () const noexcept
 Returns stream message end pointer.
bool isComplete () const noexcept
 Returns true if stream message is not empty and complete, otherwise false.
size_t getLeft () const noexcept
 Returns stream message byte count left to read or write.
bool read (const void *&data, size_t count) noexcept
 Reads data from the stream message and advances offset.
bool read (uint8_t &value) noexcept
 Reads 8-bit unsigned integer value from the stream message and advances offset.
bool read (uint16_t &value) noexcept
 Reads 16-bit unsigned integer value from the stream message and advances offset.
bool read (uint32_t &value) noexcept
 Reads 32-bit unsigned integer value from the stream message and advances offset.
bool read (uint64_t &value) noexcept
 Reads 64-bit unsigned integer value from the stream message and advances offset.
bool read (int8_t &value) noexcept
 Reads 8-bit signed integer value from the stream message and advances offset.
bool read (int16_t &value) noexcept
 Reads 16-bit signed integer value from the stream message and advances offset.
bool read (int32_t &value) noexcept
 Reads 32-bit signed integer value from the stream message and advances offset.
bool read (int64_t &value) noexcept
 Reads 64-bit signed integer value from the stream message and advances offset.
bool read (float &value) noexcept
 Reads 32-bit floating point value from the stream message and advances offset.
bool read (double &value) noexcept
 Reads 64-bit floating point value from the stream message and advances offset.
bool read (std::string_view &value, uint8_t lengthSize) noexcept
 Reads string from the stream message and advances offset.
bool read (std::string &value, uint8_t lengthSize) noexcept
 Reads string from the stream message and advances offset.
bool read (bool &value) noexcept
 Reads boolean value from the stream message and advances offset.
bool read (const void *&data, size_t &dataSize, uint8_t lengthSize) noexcept
 Reads data from the stream message and advances offset.
template<class T>
bool read (std::vector< T > &data, uint8_t lengthSize) noexcept
 Reads vector data from the stream message and advances offset.

Data Fields

uint8_titer

Static Public Attributes

static constexpr uint8_t maxLengthSize = STREAM_MESSAGE_MAX_LENGTH_SIZE
 Maximum size of the stream message length in bytes.
static constexpr uint16_t maxDatagramSize = MAX_DATAGRAM_MESSAGE_SIZE
 Safe maximum UDP datagram size in bytes. (Includes IP and VPN overhead).

Protected Attributes

uint8_tend

Detailed Description

Network stream message container. (TCP).

See the stream-message.h

Constructor & Destructor Documentation

◆ StreamMessage()

StreamMessage ( ::StreamMessage streamMessage)
inlinenoexcept

Creates a new stream message. (TCP).

Parameters
streamMessagetarget stream message data

Member Function Documentation

◆ isComplete()

bool isComplete ( ) const
inlinenoexcept

Returns true if stream message is not empty and complete, otherwise false.

See the isStreamMessageComplete().

◆ getLeft()

size_t getLeft ( ) const
inlinenoexcept

Returns stream message byte count left to read or write.

See the getStreamMessageLeft().

◆ read() [1/16]

bool read ( const void *& data,
size_t count )
inlinenoexcept

Reads data from the stream message and advances offset.

See the readStreamMessage().

Returns
True if no more data to read, otherwise false.
Parameters
[out]datareference to the message data
countmessage byte count to read

◆ read() [2/16]

bool read ( uint8_t & value)
inlinenoexcept

Reads 8-bit unsigned integer value from the stream message and advances offset.

See the readStreamMessageUint8().

Returns
True if no more data to read, otherwise false.
Parameters
[out]valuereference to the unsigned integer value

◆ read() [3/16]

bool read ( uint16_t & value)
inlinenoexcept

Reads 16-bit unsigned integer value from the stream message and advances offset.

See the readStreamMessageUint16().

Returns
True if no more data to read, otherwise false.
Parameters
[out]valuereference to the unsigned integer value

◆ read() [4/16]

bool read ( uint32_t & value)
inlinenoexcept

Reads 32-bit unsigned integer value from the stream message and advances offset.

See the readStreamMessageUint32().

Returns
True if no more data to read, otherwise false.
Parameters
[out]valuereference to the unsigned integer value

◆ read() [5/16]

bool read ( uint64_t & value)
inlinenoexcept

Reads 64-bit unsigned integer value from the stream message and advances offset.

See the readStreamMessageUint64().

Returns
True if no more data to read, otherwise false.
Parameters
[out]valuereference to the unsigned integer value

◆ read() [6/16]

bool read ( int8_t & value)
inlinenoexcept

Reads 8-bit signed integer value from the stream message and advances offset.

See the readStreamMessageInt8().

Returns
True if no more data to read, otherwise false.
Parameters
[out]valuereference to the signed integer value

◆ read() [7/16]

bool read ( int16_t & value)
inlinenoexcept

Reads 16-bit signed integer value from the stream message and advances offset.

See the readStreamMessageInt16().

Returns
True if no more data to read, otherwise false.
Parameters
[out]valuereference to the signed integer value

◆ read() [8/16]

bool read ( int32_t & value)
inlinenoexcept

Reads 32-bit signed integer value from the stream message and advances offset.

See the readStreamMessageInt32().

Returns
True if no more data to read, otherwise false.
Parameters
[out]valuereference to the signed integer value

◆ read() [9/16]

bool read ( int64_t & value)
inlinenoexcept

Reads 64-bit signed integer value from the stream message and advances offset.

See the readStreamMessageInt64().

Returns
True if no more data to read, otherwise false.
Parameters
[out]valuereference to the signed integer value

◆ read() [10/16]

bool read ( float & value)
inlinenoexcept

Reads 32-bit floating point value from the stream message and advances offset.

See the readStreamMessageFloat32().

Returns
True if no more data to read, otherwise false.
Parameters
[out]valuereference to the floating point value

◆ read() [11/16]

bool read ( double & value)
inlinenoexcept

Reads 64-bit floating point value from the stream message and advances offset.

See the readStreamMessageFloat64().

Returns
True if no more data to read, otherwise false.
Parameters
[out]valuereference to the floating point value

◆ read() [12/16]

bool read ( std::string_view & value,
uint8_t lengthSize )
inlinenoexcept

Reads string from the stream message and advances offset.

See the readStreamMessageData().

Returns
True if no more data to read, otherwise false.
Parameters
[out]valuereference to the message string
lengthSizelength of the string size in bytes

◆ read() [13/16]

bool read ( std::string & value,
uint8_t lengthSize )
inlinenoexcept

Reads string from the stream message and advances offset.

See the readStreamMessageData().

Returns
True if no more data to read, otherwise false.
Parameters
[out]valuereference to the message string
lengthSizelength of the string size in bytes

◆ read() [14/16]

bool read ( bool & value)
inlinenoexcept

Reads boolean value from the stream message and advances offset.

See the readStreamMessageBool().

Returns
True if no more data to read, otherwise false.
Parameters
[out]valuereference to the boolean value

◆ read() [15/16]

bool read ( const void *& data,
size_t & dataSize,
uint8_t lengthSize )
inlinenoexcept

Reads data from the stream message and advances offset.

See the readStreamMessageData().

Returns
True if no more data to read, otherwise false.
Parameters
[out]datareference to the message data
[out]dataSizereference to the data size in bytes
lengthSizelength of the data size in bytes

◆ read() [16/16]

template<class T>
bool read ( std::vector< T > & data,
uint8_t lengthSize )
inlinenoexcept

Reads vector data from the stream message and advances offset.

See the readStreamMessageData().

Returns
True if no more data to read, otherwise false.
Template Parameters
Ttype of the vector data
Parameters
[out]datareference to the message data vector
lengthSizelength of the data size in bytes