class Arg

Defined at line 289 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

Represents a single argument from an argument list.

Public Methods

void Clear ()

Clears the argument.

Defined at line 295 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

uint16_t GetLength ()

Returns the length (number of characters) in the argument C string.

void CopyArgsToStringArray (Arg[] aArgs, char *[] aStrings)

Copies the argument string pointers from an `Arg` array to a C string array.

Parameters

aArgs [in] An `Arg` array.
aStrings [out] An `char *` array to populate with the argument string pointers. The array MUST contain at least same number of entries as in array.
uint8_t GetArgsLength (Arg[] aArgs)

Returns the length of argument array, i.e. number of consecutive non-empty arguments.

Parameters

aArgs [in] An `Arg` array.
bool IsEmpty ()

Indicates whether or not the argument is empty (i.e., reached the end of argument list).

Defined at line 303 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

const char * GetCString ()

Gets the argument as a C string.

Defined at line 317 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

char * GetCString ()

Gets the argument as C string.

Defined at line 324 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

template <typename Type>
otError ParseAs (Type & aValue)

Parses the argument as a specified value type.

Parameters

aValue [out] A reference to output the parsed value.

Template Parameters

Type The value type.
void SetCString (char * aString)

Sets the argument with a given C string.

Parameters

aString [in] A pointer to the new C string.

Defined at line 331 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

bool operator!= (const char * aString)

Overload the operator `!=` to evaluate whether the argument is unequal to a given C string.

Parameters

aString [in] The C string to compare with (MUST not be `nullptr`).

Defined at line 354 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

otError ParseAsUint8 (uint8_t & aUint8)

Parses the argument as a `uint8_t` value.

The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix).

Parameters

aUint8 [out] A reference to an `uint8_t` variable to output the parsed value.

Defined at line 366 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

otError ParseAsUint16 (uint16_t & aUint16)

Parses the argument as a `uint16_t` value.

The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix).

Parameters

aUint16 [out] A reference to an `uint16_t` variable to output the parsed value.

Defined at line 378 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

otError ParseAsUint32 (uint32_t & aUint32)

Parses the argument as a `uint32_t` value.

The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix).

Parameters

aUint32 [out] A reference to an `uint32_t` variable to output the parsed value.

Defined at line 390 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

otError ParseAsUint64 (uint64_t & aUint64)

Parses the argument as a `uint64_t` value.

The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix).

Parameters

aUint64 [out] A reference to an `uint64_t` variable to output the parsed value.

Defined at line 402 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

otError ParseAsInt8 (int8_t & aInt8)

Parses the argument as a `int8_t` value.

The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix). The string can start with

`+`/`-` sign.

Parameters

aInt8 [out] A reference to an `int8_t` variable to output the parsed value.

Defined at line 415 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

otError ParseAsInt16 (int16_t & aInt16)

Parses the argument as a `int16_t` value.

The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix). The string can start with

`+`/`-` sign.

Parameters

aInt16 [out] A reference to an `int16_t` variable to output the parsed value.

Defined at line 428 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

otError ParseAsInt32 (int32_t & aInt32)

Parses the argument as a `int32_t` value.

The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix). The string can start with

`+`/`-` sign.

Parameters

aInt32 [out] A reference to an `int32_t` variable to output the parsed value.

Defined at line 441 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

otError ParseAsBool (bool & aBool)

Parses the argument as a `bool` value.

Zero value is treated as `false`, non-zero value as `true`.

Parameters

aBool [out] A reference to a `bool` variable to output the parsed value.

Defined at line 453 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

otError ParseAsIp6Address (otIp6Address & aAddress)

Parses the argument as an IPv6 address.

Parameters

aAddress [out] A reference to an `otIp6Address` to output the parsed IPv6 address.

Defined at line 464 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

otError ParseAsIp4Address (otIp4Address & aAddress)

Parses the argument as an IPv4 address.

Parameters

aAddress [out] A reference to an `otIp4Address` to output the parsed IPv4 address.

Defined at line 477 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

otError ParseAsIp6Prefix (otIp6Prefix & aPrefix)

Parses the argument as an IPv6 prefix.

The string is parsed as `{IPv6Address}/{PrefixLength}`.

Parameters

aPrefix [out] A reference to an `otIp6Prefix` to output the parsed IPv6 prefix.

Defined at line 492 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

otError ParseAsHexString (uint8_t * aBuffer, uint16_t aSize)

Parses the argument as a hex string into a byte array of fixed expected size.

Returns `kErrorNone` only when the hex string contains exactly

bytes (after parsing). If

there are fewer or more bytes in hex string that

the parsed bytes (up to

are copied into the

`aBuffer` and `kErrorInvalidArgs` is returned.

Parameters

aBuffer [out] A pointer to a buffer to output the parsed byte sequence.
aSize [in] The expected size of byte sequence (number of bytes after parsing).

Defined at line 521 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

template <uint16_t kBufferSize>
otError ParseAsHexString (uint8_t (&)[kBufferSize] aBuffer)

Parses the argument as a hex string into a a given fixed size array.

Returns `kErrorNone` only when the hex string contains exactly

bytes (after parsing).

If there are fewer or more bytes in hex string that

the parsed bytes (up to

are

copied into the `aBuffer` and `kErrorInvalidArgs` is returned.

Parameters

aBuffer [out] A reference to a byte array to output the parsed byte sequence.

Template Parameters

kBufferSize The byte array size (number of bytes).

Defined at line 540 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

otError ParseAsHexString (uint16_t & aSize, uint8_t * aBuffer)

Parses the argument as a hex string into a byte array.

Verifies that the parsed hex string bytes fit in

with its given

Parameters

aSize [in,out] On entry indicates the number of bytes in (max size of On exit provides number of bytes parsed and copied into
aBuffer [out] A pointer to a buffer to output the parsed byte sequence.

Defined at line 557 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

template <>
otError ParseAs<unsigned char> (uint8_t & aValue)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Specializations of `Arg::ParseAs

<Type

>()` method.

Defined at line 618 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

template <>
otError ParseAs<unsigned short> (uint16_t & aValue)

Defined at line 620 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

template <>
otError ParseAs<unsigned int> (uint32_t & aValue)

Defined at line 622 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

template <>
otError ParseAs<unsigned long> (uint64_t & aValue)

Defined at line 624 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

template <>
otError ParseAs<bool> (bool & aValue)

Defined at line 626 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

template <>
otError ParseAs<signed char> (int8_t & aValue)

Defined at line 628 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

template <>
otError ParseAs<short> (int16_t & aValue)

Defined at line 630 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

template <>
otError ParseAs<int> (int32_t & aValue)

Defined at line 632 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

template <>
otError ParseAs<const char *> (const char *& aValue)

Defined at line 634 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

template <>
otError ParseAs<otIp6Address> (otIp6Address & aValue)

Defined at line 641 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

template <>
otError ParseAs<otIp6Prefix> (otIp6Prefix & aValue)

Defined at line 643 of file ../../third_party/openthread/src/core/utils/parse_cmdline.hpp

bool operator== (const char * aString)

Overload the operator `==` to evaluate whether the argument is equal to a given C string.

If the argument is empty (`IsEmpty()` is `true`) then comparing it using operator `==` with any C string will

return false.

Parameters

aString [in] The C string to compare with (MUST not be `nullptr`).