VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
vlink::Bytes类 参考final

Versatile 128-byte byte buffer with SBO, five ownership modes and compression helpers. 更多...

#include <bytes.h>

vlink::Bytes 的协作图:

Public 成员函数

 Bytes () noexcept
 Constructs an empty, unallocated Bytes object.
 Bytes (const Bytes &target) noexcept
 Copy constructor.
 Bytes (Bytes &&target) noexcept
 Move constructor.
 Bytes (const std::initializer_list< uint8_t > &list) noexcept
 Constructs an owned Bytes from an initialiser list of byte values.
 Bytes (const std::vector< uint8_t > &data) noexcept
 Constructs an owned Bytes by deep-copying a std::vector<uint8_t>.
 ~Bytes () noexcept
 Destructor. Frees owned memory if is_owner() is true and is_loaned() is false.
Bytesoperator= (const Bytes &target) noexcept
 Copy assignment operator.
Bytesoperator= (Bytes &&target) noexcept
 Move assignment operator.
Bytesoperator= (const std::vector< uint8_t > &data) noexcept
 Assignment from a std::vector<uint8_t> (deep copy).
bool operator== (const Bytes &target) const noexcept
 Equality comparison – compares byte content.
bool operator!= (const Bytes &target) const noexcept
 Inequality comparison – compares byte content.
bool operator== (const std::vector< uint8_t > &data) const noexcept
 Equality comparison with a std::vector<uint8_t>.
bool operator!= (const std::vector< uint8_t > &data) const noexcept
 Inequality comparison with a std::vector<uint8_t>.
uint8_t & operator[] (size_t index) noexcept
 Mutable subscript operator.
const uint8_t & operator[] (size_t index) const noexcept
 Read-only subscript operator.
uint8_t * data () noexcept
 Returns a pointer to the start of the user data region (after the prefix offset).
const uint8_t * data () const noexcept
 Returns a const pointer to the start of the user data region.
uint8_t * real_data () noexcept
 Returns a pointer to the very beginning of the backing buffer (before the offset).
const uint8_t * real_data () const noexcept
 Returns a const pointer to the very beginning of the backing buffer.
size_t size () const noexcept
 Returns the number of usable bytes (excluding the prefix offset region).
size_t real_size () const noexcept
 Returns the total backing-buffer size including the prefix offset region.
size_t capacity () const noexcept
 Returns the allocated capacity of the backing buffer.
uint8_t offset () const noexcept
 Returns the size of the prefix offset region in bytes.
bool is_owner () const noexcept
 Returns true if this object owns and is responsible for freeing its buffer.
bool is_loaned () const noexcept
 Returns true if this object holds an iceoryx loaned chunk.
bool empty () const noexcept
 Returns true if the buffer is empty (no data pointer and size == 0).
uint8_t * begin () noexcept
 Iterator begin (mutable) – same as data().
const uint8_t * begin () const noexcept
 Iterator begin (const) – same as data() const.
uint8_t * end () noexcept
 Iterator end (mutable) – one past the last usable byte.
const uint8_t * end () const noexcept
 Iterator end (const) – one past the last usable byte.
uint8_t * real_begin () noexcept
 Iterator begin for the full backing buffer (mutable) – same as real_data().
const uint8_t * real_begin () const noexcept
 Iterator begin for the full backing buffer (const).
uint8_t * real_end () noexcept
 Iterator end for the full backing buffer (mutable).
const uint8_t * real_end () const noexcept
 Iterator end for the full backing buffer (const).
bool is_ptr () const noexcept
 Returns true if the object holds only an opaque pointer (size == 0 and not owner).
std::vector< uint8_t > to_raw_data () const noexcept
 Copies the usable byte region into a new std::vector<uint8_t>.
std::string to_string () const noexcept
 Returns the usable byte region as a std::string.
std::string_view to_string_view () const noexcept
 Returns a zero-copy std::string_view over the usable byte region.
template<typename T = void>
T * to_ptr () const noexcept
 Reinterprets the backing buffer as a pointer to T.
void clear () noexcept
 Releases the buffer and resets the object to the empty state.
bool shrink_to (size_t size) noexcept
 Reduces the logical size of the buffer without reallocating.
bool reserve (size_t new_capacity) noexcept
 Ensures the backing buffer can hold at least new_capacity bytes.
bool resize (size_t size) noexcept
 Resizes the logical data region to size bytes.
Bytesshallow_copy (const Bytes &bytes) noexcept
 Makes this object a non-owning alias of bytes (shallow copy in-place).
Bytesdeep_copy (const Bytes &bytes) noexcept
 Replaces this object with a fully owned deep copy of bytes.
Bytesdeep_copy_self () noexcept
 Converts this object from a non-owning alias to a fully owned deep copy of its own data.

静态 Public 成员函数

static void init_memory_pool () noexcept
 Initialises the global thread-safe memory pool for Bytes allocations.
static void release_memory_pool () noexcept
 Releases the global memory pool and returns its memory to the OS.
static uint8_t * bytes_malloc (size_t size) noexcept
 Allocates a raw byte buffer from the memory pool (or heap if pool is unavailable).
static void bytes_free (uint8_t *ptr, size_t size) noexcept
 Frees a buffer previously allocated by bytes_malloc().
static Bytes create (size_t size, uint8_t offset=0) noexcept
 Creates an owned Bytes buffer of the given size.
static Bytes shallow_copy (uint8_t *data, size_t size) noexcept
 Creates a non-owning Bytes alias pointing to an external mutable buffer.
static Bytes shallow_copy (const uint8_t *data, size_t size) noexcept
 Creates a non-owning Bytes alias pointing to an external read-only buffer.
static Bytes shallow_copy_ptr (void *data) noexcept
 Wraps an opaque pointer without associating a byte size.
static Bytes deep_copy (uint8_t *data, size_t size, uint8_t offset=0) noexcept
 Creates an owned deep copy of an external mutable buffer.
static Bytes deep_copy (const uint8_t *data, size_t size, uint8_t offset=0) noexcept
 Creates an owned deep copy of an external read-only buffer.
static Bytes loan_internal (uint8_t *data, size_t size) noexcept
 Creates a loaned (non-owning) alias for an iceoryx zero-copy payload (mutable).
static Bytes loan_internal (const uint8_t *data, size_t size) noexcept
 Creates a loaned (non-owning) alias for an iceoryx zero-copy payload (read-only).
static Bytes from_string (const std::string &str, uint8_t offset=0) noexcept
 Constructs a Bytes buffer from a std::string by deep-copying its contents.
static Bytes from_user_input (const std::string &str, bool *ok=nullptr) noexcept
 Parses a user-provided hex or binary string literal into a Bytes buffer.
static std::string convert_to_hex_str (const uint8_t *value, size_t size) noexcept
 Converts a raw byte array to an uppercase hex string with spaces.
static Bytes reverse_order (const Bytes &target) noexcept
 Returns a new Bytes object with the byte order of target reversed.
static std::string encode_to_base64 (const Bytes &target) noexcept
 Encodes a Bytes buffer as a standard Base-64 ASCII string.
static Bytes decode_from_base64 (const std::string &target) noexcept
 Decodes a Base-64 ASCII string into a Bytes buffer.
static uint32_t get_crc_32 (const Bytes &target) noexcept
 Computes the CRC-32 checksum of a Bytes buffer.
static constexpr uint8_t stack_size () noexcept
 Returns the size of the inline stack storage in bytes.
static constexpr bool is_little_endian () noexcept
 Returns true if the platform uses little-endian byte order.
static constexpr bool is_big_endian () noexcept
 Returns true if the platform uses big-endian byte order.
static bool is_compress_data (const uint8_t *data, size_t size) noexcept
 Checks whether a raw byte buffer contains LZAV-compressed VLink data.
static Bytes compress_data (const uint8_t *data, size_t size, bool high_ratio=false) noexcept
 Compresses a raw byte buffer using the LZAV algorithm.
static Bytes uncompress_data (const uint8_t *data, size_t size, bool check_valid=true) noexcept
 Decompresses a LZAV-compressed Bytes buffer.

友元

VLINK_EXPORT friend std::ostream & operator<< (std::ostream &ostream, const Bytes &target) noexcept
 Stream insertion operator – prints bytes as space-separated hex pairs.

详细描述

Versatile 128-byte byte buffer with SBO, five ownership modes and compression helpers.

The total object size is always 128 bytes (96-byte inline stack storage + metadata). Allocations larger than 96 bytes spill to the memory pool or system heap.

构造及析构函数说明

◆ Bytes() [1/5]

vlink::Bytes::Bytes ( )
noexcept

Constructs an empty, unallocated Bytes object.

data() returns nullptr and size() returns 0. is_owner() and is_loaned() are both false.

函数调用图:
这是这个函数的调用关系图:

◆ Bytes() [2/5]

vlink::Bytes::Bytes ( const Bytes & target)
noexcept

Copy constructor.

If target is an owner, a deep copy of its data is made. If target is a shallow alias (non-owner, non-loaned), the alias is shared. Loaned objects are shallow-copied as well (ownership is not transferred).

参数
targetSource Bytes to copy.
函数调用图:

◆ Bytes() [3/5]

vlink::Bytes::Bytes ( Bytes && target)
noexcept

Move constructor.

Transfers all ownership and data from target. After the move, target is empty.

参数
targetSource Bytes to move from.
函数调用图:

◆ Bytes() [4/5]

vlink::Bytes::Bytes ( const std::initializer_list< uint8_t > & list)
noexcept

Constructs an owned Bytes from an initialiser list of byte values.

Equivalent to create(list.size()) followed by a memcpy of the list elements.

参数
listInitialiser list of uint8_t values.
函数调用图:

◆ Bytes() [5/5]

vlink::Bytes::Bytes ( const std::vector< uint8_t > & data)
explicitnoexcept

Constructs an owned Bytes by deep-copying a std::vector<uint8_t>.

参数
dataVector whose contents are copied into the new buffer.
函数调用图:

◆ ~Bytes()

vlink::Bytes::~Bytes ( )
noexcept

Destructor. Frees owned memory if is_owner() is true and is_loaned() is false.

函数调用图:

成员函数说明

◆ begin() [1/2]

const uint8_t * vlink::Bytes::begin ( ) const
inlinenodiscardnoexcept

Iterator begin (const) – same as data() const.

返回
Const pointer to the first usable byte.

◆ begin() [2/2]

uint8_t * vlink::Bytes::begin ( )
inlinenodiscardnoexcept

Iterator begin (mutable) – same as data().

返回
Pointer to the first usable byte.
这是这个函数的调用关系图:

◆ bytes_free()

void vlink::Bytes::bytes_free ( uint8_t * ptr,
size_t size )
staticnoexcept

Frees a buffer previously allocated by bytes_malloc().

参数
ptrPointer returned by bytes_malloc().
sizeOriginal size passed to bytes_malloc().
函数调用图:
这是这个函数的调用关系图:

◆ bytes_malloc()

uint8_t * vlink::Bytes::bytes_malloc ( size_t size)
staticnodiscardnoexcept

Allocates a raw byte buffer from the memory pool (or heap if pool is unavailable).

参数
sizeNumber of bytes to allocate.
返回
Pointer to the allocated memory, or nullptr on failure.
注解
The returned pointer must be freed with bytes_free() using the same size.
函数调用图:
这是这个函数的调用关系图:

◆ capacity()

size_t vlink::Bytes::capacity ( ) const
inlinenodiscardnoexcept

Returns the allocated capacity of the backing buffer.

capacity() >= real_size() always holds. For SBO buffers, capacity() == kStackSize.

返回
Capacity in bytes.
这是这个函数的调用关系图:

◆ clear()

void vlink::Bytes::clear ( )
noexcept

Releases the buffer and resets the object to the empty state.

If is_owner() is true, the backing memory is returned to the pool or heap. After this call, empty() returns true.

函数调用图:
这是这个函数的调用关系图:

◆ compress_data()

Bytes vlink::Bytes::compress_data ( const uint8_t * data,
size_t size,
bool high_ratio = false )
staticnodiscardnoexcept

Compresses a raw byte buffer using the LZAV algorithm.

Wraps the compressed payload with a 4-byte header magic and a 4-byte footer magic so that is_compress_data() can recognise it. Buffers larger than kMaxCompressCacheSize (1 MiB) are rejected and an empty Bytes is returned.

参数
dataPointer to the uncompressed data.
sizeNumber of bytes to compress.
high_ratioIf true, uses LZAV high-compression mode (slower but better ratio). Default: false (normal mode).
返回
Compressed Bytes with header/footer magic, or empty on failure.
函数调用图:
这是这个函数的调用关系图:

◆ convert_to_hex_str()

std::string vlink::Bytes::convert_to_hex_str ( const uint8_t * value,
size_t size )
staticnodiscardnoexcept

Converts a raw byte array to an uppercase hex string with spaces.

Each byte is rendered as two uppercase hex digits followed by a space, e.g., {0x1A, 0xB2} -> "1A B2 ". Useful for logging binary frames.

参数
valuePointer to the byte array.
sizeNumber of bytes to convert.
返回
Hex string representation.
函数调用图:
这是这个函数的调用关系图:

◆ create()

Bytes vlink::Bytes::create ( size_t size,
uint8_t offset = 0 )
staticnodiscardnoexcept

Creates an owned Bytes buffer of the given size.

Memory is allocated from the pool or heap. If size <= kStackSize (96) the inline stack buffer is used instead (no heap allocation). The contents are not initialised.

参数
sizeNumber of usable bytes (i.e. size() after construction).
offsetNumber of bytes to reserve at the start of the backing buffer as a prefix region (e.g., for protocol headers). data() = real_data() + offset. Default: 0.
返回
A new owned Bytes object.
函数调用图:
这是这个函数的调用关系图:

◆ data() [1/2]

const uint8_t * vlink::Bytes::data ( ) const
inlinenodiscardnoexcept

Returns a const pointer to the start of the user data region.

返回
Read-only pointer to user data, or nullptr if not allocated.

◆ data() [2/2]

uint8_t * vlink::Bytes::data ( )
inlinenodiscardnoexcept

Returns a pointer to the start of the user data region (after the prefix offset).

Equivalent to real_data() + offset(). Returns nullptr if the buffer is empty.

返回
Mutable pointer to user data, or nullptr if not allocated.
这是这个函数的调用关系图:

◆ decode_from_base64()

Bytes vlink::Bytes::decode_from_base64 ( const std::string & target)
staticnodiscardnoexcept

Decodes a Base-64 ASCII string into a Bytes buffer.

参数
targetBase-64 encoded string.
返回
Decoded Bytes. Returns an empty object on invalid input.
函数调用图:
这是这个函数的调用关系图:

◆ deep_copy() [1/3]

Bytes & vlink::Bytes::deep_copy ( const Bytes & bytes)
noexcept

Replaces this object with a fully owned deep copy of bytes.

Releases the current buffer, allocates new memory, and copies all bytes from bytes. After this call is_owner() is true.

参数
bytesSource to copy.
返回
Reference to *this.
函数调用图:

◆ deep_copy() [2/3]

Bytes vlink::Bytes::deep_copy ( const uint8_t * data,
size_t size,
uint8_t offset = 0 )
staticnodiscardnoexcept

Creates an owned deep copy of an external read-only buffer.

Same as the mutable overload but accepts a const source pointer.

参数
dataPointer to the source read-only buffer.
sizeNumber of bytes to copy.
offsetPrefix-region size in the new buffer. Default: 0.
返回
A new owned Bytes containing a copy of the source data.
函数调用图:

◆ deep_copy() [3/3]

Bytes vlink::Bytes::deep_copy ( uint8_t * data,
size_t size,
uint8_t offset = 0 )
staticnodiscardnoexcept

Creates an owned deep copy of an external mutable buffer.

Allocates new memory, copies size bytes from data, and returns a fully owned Bytes object. Safe even after the original buffer is freed.

参数
dataPointer to the source buffer.
sizeNumber of bytes to copy.
offsetPrefix-region size in the new buffer. Default: 0.
返回
A new owned Bytes containing a copy of the source data.
函数调用图:
这是这个函数的调用关系图:

◆ deep_copy_self()

Bytes & vlink::Bytes::deep_copy_self ( )
noexcept

Converts this object from a non-owning alias to a fully owned deep copy of its own data.

If the object is already an owner, this is a no-op. Otherwise, new memory is allocated, the current data is copied, and is_owner_ is set to true.

返回
Reference to *this.
函数调用图:
这是这个函数的调用关系图:

◆ empty()

bool vlink::Bytes::empty ( ) const
inlinenodiscardnoexcept

Returns true if the buffer is empty (no data pointer and size == 0).

返回
true if data_ == nullptr and size_ == 0.
这是这个函数的调用关系图:

◆ encode_to_base64()

std::string vlink::Bytes::encode_to_base64 ( const Bytes & target)
staticnodiscardnoexcept

Encodes a Bytes buffer as a standard Base-64 ASCII string.

参数
targetBuffer to encode.
返回
Base-64 encoded string.
函数调用图:
这是这个函数的调用关系图:

◆ end() [1/2]

const uint8_t * vlink::Bytes::end ( ) const
inlinenodiscardnoexcept

Iterator end (const) – one past the last usable byte.

返回
Const pointer to one past the last byte.

◆ end() [2/2]

uint8_t * vlink::Bytes::end ( )
inlinenodiscardnoexcept

Iterator end (mutable) – one past the last usable byte.

返回
Pointer to one past the last byte.
这是这个函数的调用关系图:

◆ from_string()

Bytes vlink::Bytes::from_string ( const std::string & str,
uint8_t offset = 0 )
staticnodiscardnoexcept

Constructs a Bytes buffer from a std::string by deep-copying its contents.

参数
strSource string.
offsetPrefix-region reserved before the string data. Default: 0.
返回
A new owned Bytes containing the UTF-8 bytes of str.
函数调用图:
这是这个函数的调用关系图:

◆ from_user_input()

Bytes vlink::Bytes::from_user_input ( const std::string & str,
bool * ok = nullptr )
staticnodiscardnoexcept

Parses a user-provided hex or binary string literal into a Bytes buffer.

Accepts formats such as "0x1A2B3C" (hex) or raw binary strings. Sets ok to false if parsing fails.

参数
strInput string to parse.
okOptional pointer set to true on success, false on failure.
返回
The parsed Bytes, or an empty object on failure.
函数调用图:
这是这个函数的调用关系图:

◆ get_crc_32()

uint32_t vlink::Bytes::get_crc_32 ( const Bytes & target)
staticnodiscardnoexcept

Computes the CRC-32 checksum of a Bytes buffer.

参数
targetBuffer to checksum.
返回
32-bit CRC value.
函数调用图:
这是这个函数的调用关系图:

◆ init_memory_pool()

void vlink::Bytes::init_memory_pool ( )
staticnoexcept

Initialises the global thread-safe memory pool for Bytes allocations.

On Linux with __cpp_lib_memory_resource support this initialises a pmr::synchronized_pool_resource that reduces per-allocation overhead. Call this once at application start before any Bytes objects are created. Safe to call multiple times; subsequent calls are no-ops.

这是这个函数的调用关系图:

◆ is_big_endian()

bool vlink::Bytes::is_big_endian ( )
inlinestaticnodiscardconstexprnoexcept

Returns true if the platform uses big-endian byte order.

返回
true on big-endian platforms. Equivalent to !is_little_endian().
函数调用图:
这是这个函数的调用关系图:

◆ is_compress_data()

bool vlink::Bytes::is_compress_data ( const uint8_t * data,
size_t size )
staticnodiscardnoexcept

Checks whether a raw byte buffer contains LZAV-compressed VLink data.

Inspects the first 4 bytes for the header magic {0x17, 0x49, 0xB2, 0x6F} and the last 4 bytes for the footer magic {0xA7, 0x05, 0xED, 0x71}. Both must match for the function to return true.

参数
dataPointer to the buffer to inspect.
sizeLength of the buffer.
返回
true if header and footer magic are present.
函数调用图:
这是这个函数的调用关系图:

◆ is_little_endian()

bool vlink::Bytes::is_little_endian ( )
inlinestaticnodiscardconstexprnoexcept

Returns true if the platform uses little-endian byte order.

Determined at compile time from preprocessor macros (__BYTE_ORDER__, __LITTLE_ENDIAN__, Windows defaults).

返回
true on little-endian platforms (x86, arm-le, etc.).
这是这个函数的调用关系图:

◆ is_loaned()

bool vlink::Bytes::is_loaned ( ) const
inlinenodiscardnoexcept

Returns true if this object holds an iceoryx loaned chunk.

Loaned objects must not free the underlying memory; ownership belongs to RouDi.

返回
true for objects created via loan_internal().
这是这个函数的调用关系图:

◆ is_owner()

bool vlink::Bytes::is_owner ( ) const
inlinenodiscardnoexcept

Returns true if this object owns and is responsible for freeing its buffer.

返回
true for objects created via create() or deep_copy().
这是这个函数的调用关系图:

◆ is_ptr()

bool vlink::Bytes::is_ptr ( ) const
inlinenodiscardnoexcept

Returns true if the object holds only an opaque pointer (size == 0 and not owner).

An object created via shallow_copy_ptr() has size_ == 0, offset_ == 0 and is_owner_ == false. Use to_ptr<T>() to retrieve the wrapped pointer.

返回
true if this is a pointer-only wrapper.
这是这个函数的调用关系图:

◆ loan_internal() [1/2]

Bytes vlink::Bytes::loan_internal ( const uint8_t * data,
size_t size )
staticnodiscardnoexcept

Creates a loaned (non-owning) alias for an iceoryx zero-copy payload (read-only).

Same as the mutable overload but for const payloads.

参数
dataPointer to the read-only iceoryx chunk payload.
sizeSize of the payload in bytes.
返回
A loaned Bytes object.
函数调用图:

◆ loan_internal() [2/2]

Bytes vlink::Bytes::loan_internal ( uint8_t * data,
size_t size )
staticnodiscardnoexcept

Creates a loaned (non-owning) alias for an iceoryx zero-copy payload (mutable).

Marks the object with is_loaned() == true. VLink will not free the memory because it is owned by the iceoryx RouDi daemon. This factory is used internally by the shm:// transport backend.

参数
dataPointer to the iceoryx chunk payload.
sizeSize of the payload in bytes.
返回
A loaned Bytes object.
函数调用图:
这是这个函数的调用关系图:

◆ offset()

uint8_t vlink::Bytes::offset ( ) const
inlinenodiscardnoexcept

Returns the size of the prefix offset region in bytes.

data() == real_data() + offset().

返回
Offset in bytes.
这是这个函数的调用关系图:

◆ operator!=() [1/2]

bool vlink::Bytes::operator!= ( const Bytes & target) const
nodiscardnoexcept

Inequality comparison – compares byte content.

参数
targetBytes to compare with.
返回
true if the objects differ in size or content.
函数调用图:

◆ operator!=() [2/2]

bool vlink::Bytes::operator!= ( const std::vector< uint8_t > & data) const
nodiscardnoexcept

Inequality comparison with a std::vector<uint8_t>.

参数
dataVector to compare with.
返回
true if sizes or contents differ.
函数调用图:

◆ operator=() [1/3]

Bytes & vlink::Bytes::operator= ( Bytes && target)
noexcept

Move assignment operator.

Releases the current buffer, then transfers all state from target.

参数
targetSource Bytes to move from.
返回
Reference to *this.
函数调用图:

◆ operator=() [2/3]

Bytes & vlink::Bytes::operator= ( const Bytes & target)
noexcept

Copy assignment operator.

Releases the current buffer, then copies target (deep if owner, shallow otherwise).

参数
targetSource Bytes to copy-assign from.
返回
Reference to *this.
函数调用图:

◆ operator=() [3/3]

Bytes & vlink::Bytes::operator= ( const std::vector< uint8_t > & data)
noexcept

Assignment from a std::vector<uint8_t> (deep copy).

参数
dataVector whose contents are deep-copied into this buffer.
返回
Reference to *this.
函数调用图:

◆ operator==() [1/2]

bool vlink::Bytes::operator== ( const Bytes & target) const
nodiscardnoexcept

Equality comparison – compares byte content.

参数
targetBytes to compare with.
返回
true if both objects have identical size and content.
函数调用图:

◆ operator==() [2/2]

bool vlink::Bytes::operator== ( const std::vector< uint8_t > & data) const
nodiscardnoexcept

Equality comparison with a std::vector<uint8_t>.

参数
dataVector to compare with.
返回
true if sizes and contents match.
函数调用图:

◆ operator[]() [1/2]

const uint8_t & vlink::Bytes::operator[] ( size_t index) const
inlinenodiscardnoexcept

Read-only subscript operator.

参数
indexLogical index (0-based from the start of the user data region).
返回
Const reference to the byte at index.

◆ operator[]() [2/2]

uint8_t & vlink::Bytes::operator[] ( size_t index)
inlinenodiscardnoexcept

Mutable subscript operator.

Details

Accesses the byte at logical index index (i.e., real_data()[offset + index]). No bounds checking is performed.

参数
indexLogical index (0-based from the start of the user data region).
返回
Reference to the byte at index.

◆ real_begin() [1/2]

const uint8_t * vlink::Bytes::real_begin ( ) const
inlinenodiscardnoexcept

Iterator begin for the full backing buffer (const).

返回
Const pointer to the first byte of the raw buffer.

◆ real_begin() [2/2]

uint8_t * vlink::Bytes::real_begin ( )
inlinenodiscardnoexcept

Iterator begin for the full backing buffer (mutable) – same as real_data().

返回
Pointer to the first byte of the raw buffer (before the offset).
这是这个函数的调用关系图:

◆ real_data() [1/2]

const uint8_t * vlink::Bytes::real_data ( ) const
inlinenodiscardnoexcept

Returns a const pointer to the very beginning of the backing buffer.

返回
Read-only pointer to the raw buffer origin.

◆ real_data() [2/2]

uint8_t * vlink::Bytes::real_data ( )
inlinenodiscardnoexcept

Returns a pointer to the very beginning of the backing buffer (before the offset).

Use this to write protocol headers into the reserved prefix region. real_data() + offset() == data().

返回
Mutable pointer to the raw buffer origin.
这是这个函数的调用关系图:

◆ real_end() [1/2]

const uint8_t * vlink::Bytes::real_end ( ) const
inlinenodiscardnoexcept

Iterator end for the full backing buffer (const).

返回
Const pointer to one past the last byte of the raw buffer.

◆ real_end() [2/2]

uint8_t * vlink::Bytes::real_end ( )
inlinenodiscardnoexcept

Iterator end for the full backing buffer (mutable).

返回
Pointer to one past the last byte of the raw buffer.
这是这个函数的调用关系图:

◆ real_size()

size_t vlink::Bytes::real_size ( ) const
inlinenodiscardnoexcept

Returns the total backing-buffer size including the prefix offset region.

real_size() == size() + offset().

返回
Total size of the backing buffer in bytes.
这是这个函数的调用关系图:

◆ release_memory_pool()

void vlink::Bytes::release_memory_pool ( )
staticnoexcept

Releases the global memory pool and returns its memory to the OS.

After this call, bytes_malloc falls back to the system heap allocator. Call once at application shutdown after all Bytes objects that used the pool have been destroyed, to avoid a use-after-free.

函数调用图:
这是这个函数的调用关系图:

◆ reserve()

bool vlink::Bytes::reserve ( size_t new_capacity)
noexcept

Ensures the backing buffer can hold at least new_capacity bytes.

If the current capacity is already >= new_capacity this is a no-op. Otherwise a new buffer is allocated and the existing data is copied.

参数
new_capacityMinimum required capacity in bytes.
返回
true on success, false if allocation failed.
函数调用图:
这是这个函数的调用关系图:

◆ resize()

bool vlink::Bytes::resize ( size_t size)
nodiscardnoexcept

Resizes the logical data region to size bytes.

If size <= current capacity, only size_ is updated. If size > current capacity, reserve(size) is called first. Newly added bytes are not initialised.

参数
sizeNew desired size in bytes.
返回
true on success, false if reallocation failed.
函数调用图:
这是这个函数的调用关系图:

◆ reverse_order()

Bytes vlink::Bytes::reverse_order ( const Bytes & target)
staticnodiscardnoexcept

Returns a new Bytes object with the byte order of target reversed.

参数
targetSource buffer to reverse.
返回
A new owned Bytes with bytes in reversed order.
函数调用图:
这是这个函数的调用关系图:

◆ shallow_copy() [1/3]

Bytes & vlink::Bytes::shallow_copy ( const Bytes & bytes)
noexcept

Makes this object a non-owning alias of bytes (shallow copy in-place).

Releases the current buffer, then copies the pointer and metadata from bytes without copying the underlying data. After this call is_owner() is false.

参数
bytesSource to alias.
返回
Reference to *this.
函数调用图:

◆ shallow_copy() [2/3]

Bytes vlink::Bytes::shallow_copy ( const uint8_t * data,
size_t size )
staticnodiscardnoexcept

Creates a non-owning Bytes alias pointing to an external read-only buffer.

Same as the mutable overload except the data pointer is const. Calling the non-const data() accessor on the result returns nullptr.

参数
dataPointer to the external read-only buffer.
sizeLength of the buffer in bytes.
返回
A non-owning Bytes object wrapping data.
函数调用图:

◆ shallow_copy() [3/3]

Bytes vlink::Bytes::shallow_copy ( uint8_t * data,
size_t size )
staticnodiscardnoexcept

Creates a non-owning Bytes alias pointing to an external mutable buffer.

No memory is allocated or copied. The caller is responsible for ensuring the external buffer outlives the returned Bytes object. is_owner() returns false.

参数
dataPointer to the external buffer.
sizeLength of the buffer in bytes.
返回
A non-owning Bytes object wrapping data.
函数调用图:
这是这个函数的调用关系图:

◆ shallow_copy_ptr()

Bytes vlink::Bytes::shallow_copy_ptr ( void * data)
staticnodiscardnoexcept

Wraps an opaque pointer without associating a byte size.

Sets size == 0 and offset == 0 so that is_ptr() returns true. Useful for passing opaque C handles or iceoryx chunk pointers through the Bytes transport. The caller owns the pointed-to memory; VLink will not free it.

参数
dataOpaque pointer to wrap.
返回
A non-owning, zero-size Bytes object carrying the pointer.
函数调用图:
这是这个函数的调用关系图:

◆ shrink_to()

bool vlink::Bytes::shrink_to ( size_t size)
nodiscardnoexcept

Reduces the logical size of the buffer without reallocating.

Sets size_ to size if size <= current size(); the backing buffer is not freed or shrunk.

参数
sizeNew logical size in bytes. Must be <= current size().
返回
true on success, false if size exceeds the current size.
函数调用图:
这是这个函数的调用关系图:

◆ size()

size_t vlink::Bytes::size ( ) const
inlinenodiscardnoexcept

Returns the number of usable bytes (excluding the prefix offset region).

返回
Size in bytes. Returns 0 if empty.
这是这个函数的调用关系图:

◆ stack_size()

uint8_t vlink::Bytes::stack_size ( )
inlinestaticnodiscardconstexprnoexcept

Returns the size of the inline stack storage in bytes.

Buffers of this size or smaller use the embedded stack_data_ array and never incur a heap allocation.

返回
kStackSize (96).
这是这个函数的调用关系图:

◆ to_ptr()

template<typename T>
T * vlink::Bytes::to_ptr ( ) const
inlinenodiscardnoexcept

Reinterprets the backing buffer as a pointer to T.

Calls reinterpret_cast<T*>(real_data()). Use with care; alignment must be compatible with T.

模板参数
TTarget type. Defaults to void.
返回
Pointer to T, or nullptr if the buffer is empty.
这是这个函数的调用关系图:

◆ to_raw_data()

std::vector< uint8_t > vlink::Bytes::to_raw_data ( ) const
nodiscardnoexcept

Copies the usable byte region into a new std::vector<uint8_t>.

返回
A vector containing a copy of data()[0..size()-1].
函数调用图:
这是这个函数的调用关系图:

◆ to_string()

std::string vlink::Bytes::to_string ( ) const
nodiscardnoexcept

Returns the usable byte region as a std::string.

返回
A string constructed from data() and size().
函数调用图:
这是这个函数的调用关系图:

◆ to_string_view()

std::string_view vlink::Bytes::to_string_view ( ) const
nodiscardnoexcept

Returns a zero-copy std::string_view over the usable byte region.

The returned view is valid only as long as this Bytes object is alive and unmodified.

返回
string_view pointing into the buffer.
函数调用图:
这是这个函数的调用关系图:

◆ uncompress_data()

Bytes vlink::Bytes::uncompress_data ( const uint8_t * data,
size_t size,
bool check_valid = true )
staticnodiscardnoexcept

Decompresses a LZAV-compressed Bytes buffer.

Strips the 4-byte header and footer magic, then calls lzav_decompress(). If check_valid is true the magic bytes are validated first; an invalid magic returns an empty Bytes.

参数
dataPointer to the compressed buffer (including header/footer).
sizeTotal size of the compressed buffer.
check_validIf true, validate the header/footer magic before decompressing. Default: true.
返回
Decompressed Bytes, or empty on failure.
函数调用图:
这是这个函数的调用关系图:

◆ operator<<

VLINK_EXPORT friend std::ostream & operator<< ( std::ostream & ostream,
const Bytes & target )
friend

Stream insertion operator – prints bytes as space-separated hex pairs.

参数
ostreamOutput stream.
targetBytes to print.
返回
Reference to ostream.

该类的文档由以下文件生成: