mal-packet-weaver
C++20 packet serialization/deserialization library.
Loading...
Searching...
No Matches
mal_toolkit::ByteView Struct Reference

A lightweight view over a sequence of bytes. More...

#include "byte-helper.hpp"

Inheritance diagram for mal_toolkit::ByteView:
[legend]
Collaboration diagram for mal_toolkit::ByteView:
[legend]

Public Member Functions

template<typename T >
const T * as () const
 Convert the ByteView to a typed view.
 
constexpr ByteView subview (size_t from=0) const
 Create a subview of the ByteView.
 
constexpr ByteView subview (size_t from, size_t length) const
 Create a subview of the ByteView with a specified length.
 

Public Attributes

elements
 STL member.
 

Detailed Description

A lightweight view over a sequence of bytes.

ByteView provides a span-like view over a sequence of bytes and it can be used for efficient and safe manipulation of byte data.

Definition at line 28 of file byte-helper.hpp.

Member Function Documentation

◆ as()

template<typename T >
const T * mal_toolkit::ByteView::as ( ) const
inlinenodiscard

Convert the ByteView to a typed view.

This function interprets the underlying byte data as a sequence of the specified type and returns a pointer to the first element.

Template Parameters
TThe type to interpret the byte data as.
Returns
A pointer to the first element of the interpreted type.

Definition at line 44 of file byte-helper.hpp.

Here is the caller graph for this function:

◆ subview() [1/2]

ByteView mal_toolkit::ByteView::subview ( size_t from,
size_t length ) const
inlinenodiscardconstexpr

Create a subview of the ByteView with a specified length.

This function creates a new ByteView that represents a subsequence of the original ByteView starting from the specified index and having the specified length.

Parameters
fromThe starting index of the subview.
lengthThe length of the subview.
Returns
A new ByteView representing the subview.

Definition at line 74 of file byte-helper.hpp.

◆ subview() [2/2]

ByteView mal_toolkit::ByteView::subview ( size_t from = 0) const
inlinenodiscardconstexpr

Create a subview of the ByteView.

This function creates a new ByteView that represents a subsequence of the original ByteView starting from the specified index.

Parameters
fromThe starting index of the subview.
Returns
A new ByteView representing the subview.

Definition at line 58 of file byte-helper.hpp.

Member Data Documentation

◆ elements

T std::span< T >::elements
inherited

STL member.


The documentation for this struct was generated from the following file: