nl::Weave::Profiles::ReferencedTLVData

#include <src/lib/profiles/common/WeaveMessage.h>

Similarly, we need to be able to represent a big old blob of TLV data.

Summary

Inheritance

Inherits from: nl::Weave::Profiles::RetainedPacketBuffer

Constructors and Destructors

ReferencedTLVData(void)
-------------- definitions for TLV data --------------

Public types

TLVWriteCallback)(TLV::TLVWriter &aWriter, void *aAppState) typedef
void(*

Public attributes

theData
uint8_t *
theLength
uint16_t
theMaxLength
uint16_t

Public functions

free(void)
void
Free a ReferencedTLVData object, which is to say, undefine it.
init(System::PacketBuffer *aBuffer)
Initialize the ReferencedTLVData object given a PacketBuffer.
init(MessageIterator & i)
Initialize a ReferencedTLVData object given a MessageIterator.
init(uint16_t aLength, uint16_t aMaxLength, uint8_t *aByteString)
Initialize a ReferencedTLVObject given a byte string.
init(TLVWriteCallback aWriteCallback, void *anAppState)
Initialize a RefererencedTLVData object given a callback function.
isEmpty(void)
bool
Check if a ReferencedTLVData object has anything in it.
isFree(void)
bool
Check if a ReferencedTLVData object is "free", i.e.
operator==(const ReferencedTLVData &) const
bool
Check a ReferencedTLVData object against another for equality.
pack(System::PacketBuffer *buff)
Pack a ReferencedTLVData object directly into a PacketBuffer.
pack(MessageIterator & i, uint32_t maxLen)
packedLength(void)
uint16_t
Return the data length assuming that the object has been packed into a buffer.

Public static functions

parse(System::PacketBuffer *buff, ReferencedTLVData & aTarget)
Parse a ReferencedTLVData object from a supplied PacketBuffer.
parse(MessageIterator & i, ReferencedTLVData & aTarget)
Parse a ReferencedTLVData object from a supplied MessageIterator.

Public types

TLVWriteCallback

void(* TLVWriteCallback)(TLV::TLVWriter &aWriter, void *aAppState)

Public attributes

theData

uint8_t * theData

theLength

uint16_t theLength

theMaxLength

uint16_t theMaxLength

Public functions

ReferencedTLVData

 ReferencedTLVData(
  void
)

-------------- definitions for TLV data --------------

The no-arg constructor for TLV data. Delivers a free/uninitialized object which must be subjected to one of the init() methods defined here in order to be useful.

free

void free(
  void
)

Free a ReferencedTLVData object, which is to say, undefine it.

init

WEAVE_ERROR init(
  System::PacketBuffer *aBuffer
)

Initialize the ReferencedTLVData object given a PacketBuffer.

Initialize a ReferencedTLVData object given a buffer full of TLV. This assumes that the buffer ONLY contains TLV.

Details
Parameters
[in] aBuffer
A message buffer in which the TLV resides.
Return Values
WEAVE_NO_ERROR
Unconditionally

init

WEAVE_ERROR init(
  MessageIterator & i
)

Initialize a ReferencedTLVData object given a MessageIterator.

Initialize a ReferencedTLVData object given a MessageIterator. In this case, the TLV is that last portion of the buffer and we pass in a message iterator that's pointing to it.

Details
Parameters
[in] i
A message iterator pointing to TLV to be extracted.
Return Values
WEAVE_NO_ERROR
Unconditionally

init

WEAVE_ERROR init(
  uint16_t aLength,
  uint16_t aMaxLength,
  uint8_t *aByteString
)

Initialize a ReferencedTLVObject given a byte string.

Initialize ReferencedTLVData object with a byte string containing TLV. This initializer is the one we use if there's no PacketrBuffer because we're creating one of these to pack and send.

Details
Parameters
[in] aLength
A length for the TLV data
[in] aMaxLength
The total length of the buffer
[in] aByteString
A pointer to the string data
Return Values
WEAVE_NO_ERROR
Unconditionally

init

WEAVE_ERROR init(
  TLVWriteCallback aWriteCallback,
  void *anAppState
)

Initialize a RefererencedTLVData object given a callback function.

Initialize a ReferencedTLVData object. Instead of explicitly supplying the data, this version provides function, the write callback, and a reference object, which will be passed to it, along with a TLVWriter object, when the referenced data is supposed to be packed and sent. The signature of that callback is:

typedef void (*TLVWriteCallback)(TLV::TLVWriter &aWriter, void *aAppState);

Details
Parameters
[in] aWriteCallback
the function to be called when it's time to write some TLV.
[in] anAppState
an application state object to be passed to the callback along with the writer.
Return Values
WEAVE_NO_ERROR
On success.
WEAVE_ERROR_INVALID_ARGUMENT
If the write callback is not supplied.

isEmpty

bool isEmpty(
  void
)

Check if a ReferencedTLVData object has anything in it.

There are two possible ways such an object could "have" something. Either it could have 0 length OR it could have no write callback.

Details
Returns
true if the data set has 0 length or there's no write callback in hand, false otherwise.

isFree

bool isFree(
  void
)

Check if a ReferencedTLVData object is "free", i.e.

undefined.

Details
Returns
true if the object is undefined, false otherwise.

operator==

bool operator==(
  const ReferencedTLVData &
) const 

Check a ReferencedTLVData object against another for equality.

Note that this only really makes sense in the case of two objects that have actual data in them backed by a buffer or string.

Details
Parameters
[in] Another
an object to check against
Return Values
true
The objects are equal.
false
The objects strings are not equal.

pack

WEAVE_ERROR pack(
  System::PacketBuffer *buff
)

Pack a ReferencedTLVData object directly into a PacketBuffer.

Details
Parameters
[in] buff
the buffer to fill.
Returns
a WEAVE_ERROR reflecting the success of the underlying pack call.

pack

WEAVE_ERROR pack(
  MessageIterator & i,
  uint32_t maxLen
)

packedLength

uint16_t packedLength(
  void
)

Return the data length assuming that the object has been packed into a buffer.

Details
Returns
the integer length of the packed data.

Public static functions

parse

WEAVE_ERROR parse(
  System::PacketBuffer *buff,
  ReferencedTLVData & aTarget
)

Parse a ReferencedTLVData object from a supplied PacketBuffer.

Parse a ReferencedTLVData object out of an inet buffer (assuming it just contains TLV).

Details
Parameters
[in] buff
the buffer to read from.
[out] aTarget
a ReferencedTLVData object to "fill" with the result.
Returns
a WEAVE_ERROR reflecting the success of the underlying parse call.

parse

WEAVE_ERROR parse(
  MessageIterator & i,
  ReferencedTLVData & aTarget
)

Parse a ReferencedTLVData object from a supplied MessageIterator.

Parse a ReferenceTLVData object from a MessageIterator object assumed to be pointing at the TLV portion of a message.

Note that no actual "parsing" is done here since the TLV is left in the buffer and not manipulated at all. This method mainly just sets up the ReferencedTLVData structure for later use.

Details
Parameters
[in] i
An iterator over the message being parsed.
[out] aTarget
A place to put the result of parsing.
Return Values
WEAVE_NO_ERROR
Unconditionally