nl::Weave::Profiles::ReferencedTLVData

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

同样,我们需要能够表示大型的旧 TLV 数据 blob。

摘要

继承

继承自: nl::Weave::Profiles::RetainedPacketBuffer

构造函数和析构函数

ReferencedTLVData(void)
-------------- TLV 数据的定义 --------------

公共类型

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

公共属性

theData
uint8_t *
theLength
uint16_t
theMaxLength
uint16_t

公共函数

free(void)
void
释放 ReferencedTLVData 对象,也就是说,取消定义该对象。
init(System::PacketBuffer *aBuffer)
在给定 PacketBuffer 的情况下,初始化 ReferencedTLVData 对象。
init(MessageIterator & i)
根据 MessageIterator 初始化 ReferencedTLVData 对象。
init(uint16_t aLength, uint16_t aMaxLength, uint8_t *aByteString)
在给定字节字符串的情况下初始化 ReferencedTLVObject。
init(TLVWriteCallback aWriteCallback, void *anAppState)
在给定回调函数的情况下初始化 RefererencedTLVData 对象。
isEmpty(void)
bool
检查 ReferencedTLVData 对象中是否包含任何内容。
isFree(void)
bool
检查 ReferencedTLVData 对象是否为“可用”对象,即
operator==(const ReferencedTLVData &) const
bool
检查 ReferencedTLVData 对象是否与另一个对象相等。
pack(System::PacketBuffer *buff)
ReferencedTLVData 对象直接打包到 PacketBuffer 中。
pack(MessageIterator & i, uint32_t maxLen)
packedLength(void)
uint16_t
返回数据长度(假设对象已打包到缓冲区中)。

公共静态函数

parse(System::PacketBuffer *buff, ReferencedTLVData & aTarget)
从提供的 PacketBuffer 解析 ReferencedTLVData 对象。
parse(MessageIterator & i, ReferencedTLVData & aTarget)
从提供的 MessageIterator 解析 ReferencedTLVData 对象。

公共类型

TLVWriteCallback

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

公共属性

theData

uint8_t * theData

theLength

uint16_t theLength

theMaxLength

uint16_t theMaxLength

公共函数

ReferencedTLVData

 ReferencedTLVData(
  void
)

-------------- TLV 数据的定义 --------------

TLV 数据的 no-arg 构造函数。用于提供自由/未初始化的对象,该对象必须使用此处定义的某个 init() 方法才能发挥作用。

免费

void free(
  void
)

释放 ReferencedTLVData 对象,也就是说,取消定义该对象。

init

WEAVE_ERROR init(
  System::PacketBuffer *aBuffer
)

在给定 PacketBuffer 的情况下,初始化 ReferencedTLVData 对象。

如果缓冲区已满 TLV,请初始化 ReferencedTLVData 对象。这里假设缓冲区仅包含 TLV

具体说明
参数
[in] aBuffer
TLV 所在的消息缓冲区。
返回值
WEAVE_NO_ERROR
无条件

init

WEAVE_ERROR init(
  MessageIterator & i
)

根据 MessageIterator 初始化 ReferencedTLVData 对象。

根据 MessageIterator 初始化 ReferencedTLVData 对象。在本例中,TLV 是缓冲区的最后一部分,我们会传入指向它的消息迭代器。

具体说明
参数
[in] i
指向要提取的 TLV 的消息迭代器。
返回值
WEAVE_NO_ERROR
无条件

init

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

在给定字节字符串的情况下初始化 ReferencedTLVObject。

使用包含 TLV 的字节字符串初始化 ReferencedTLVData 对象。如果没有 PacketrBuffer,我们就使用此初始化程序,因为我们创建这类初始化程序是为了打包和发送。

具体说明
参数
[in] aLength
TLV 数据的长度
[in] aMaxLength
缓冲区的总长度
[in] aByteString
指向字符串数据的指针
返回值
WEAVE_NO_ERROR
无条件

init

WEAVE_ERROR init(
  TLVWriteCallback aWriteCallback,
  void *anAppState
)

在给定回调函数的情况下初始化 RefererencedTLVData 对象。

初始化 ReferencedTLVData 对象。此版本没有显式提供数据,而是提供了函数、写入回调、一个引用对象(当应该打包和发送引用的数据时,该对象将与 TLVWriter 对象一起传递给该函数)。该回调的签名为:

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

具体说明
参数
[in] aWriteCallback
在编写 TLV 时要调用的函数。
[in] anAppState
与写入器一起传递给回调的应用状态对象。
返回值
WEAVE_NO_ERROR
成功时。
WEAVE_ERROR_INVALID_ARGUMENT
如果未提供写入回调。

isEmpty

bool isEmpty(
  void
)

检查 ReferencedTLVData 对象中是否包含任何内容。

这种对象可能“拥有”某些内容的方式有两种。它可以具有 0 长度,或者没有写入回调。

具体说明
返回值
如果数据集的长度为 0 或者没有写入回调,则为 true,否则为 false。

isFree

bool isFree(
  void
)

检查 ReferencedTLVData 对象是否为“可用”对象,即

未定义。

具体说明
返回值
如果对象未定义,则返回 true,否则返回 false。

运算符==

bool operator==(
  const ReferencedTLVData &
) const 

检查 ReferencedTLVData 对象是否与另一个对象相等。

请注意,只有在两个对象中包含由缓冲区或字符串支持的实际数据时才有意义。

具体说明
参数
[in] Another
要检查的对象
返回值
true
对象相等。
false
对象的字符串不相等。

WEAVE_ERROR pack(
  System::PacketBuffer *buff
)

ReferencedTLVData 对象直接打包到 PacketBuffer 中。

具体说明
参数
[in] buff
要填充的缓冲区。
返回值
反映底层 pack 调用成功的 WEAVE_ERROR。

WEAVE_ERROR pack(
  MessageIterator & i,
  uint32_t maxLen
)

packedLength

uint16_t packedLength(
  void
)

返回数据长度(假设对象已打包到缓冲区中)。

具体说明
返回值
打包数据的整数长度。

公共静态函数

parse

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

从提供的 PacketBuffer 解析 ReferencedTLVData 对象。

从 inet 缓冲区中解析 ReferencedTLVData 对象(假设它仅包含 TLV)。

具体说明
参数
[in] buff
要读取的缓冲区。
[out] aTarget
ReferencedTLVData 对象,以使用结果“填充”。
返回值
反映底层解析调用成功的 WEAVE_ERROR。

parse

WEAVE_ERROR parse(
  MessageIterator & i,
  ReferencedTLVData & aTarget
)

从提供的 MessageIterator 解析 ReferencedTLVData 对象。

从假定指向消息的 TLV 部分的 MessageIterator 对象解析 ReferenceTLVData 对象。

请注意,此处并未执行实际的“解析”,因为 TLV 留在缓冲区中,根本未被操纵。此方法主要只是设置 ReferencedTLVData 结构以供稍后使用。

具体说明
参数
[in] i
针对正在解析的消息的迭代器。
[out] aTarget
放置解析结果的位置。
返回值
WEAVE_NO_ERROR
无条件