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

◆ read_string()

std::string MayaFlux::Transitive::Protocol::read_string ( const uint8_t *  data,
size_t  max_len,
size_t &  offset 
)
inline

Read a null-terminated string from a byte buffer.

Advances offset by padded_size(len + 1). Safe: will not read past max_len.

Parameters
dataBuffer start.
max_lenTotal buffer size in bytes.
offsetCurrent read position, advanced on return.
Returns
Parsed string, empty if offset is already at or past max_len.

Definition at line 36 of file BinaryBuffer.hpp.

38{
39 if (offset >= max_len) {
40 return {};
41 }
42 const auto* start = reinterpret_cast<const char*>(data + offset);
43 size_t len = strnlen(start, max_len - offset);
44 std::string result(start, len);
45 offset += padded_size(len + 1);
46 return result;
47}

References padded_size().

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

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