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

nl::Weave::Encoding

This namespace provides functions for:

Summary

  • Performing byte reordering by value for 16-, 32-, and 64-bit types.
  • Safely performing simple, efficient memory-mapped accesses, potentially to unaligned memory locations, with or without byte reordering, to 8-, 16-, 32-, and 64-bit quantities, both with and without pointer management.

Functions

Get8(const uint8_t *p)
uint8_t
Perform a, potentially unaligned, memory read of the 8-bit value from the specified pointer address.
Put8(uint8_t *p, uint8_t v)
void
Perform a, potentially unaligned, memory write of the target system byte ordered 8-bit value to the specified pointer address.
Read8(uint8_t *& p)
uint8_t
Perform a, potentially unaligned, memory read of the 16-bit value from the specified pointer address and increment the pointer by 8-bits (1 byte).
Read8(const uint8_t *& p)
uint8_t
Perform a, potentially unaligned, memory read of the 16-bit value from the specified pointer address and increment the pointer by 8-bits (1 byte).
Swap16(uint16_t v)
uint16_t
This unconditionally performs a byte order swap by value of the specified 16-bit value.
Swap32(uint32_t v)
uint32_t
This unconditionally performs a byte order swap by value of the specified 32-bit value.
Swap64(uint64_t v)
uint64_t
This unconditionally performs a byte order swap by value of the specified 64-bit value.
Write8(uint8_t *& p, uint8_t v)
void
Perform a, potentially unaligned, memory write of the 8-bit value to the specified pointer address and increment the pointer by 8-bits (1 byte).

Namespaces

nl::Weave::Encoding::BigEndian

This namespace provides functions for:

nl::Weave::Encoding::LittleEndian

This namespace provides functions for:

Functions

Get8

uint8_t Get8(
  const uint8_t *p
)

Perform a, potentially unaligned, memory read of the 8-bit value from the specified pointer address.

Details
Parameters
[in] p
A pointer address, potentially unaligned, to read the 8-bit value from.
Returns
The 8-bit value at the specified pointer address.

Put8

void Put8(
  uint8_t *p,
  uint8_t v
)

Perform a, potentially unaligned, memory write of the target system byte ordered 8-bit value to the specified pointer address.

Details
Parameters
[in] p
A pointer address, potentially unaligned, to write the 8-bit value to.
[in] v
The 8-bit value to write.

Read8

uint8_t Read8(
  uint8_t *& p
)

Perform a, potentially unaligned, memory read of the 16-bit value from the specified pointer address and increment the pointer by 8-bits (1 byte).

Details
Parameters
[in,out] p
A reference to a pointer address, potentially unaligned, to read the 8-bit value from and to then increment by 8-bits (1 byte).
Returns
The 8-bit value at the specified pointer address.

Read8

uint8_t Read8(
  const uint8_t *& p
)

Perform a, potentially unaligned, memory read of the 16-bit value from the specified pointer address and increment the pointer by 8-bits (1 byte).

Details
Parameters
[in,out] p
A reference to a constant pointer address, potentially unaligned, to read the 8-bit value from and to then increment by 8-bits (1 byte).
Returns
The 8-bit value at the specified pointer address.

Swap16

uint16_t Swap16(
  uint16_t v
)

This unconditionally performs a byte order swap by value of the specified 16-bit value.

Details
Parameters
[in] v
The 16-bit value to be byte order swapped.
Returns
The input value, byte order swapped.

Swap32

uint32_t Swap32(
  uint32_t v
)

This unconditionally performs a byte order swap by value of the specified 32-bit value.

Details
Parameters
[in] v
The 32-bit value to be byte order swapped.
Returns
The input value, byte order swapped.

Swap64

uint64_t Swap64(
  uint64_t v
)

This unconditionally performs a byte order swap by value of the specified 64-bit value.

Details
Parameters
[in] v
The 64-bit value to be byte order swapped.
Returns
The input value, byte order swapped.

Write8

void Write8(
  uint8_t *& p,
  uint8_t v
)

Perform a, potentially unaligned, memory write of the 8-bit value to the specified pointer address and increment the pointer by 8-bits (1 byte).

Details
Parameters
[in,out] p
A reference to a pointer address, potentially unaligned, to read the 8-bit value from and to then increment by 8-bits (1 byte).
[in] v
The 8-bit value to write.