class TLVWriter

Defined at line 218 of file x64-shared/gen/third_party/openweave-core/src/include/Weave/Core/WeaveTLV.h

Provides a memory efficient encoder for writing data in Weave TLV format.

TLVWriter implements a forward-only, stream-style encoder for Weave TLV data. Applications

write data to an encoding by calling one of the writer's Put() methods, passing associated

tag and value information as necessary. Similarly applications can encode TLV container types

(structures, arrays or paths) by calling the writer's OpenContainer() or EnterContainer()

methods.

A TLVWriter object can write data directly to a fixed output buffer, or to a chain of one or

more PacketBuffer objects. Additionally, applications can supply their own

and

functions to direct output to an arbitrary destination, e.g. a socket or an

event queue.

Public Members

uint32_t ImplicitProfileId
void * AppData
GetNewBufferFunct GetNewBuffer
FinalizeBufferFunct FinalizeBuffer

Protected Members

uintptr_t mBufHandle
uint8_t * mBufStart
uint8_t * mWritePoint
uint32_t mRemainingLen
uint32_t mLenWritten
uint32_t mMaxLen
TLVType mContainerType

Public Methods

void Init (uint8_t * buf, uint32_t maxLen)

*** See WeaveTLVWriter.cpp file for API documentation ***

void InitMalloced (uint8_t *& outBuf, uint32_t initialBufSize, uint32_t maxLen)
void Init (PacketBuffer * buf, uint32_t maxLen)
void Init (PacketBuffer * buf, uint32_t maxLen, bool allowDiscontiguousBuffers)
WEAVE_ERROR Finalize ()
WEAVE_ERROR ContinuePutBytes (const uint8_t * buf, uint32_t len)
WEAVE_ERROR Put (uint64_t tag, int8_t v)
WEAVE_ERROR Put (uint64_t tag, int8_t v, bool preserveSize)
WEAVE_ERROR Put (uint64_t tag, int16_t v)
WEAVE_ERROR Put (uint64_t tag, int16_t v, bool preserveSize)
WEAVE_ERROR Put (uint64_t tag, int32_t v)
WEAVE_ERROR Put (uint64_t tag, int32_t v, bool preserveSize)
WEAVE_ERROR Put (uint64_t tag, int64_t v)
WEAVE_ERROR Put (uint64_t tag, int64_t v, bool preserveSize)
WEAVE_ERROR Put (uint64_t tag, uint8_t v)
WEAVE_ERROR Put (uint64_t tag, uint8_t v, bool preserveSize)
WEAVE_ERROR Put (uint64_t tag, uint16_t v)
WEAVE_ERROR Put (uint64_t tag, uint16_t v, bool preserveSize)
WEAVE_ERROR Put (uint64_t tag, uint32_t v)
WEAVE_ERROR Put (uint64_t tag, uint32_t v, bool preserveSize)
WEAVE_ERROR Put (uint64_t tag, uint64_t v)
WEAVE_ERROR Put (uint64_t tag, uint64_t v, bool preserveSize)
WEAVE_ERROR Put (uint64_t tag, float v)
WEAVE_ERROR Put (uint64_t tag, double v)
WEAVE_ERROR PutBoolean (uint64_t tag, bool v)
WEAVE_ERROR PutBytes (uint64_t tag, const uint8_t * buf, uint32_t len)
WEAVE_ERROR StartPutBytes (uint64_t tag, uint32_t totalLen)
WEAVE_ERROR PutString (uint64_t tag, const char * buf)
WEAVE_ERROR PutString (uint64_t tag, const char * buf, uint32_t len)
WEAVE_ERROR PutStringF (uint64_t tag, const char * fmt)
WEAVE_ERROR VPutStringF (uint64_t tag, const char * fmt, va_list ap)
WEAVE_ERROR PutNull (uint64_t tag)
WEAVE_ERROR CopyElement (TLVReader & reader)
WEAVE_ERROR CopyElement (uint64_t tag, TLVReader & reader)
WEAVE_ERROR StartContainer (uint64_t tag, TLVType containerType, TLVType & outerContainerType)
WEAVE_ERROR EndContainer (TLVType outerContainerType)
WEAVE_ERROR OpenContainer (uint64_t tag, TLVType containerType, TLVWriter & containerWriter)
WEAVE_ERROR CloseContainer (TLVWriter & containerWriter)
WEAVE_ERROR PutPreEncodedContainer (uint64_t tag, TLVType containerType, const uint8_t * data, uint32_t dataLen)
WEAVE_ERROR CopyContainer (TLVReader & container)
WEAVE_ERROR CopyContainer (uint64_t tag, TLVReader & container)
WEAVE_ERROR CopyContainer (uint64_t tag, const uint8_t * encodedContainer, uint16_t encodedContainerLen)
TLVType GetContainerType ()
uint32_t GetLengthWritten ()
WEAVE_ERROR GetNewPacketBuffer (TLVWriter & writer, uintptr_t & bufHandle, uint8_t *& bufStart, uint32_t & bufLen)

Implementations of GetNewBufferFunct/FinalizeBufferFunct that support writing into one or more

PacketBuffers.

WEAVE_ERROR FinalizePacketBuffer (TLVWriter & writer, uintptr_t bufHandle, uint8_t * bufStart, uint32_t dataLen)
WEAVE_ERROR GetNewBuffer_Malloced (TLVWriter & writer, uintptr_t & bufHandle, uint8_t *& bufStart, uint32_t & bufLen)

Implementations of the GetNewBufferFunct that support writing into a dynamic buffer

Protected Methods

bool IsContainerOpen ()

Defined at line 311 of file x64-shared/gen/third_party/openweave-core/src/include/Weave/Core/WeaveTLV.h

bool IsCloseContainerReserved ()

Determine whether the container should reserve space for the

CloseContainer symbol at the point of starting / opening the

container.

Defined at line 324 of file x64-shared/gen/third_party/openweave-core/src/include/Weave/Core/WeaveTLV.h

void SetContainerOpen (bool aContainerOpen)

Defined at line 312 of file x64-shared/gen/third_party/openweave-core/src/include/Weave/Core/WeaveTLV.h

void SetCloseContainerReserved (bool aCloseContainerReserved)

Set whether the container should reserve the space for the

CloseContainer symbol at the point of starting / opening the

container.

Defined at line 332 of file x64-shared/gen/third_party/openweave-core/src/include/Weave/Core/WeaveTLV.h

WEAVE_ERROR WriteElementHead (TLVElementType elemType, uint64_t tag, uint64_t lenOrVal)
WEAVE_ERROR WriteElementWithData (TLVType type, uint64_t tag, const uint8_t * data, uint32_t dataLen)
WEAVE_ERROR WriteData (const uint8_t * p, uint32_t len)

Enumerations

enum 
Name Value
kEndOfContainerMarkerSize 1

Defined at line 314 of file x64-shared/gen/third_party/openweave-core/src/include/Weave/Core/WeaveTLV.h

Friends

class TLVUpdater