ot::Utils::CmdLineParser::ParseAsHexStringSegment() function
Parses a segment of a hex string up to a given size. Allows a longer hex string to be parsed and read in smaller segments into a given buffer. If the entire hex string bytes can fit in the given @p aBuffer with its @p aSize, they are copied into @p aBuffer and function returns `kErrorNone`. Otherwise, @p aSize bytes are read and copied and function returns `kErrorPending` to indicate that there are more bytes to parse. The @p aString is also updated to skip over the parsed segment. Correctly handles hex strings with even or odd length. For example, "AABBCCDD" (with even length) is parsed as {0xaa, 0xbb, 0xcc, 0xdd} and "123" (with odd length) is parsed as {0x01, 0x23}.
Arguments
aString
A reference to string to parse. On successful parse, updated to skip parsed digits.
aSize
On entry indicates the segment size (number of bytes in @p aBuffer). On exit provides number of bytes parsed and copied into @p aBuffer.
aBuffer
A pointer to a buffer to output the parsed byte sequence.
Return value
kErrorNone The string was parsed successfully to the end of string. kErrorPending The string segment was parsed successfully, but there are additional bytes remaining to be parsed. kErrorInvalidArgs The string does not contain valid format hex digits.
![]()
error = ot::Utils::CmdLineParser::ParseAsHexStringSegment(aHexString, length, buf);
ot::Utils::CmdLineParser::ParseAsHexStringSegment() is called by 1 function and calls 1 function:
![]()
ot::Utils::CmdLineParser::ParseAsHexStringSegment()
ot::Utils::CmdLineParser::ParseAsHexStringSegment() reads 1 variable:
![]()
ot::Utils::CmdLineParser::ParseAsHexStringSegment()