StringAttribute
#include <icy/stun/attributes.h>
class StringAttributeDefined in src/stun/include/icy/stun/attributes.h:369
- Inherits
Attribute
Implements a STUN/TURN attribute that holds an arbitrary byte string. Used for Username, Password, Realm, Nonce, Software, Data, and similar attributes.
List of all members
| Name | Kind | Owner |
|---|---|---|
StringAttribute | function | Declared here |
StringAttribute | function | Declared here |
~StringAttribute | function | Declared here |
clone | function | Declared here |
bytes | function | Declared here |
setBytes | function | Declared here |
asString | function | Declared here |
copyBytes | function | Declared here |
copyBytes | function | Declared here |
getByte | function | Declared here |
setByte | function | Declared here |
read | function | Declared here |
write | function | Declared here |
_bytes | variable | Declared here |
~Attribute | function | Inherited from Attribute |
clone | function | Inherited from Attribute |
read | function | Inherited from Attribute |
write | function | Inherited from Attribute |
type | function | Inherited from Attribute |
size | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
consumePadding | function | Inherited from Attribute |
writePadding | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
TypeID | variable | Inherited from Attribute |
create | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
_type | variable | Inherited from Attribute |
_size | variable | Inherited from Attribute |
Attribute | function | Inherited from Attribute |
setLength | function | Inherited from Attribute |
Type | enum | Inherited from Attribute |
Inherited from Attribute
| Kind | Name | Description |
|---|---|---|
function | ~Attribute virtual inline | |
function | clone virtual | Returns a deep copy of this attribute. |
function | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
function | write virtual const | Writes the body (not the type or size) to the given buffer. |
function | type const | |
function | size const | |
function | paddingBytes const inline | |
function | paddedBytes const inline | |
function | consumePadding const | Advances the reader past any 4-byte alignment padding that follows this attribute's body. |
function | writePadding const | Writes zero-fill padding bytes to align this attribute to a 4-byte boundary. |
function | typeString | |
variable | TypeID static constexpr | |
function | create static | Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid. |
function | paddingBytes static inline constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
function | paddedBytes static inline constexpr | Returns the body length including 4-byte alignment padding. |
function | typeString static | |
variable | _type | |
variable | _size | |
function | Attribute | |
function | setLength | Updates the stored body length. |
enum | Type |
Public Methods
| Return | Name | Description |
|---|---|---|
StringAttribute | ||
StringAttribute | Copy constructor; duplicates stored bytes. | |
~StringAttribute virtual | ||
std::unique_ptr< Attribute > | clone virtual override | Returns a deep copy of this attribute. |
const char * | bytes const inline | |
void | setBytes | Replaces the stored bytes with a copy of the given buffer and updates the attribute's reported size. |
std::string | asString const | |
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 override | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write virtual const override | Writes the body (not the type or size) to the given buffer. |
StringAttribute
StringAttribute(uint16_t type, uint16_t size = 0)Defined in src/stun/include/icy/stun/attributes.h:374
Parameters
| Parameter | Type | Description |
|---|---|---|
type | uint16_t | Wire type code for the concrete attribute. |
size | uint16_t | Initial body length in bytes (0 for variable-length attributes). |
StringAttribute
StringAttribute(const StringAttribute & r)Defined in src/stun/include/icy/stun/attributes.h:377
Copy constructor; duplicates stored bytes.
~StringAttribute
virtual
virtual ~StringAttribute()Defined in src/stun/include/icy/stun/attributes.h:378
clone
virtual override
virtual std::unique_ptr< Attribute > clone() overrideDefined in src/stun/include/icy/stun/attributes.h:381
Returns a deep copy of this attribute.
Reimplements
bytes
const inline
inline const char * bytes() constDefined in src/stun/include/icy/stun/attributes.h:384
Returns
Pointer to the raw byte buffer.
setBytes
void setBytes(const char * bytes, size_t size)Defined in src/stun/include/icy/stun/attributes.h:390
Replaces the stored bytes with a copy of the given buffer and updates the attribute's reported size.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | const char * | Source data pointer. |
size | size_t | Number of bytes to copy. |
asString
const
std::string asString() constDefined in src/stun/include/icy/stun/attributes.h:393
Returns
The stored bytes as a std::string.
copyBytes
void copyBytes(const char * bytes)Defined in src/stun/include/icy/stun/attributes.h:398
Copies a null-terminated string into the attribute, using strlen to determine the length.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | const char * | Null-terminated source string. |
copyBytes
void copyBytes(const void * bytes, size_t size)Defined in src/stun/include/icy/stun/attributes.h:403
Copies an arbitrary block of memory into the attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | const void * | Source data pointer. |
size | size_t | Number of bytes to copy. |
getByte
const
uint8_t getByte(int index) constDefined in src/stun/include/icy/stun/attributes.h:408
Returns a single byte from the stored buffer.
Returns
The byte value at index.
Parameters
| Parameter | Type | Description |
|---|---|---|
index | int | Zero-based byte offset. |
setByte
void setByte(int index, uint8_t value)Defined in src/stun/include/icy/stun/attributes.h:413
Overwrites a single byte in the stored buffer.
Parameters
| Parameter | Type | Description |
|---|---|---|
index | int | Zero-based byte offset. |
value | uint8_t | New value to write. |
read
virtual override
virtual void read(BitReader & reader) overrideDefined in src/stun/include/icy/stun/attributes.h:415
Reads the body (not the type or size) for this type of attribute from the given buffer.
Reimplements
Parameters
| Parameter | Type | Description |
|---|---|---|
reader | BitReader & | Source bit reader positioned at the attribute body. |
write
virtual const override
virtual void write(BitWriter & writer) const overrideDefined in src/stun/include/icy/stun/attributes.h:416
Writes the body (not the type or size) to the given buffer.
Reimplements
Parameters
| Parameter | Type | Description |
|---|---|---|
writer | BitWriter & | Destination bit writer. |
Private Attributes
| Return | Name | Description |
|---|---|---|
std::vector< char > | _bytes |
_bytes
std::vector< char > _bytes