MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ read_blob()

std::vector< uint8_t > MayaFlux::Transitive::Protocol::read_blob ( const uint8_t *  data,
size_t  max_len,
size_t &  offset 
)
inline

Read a length-prefixed blob from a byte buffer.

Format: [int32 size (big-endian)][data, padded to 4-byte boundary]. Advances offset past the blob. Returns empty vector on invalid size.

Parameters
dataBuffer start.
max_lenTotal buffer size in bytes.
offsetCurrent read position, advanced on return.

Definition at line 99 of file BinaryBuffer.hpp.

101{
102 int32_t blob_size = read_int32(data, offset);
103 if (blob_size < 0
104 || offset + static_cast<size_t>(blob_size) > max_len) {
105 return {};
106 }
107 std::vector<uint8_t> result(
108 data + offset, data + offset + blob_size);
109 offset += padded_size(static_cast<size_t>(blob_size));
110 return result;
111}
int32_t read_int32(const uint8_t *data, size_t &offset)
Read a big-endian int32 from a byte buffer.

References padded_size(), and read_int32().

Referenced by MayaFlux::Core::OscParser::parse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: