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
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
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
Template Parameters
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
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
Defined at line 359 of file ../../third_party/openthread/src/core/common/data.hpp