expand_bytes()
Decompose a sequence of bytes and store it in a variable.
Decompose a sequence of bytes and store it in a variable.
The expand_bytes()
parameter is a combination of iterators of type uint8_t*
. This specifies the next iterator after the beginning and end of the parsed target. If the parsing proceeds to the e
position, nullptr
is returned.
If there is no error in expansion, the next iterator to be read is returned.
The variable number parameters can be the following
Byte count | Data length | Explanation |
---|---|---|
| 1 | |
| 2 | Expand as a big-endian sequence |
| 4 | Expand as a big-endian sequence |
| N | Fixed-length array of type |
| N | Pairs of an array of type |
Example
In this example, a 4-byte string is read out first. Here, make_pair()
is used to explicitly read 4 bytes of data.
The next data is read out based on the returned iterator np
. The next data is of type uint8_t
, followed by five more of type uint16_t
.
Background
To simplify the description of byte arrays of type uint8_t
used in generating data payloads and extracting data from non-volatile packets.
The above is the simplest description, but it can be read from a byte array using Byte array utils as follows
最終更新