pack_bytes()
Generates a sequence of bytes by arranging element data.
Generates a sequence of bytes by arranging element data.
uint8_t* pack_bytes(uint8_t* b, uint8_t* e, ...)pack_bytes takes a begin(),end() iterator of the container class as a parameter and writes the data specified by the following parameters to the container as a sequence of bytes.
The data given for the variable argument parameters are as follows
uint8_t
1
uint16_t
2
Stored in big-endian order
uint32_t
4
Stored in big-endian order
uint8_t[N]
N
Fixed-length array of type uint8_t.
std::pair<char*,N>
N
A pair of an array of type char*,uint8_t* and array length. Can be generated with make_pair().
smplbuf_u8& pack_bytes(smplbuf_u8& c, ...)The pack_bytes takes a container object as a parameter and writes the data specified by the subsequent parameters as a sequence of bytes into the container. It is appended to the end by the container's .push_back() method.
The data given as variable argument parameters is shown below.
uint8_t
1
uint16_t
2
Stored in big-endian order
uint32_t
4
Stored in big-endian order
uint8_t[N]
N
Fixed-length array of type uint8_t.
std::pair<char*,N>
N
A pair of an array of type char*,uint8_t* and array length. Can be generated with make_pair().
smplbuf_u8?
.size()
smplbuf<>container of typeuint8_t. Container length (.size()`) of data.
Example
In this example, each attribute and payload of the received packet is re-stored in a separate buffer buf.
Background
To simplify the description of byte arrays of type uint8_t used in the generation of data payloads and extraction of data in non-volatile packets.
The above is the simplest description, but byte arrays can be generated using Byte array utils as follows.
最終更新