template <DataLengthType kDataLengthType>

class MutableData

Defined at line 257 of file ../../third_party/openthread/src/core/common/data.hpp

Represents a generic `MutableData` which is simply a wrapper over a pointer to a buffer with a given data

length.

It inherits from `Data` but unlike `Data` which treats its buffer content as immutable, `MutableData` allows its

data buffer content to be changed.

A `MutableData` instance MUST be initialized (using any of the `Init()` methods) before calling any other methods

(e.g., `GetBytes()` or `GetLength()`), otherwise the behavior is undefined.

Public Methods

void Init (void * aBuffer, LengthType aLength)

Initializes the `MutableData` to point to a given buffer with a given length.

Parameters

aBuffer [in] A pointer to a buffer containing the data.
aLength [in] The data length (number of bytes in

Defined at line 275 of file ../../third_party/openthread/src/core/common/data.hpp

void InitFormRange (uint8_t * aStart, uint8_t * aEnd)

Initializes the `MutableData` to point to a range of bytes in a given buffer.

The range is specified by the pointers to its start

and its end

`Data` will point to the

bytes in the buffer from

up to but excluding

(i.e., `aStart

<

= bytes

<

aEnd`).

Parameters

aStart [in] Pointer to the start of the range.
aEnd [in] Pointer to the end of the range.

Defined at line 286 of file ../../third_party/openthread/src/core/common/data.hpp

template <typename ObjectType>
void InitFrom (ObjectType & aObject)

Initializes the `MutableData` to point to the content of an object.

Parameters

aObject [in] The object to initialize the `MutableData` with.

Template Parameters

ObjectType The object type (MUST not be a pointer type).

Defined at line 295 of file ../../third_party/openthread/src/core/common/data.hpp

uint8_t * GetBytes ()

Returns a pointer to the data bytes buffer.

Defined at line 306 of file ../../third_party/openthread/src/core/common/data.hpp

const uint8_t * GetBytes ()

Returns a pointer to the data bytes buffer.

Defined at line 313 of file ../../third_party/openthread/src/core/common/data.hpp

void ClearBytes ()

Clears all the bytes (sets them to zero) in the buffer pointed by the `MutableData`.

Defined at line 318 of file ../../third_party/openthread/src/core/common/data.hpp

Error CopyBytesFrom (const uint8_t * aBuffer, LengthType aLength)

Copies the bytes from a given buffer into the `MutableData` buffer.

If the current `MutableData` length is larger than or equal to

then all the bytes are copied

from

into the buffer of `MutableData` and the `MutableData`'s length is changed to

If the current `MutableData` length is smaller than

then the method returns `kErrorNoBufs` but still

copies as many bytes as can fit.

Parameters

aBuffer [in] A pointer to a buffer to copy from.
aLength [in] The length of (number of bytes).

Defined at line 335 of file ../../third_party/openthread/src/core/common/data.hpp

Error CopyBytesFrom (const Data<kDataLengthType> & aData)

Copies the bytes from an given `Data` instance into the `MutableData` buffer.

If the current `MutableData` length is larger than or equal to the

length, then all the bytes are copied

from

into the buffer of `MutableData` and the `MutableData`'s length is adjusted accordingly.

If the current `MutableData` length is smaller than

length, then as many bytes as can fit are copied

and the method returns `kErrorNoBufs`.

Parameters

aData [in] A `Data` instance to copy the content from.

Defined at line 359 of file ../../third_party/openthread/src/core/common/data.hpp