CIRCT 22.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
esi::MessageData Class Reference

A logical chunk of data representing serialized data. More...

#include <Common.h>

Collaboration diagram for esi::MessageData:
Collaboration graph
[legend]

Public Member Functions

 MessageData ()=default
 Adopts the data vector buffer.
 
 MessageData (std::span< const uint8_t > data)
 
 MessageData (std::vector< uint8_t > &data)
 
 MessageData (std::vector< uint8_t > &&data)
 
 MessageData (const uint8_t *data, size_t size)
 
 ~MessageData ()=default
 
const uint8_t * getBytes () const
 
const std::vector< uint8_t > & getData () const
 Get the data as a vector of bytes.
 
 operator const std::vector< uint8_t > & () const
 Implicit conversion to a vector/span of bytes, to play nice with other APIs that accept bytearray-like things.
 
 operator std::span< const uint8_t > () const
 
std::vector< uint8_t > takeData ()
 Move the data out of this object.
 
size_t getSize () const
 Get the size of the data in bytes.
 
size_t size () const
 
bool empty () const
 Returns true if this message contains no data.
 
template<typename T >
const T * as () const
 Cast to a type.
 
std::string toHex () const
 Convert the data to a hex string.
 

Static Public Member Functions

template<typename T >
static MessageData from (T &t)
 Cast from a type to its raw bytes.
 

Private Attributes

std::vector< uint8_t > data
 

Detailed Description

A logical chunk of data representing serialized data.

Currently, just a wrapper for a vector of bytes, which is not efficient in terms of memory copying. This will change in the future as will the API.

Definition at line 107 of file Common.h.

Constructor & Destructor Documentation

◆ MessageData() [1/5]

esi::MessageData::MessageData ( )
default

Adopts the data vector buffer.

Referenced by from().

◆ MessageData() [2/5]

esi::MessageData::MessageData ( std::span< const uint8_t >  data)
inline

Definition at line 111 of file Common.h.

◆ MessageData() [3/5]

esi::MessageData::MessageData ( std::vector< uint8_t > &  data)
inline

Definition at line 113 of file Common.h.

◆ MessageData() [4/5]

esi::MessageData::MessageData ( std::vector< uint8_t > &&  data)
inline

Definition at line 114 of file Common.h.

◆ MessageData() [5/5]

esi::MessageData::MessageData ( const uint8_t *  data,
size_t  size 
)
inline

Definition at line 115 of file Common.h.

◆ ~MessageData()

esi::MessageData::~MessageData ( )
default

Member Function Documentation

◆ as()

template<typename T >
const T * esi::MessageData::as ( ) const
inline

Cast to a type.

Throws if the size of the data does not match the size of the message. The lifetime of the resulting pointer is tied to the lifetime of this object.

Definition at line 142 of file Common.h.

References data.

◆ empty()

bool esi::MessageData::empty ( ) const
inline

Returns true if this message contains no data.

Definition at line 136 of file Common.h.

References data.

◆ from()

template<typename T >
static MessageData esi::MessageData::from ( T &  t)
inlinestatic

Cast from a type to its raw bytes.

Definition at line 152 of file Common.h.

References MessageData().

◆ getBytes()

const uint8_t * esi::MessageData::getBytes ( ) const
inline

Definition at line 118 of file Common.h.

References data.

Referenced by log(), PYBIND11_MODULE(), and sv2cCosimserverEpTryGet().

◆ getData()

const std::vector< uint8_t > & esi::MessageData::getData ( ) const
inline

Get the data as a vector of bytes.

Definition at line 121 of file Common.h.

References data.

◆ getSize()

size_t esi::MessageData::getSize ( ) const
inline

Get the size of the data in bytes.

Definition at line 132 of file Common.h.

References data.

Referenced by log(), PYBIND11_MODULE(), size(), and sv2cCosimserverEpTryGet().

◆ operator const std::vector< uint8_t > &()

esi::MessageData::operator const std::vector< uint8_t > & ( ) const
inline

Implicit conversion to a vector/span of bytes, to play nice with other APIs that accept bytearray-like things.

Definition at line 125 of file Common.h.

References data.

◆ operator std::span< const uint8_t >()

esi::MessageData::operator std::span< const uint8_t > ( ) const
inline

Definition at line 126 of file Common.h.

References data.

◆ size()

size_t esi::MessageData::size ( ) const
inline

◆ takeData()

std::vector< uint8_t > esi::MessageData::takeData ( )
inline

Move the data out of this object.

Definition at line 129 of file Common.h.

References data.

◆ toHex()

std::string MessageData::toHex ( ) const

Convert the data to a hex string.

Definition at line 22 of file Common.cpp.

References data.

Member Data Documentation

◆ data

std::vector<uint8_t> esi::MessageData::data
private

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