#include <icy/stun/attributes.h>Inherits:
Attribute
Implements a STUN/TURN attribute that holds an arbitrary byte string. Used for Username, Password, Realm, Nonce, Software, Data, and similar attributes.
| Return | Name | Description |
|---|---|---|
StringAttribute | #### Parameters | |
StringAttribute | Copy constructor; duplicates stored bytes. | |
std::unique_ptr< Attribute > | clone virtual | Returns a deep copy of this attribute. |
const char * | bytes const inline | #### Returns |
void | setBytes | Replaces the stored bytes with a copy of the given buffer and updates the attribute's reported size. |
std::string | asString const | #### Returns |
void | copyBytes | Copies a null-terminated string into the attribute, using strlen to determine the length. |
void | copyBytes | Copies an arbitrary block of memory into the attribute. |
uint8_t | getByte const | Returns a single byte from the stored buffer. |
void | setByte | Overwrites a single byte in the stored buffer. |
void | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write virtual const | Writes the body (not the type or size) to the given buffer. |
StringAttribute(uint16_t type, uint16_t size)type Wire type code for the concrete attribute.
size Initial body length in bytes (0 for variable-length attributes).
StringAttribute(const StringAttribute & r)Copy constructor; duplicates stored bytes.
virtual
virtual std::unique_ptr< Attribute > clone()Returns a deep copy of this attribute.
const inline
inline const char * bytes() constPointer to the raw byte buffer.
void setBytes(const char * bytes, size_t size)Replaces the stored bytes with a copy of the given buffer and updates the attribute's reported size.
bytes Source data pointer.
size Number of bytes to copy.
const
std::string asString() constThe stored bytes as a std::string.
void copyBytes(const char * bytes)Copies a null-terminated string into the attribute, using strlen to determine the length.
bytes Null-terminated source string.void copyBytes(const void * bytes, size_t size)Copies an arbitrary block of memory into the attribute.
bytes Source data pointer.
size Number of bytes to copy.
const
uint8_t getByte(int index) constReturns a single byte from the stored buffer.
index Zero-based byte offset.The byte value at index.
void setByte(int index, uint8_t value)Overwrites a single byte in the stored buffer.
index Zero-based byte offset.
value New value to write.
virtual
virtual void read(BitReader & reader)Reads the body (not the type or size) for this type of attribute from the given buffer.
reader Source bit reader positioned at the attribute body.virtual const
virtual void write(BitWriter & writer) constWrites the body (not the type or size) to the given buffer.
writer Destination bit writer.| Return | Name | Description |
|---|---|---|
std::vector< char > | _bytes |
std::vector< char > _bytes