Google is committed to advancing racial equity for Black communities. See how.

nl::Weave::Profiles::MessageIterator

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

In order to use message buffers sensibly, we define this iterator, which can be used to keep track of boundaries and so on.

Summary

Inheritance

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

Constructors and Destructors

MessageIterator(System::PacketBuffer *)
The constructor method.

Public attributes

thePoint
uint8_t *

Public functions

append(void)
void
Set the point to after any data currently in the buffer.
finishWriting(void)
void
Adjust the buffer after writing.
hasData(uint16_t)
bool
hasRoom(uint16_t)
bool
operator!=(const MessageIterator &)
bool
operator*(void)
uint8_t &
operator+(uint16_t)
operator++(void)
Increment a message iterator by 1 if there's room.
operator-(uint16_t)
operator==(const MessageIterator &)
bool
read16(uint16_t *)
read32(uint32_t *)
read64(uint64_t *)
readByte(uint8_t *)
readBytes(uint16_t, uint8_t *)
readString(uint16_t, char *)
write16(uint16_t)
write32(uint32_t)
write64(uint64_t)
writeByte(uint8_t)
writeBytes(uint16_t, uint8_t *)
writeString(uint16_t, char *)

Public attributes

thePoint

uint8_t * thePoint

Public functions

MessageIterator

 MessageIterator(
  System::PacketBuffer *
)

The constructor method.

Details
Parameters
aBuffer
A message buffer to iterate over.

append

void append(
  void
)

Set the point to after any data currently in the buffer.

finishWriting

void finishWriting(
  void
)

Adjust the buffer after writing.

hasData

bool hasData(
  uint16_t
)

Details
Parameters
inc
An integer amount that may be read from the buffer.
Return Values
true
The buffer's current data length is greater than or equal to the given increment.
false
Otherwise.

hasRoom

bool hasRoom(
  uint16_t
)

Details
Parameters
inc
An integer amount that may be written to the buffer.
Return Values
true
The difference between the buffer's current data length and its maximum allowable data length, (its available data length), is less than or equal to the given increment.
false
Otherwise.

operator!=

bool operator!=(
  const MessageIterator &
)

Details
Parameters
aMessageIterator
Another message iterator to compare with.

operator*

uint8_t & operator*(
  void
)

Details
Returns
What we're looking at in the buffer.

operator+

MessageIterator & operator+(
  uint16_t
)

Details
Parameters
inc
An increment to apply to the message iterator.
Returns
The iterator incremented by the given value if there's room, or else slammed right up against the end if there's not.

operator++

MessageIterator & operator++(
  void
)

Increment a message iterator by 1 if there's room.

operator-

MessageIterator & operator-(
  uint16_t
)

Details
Parameters
dec
A decrement to apply to the message iterator.
Returns
The iterator decremented by the given value if there's room, or else slammed right up against the beginning if there's not.

operator==

bool operator==(
  const MessageIterator &
)

Details
Parameters
aMessageIterator
Another message iterator to compare with.

read16

WEAVE_ERROR read16(
  uint16_t *
)

Details
Parameters
aDestination
A place to put a short read off the buffer.
Return Values
WEAVE_NO_ERROR
If it's all OK.
WEAVE_ERROR_BUFFER_TOO_SMALL
If we're running past the end of the buffer.

read32

WEAVE_ERROR read32(
  uint32_t *
)

Details
Parameters
aDestination
A place to put a 32-bit value read off the buffer.
Return Values
WEAVE_NO_ERROR
If it's all OK.
WEAVE_ERROR_BUFFER_TOO_SMALL
If we're running past the end of the buffer.

read64

WEAVE_ERROR read64(
  uint64_t *
)

Details
Parameters
aDestination
A place to put a 64-bit value read off the buffer.
Return Values
WEAVE_NO_ERROR
If it's all OK.
WEAVE_ERROR_BUFFER_TOO_SMALL
If we're running past the end of the buffer.

readByte

WEAVE_ERROR readByte(
  uint8_t *
)

Details
Parameters
aDestination
A place to put a byte read off the buffer.
Return Values
WEAVE_NO_ERROR
If it's all OK.
WEAVE_ERROR_BUFFER_TOO_SMALL
If we're running past the end of the buffer.

readBytes

WEAVE_ERROR readBytes(
  uint16_t,
  uint8_t *
)

Details
Parameters
aLength
The length of the byte string to be read.
aByteString
A place to put the bytes.
Return Values
WEAVE_NO_ERROR
If it's all OK.
WEAVE_ERROR_BUFFER_TOO_SMALL
If we're running past the end of the buffer.

readString

WEAVE_ERROR readString(
  uint16_t,
  char *
)

Details
Parameters
aLength
The length of the string to be read.
aString
A place to put the string.
Return Values
WEAVE_NO_ERROR
If it's all OK.
WEAVE_ERROR_BUFFER_TOO_SMALL
If we're running past the end of the buffer.

write16

WEAVE_ERROR write16(
  uint16_t
)

Details
Parameters
aValue
A short value to write out.
Return Values
WEAVE_NO_ERROR
If it's all OK.
WEAVE_ERROR_BUFFER_TOO_SMALL
If we're running past the end of the buffer.

write32

WEAVE_ERROR write32(
  uint32_t
)

Details
Parameters
aValue
A 32-bit value to write out.
Return Values
WEAVE_NO_ERROR
If it's all OK.
WEAVE_ERROR_BUFFER_TOO_SMALL
If we're running past the end of the buffer.

write64

WEAVE_ERROR write64(
  uint64_t
)

Details
Parameters
aValue
A 64-bit value to write out.
Return Values
WEAVE_NO_ERROR
If it's all OK.
WEAVE_ERROR_BUFFER_TOO_SMALL
If we're running past the end of the buffer.

writeByte

WEAVE_ERROR writeByte(
  uint8_t
)

Details
Parameters
aValue
A byte value to write out.
Return Values
WEAVE_NO_ERROR
If it's all OK.
WEAVE_ERROR_BUFFER_TOO_SMALL
If we're running past the end of the buffer.

writeBytes

WEAVE_ERROR writeBytes(
  uint16_t,
  uint8_t *
)

Details
Parameters
aLength
The length of the byte string to write.
aString
The byte string itself.
Return Values
WEAVE_NO_ERROR
If it's all OK.
WEAVE_ERROR_BUFFER_TOO_SMALL
If we're running past the end of the buffer.

writeString

WEAVE_ERROR writeString(
  uint16_t,
  char *
)

Details
Parameters
aLength
The length of the string to write.
aString
The string itself.
Return Values
WEAVE_NO_ERROR
If it's all OK.
WEAVE_ERROR_BUFFER_TOO_SMALL
If we're running past the end of the buffer.