StringAttribute
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. | |
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
typeWire type code for the concrete attribute.sizeInitial 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.
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
bytesSource data pointer.sizeNumber 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
bytesNull-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
bytesSource data pointer.sizeNumber 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.
Parameters
indexZero-based byte offset.
Returns
The byte value at index.
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
indexZero-based byte offset.valueNew 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.
Parameters
readerSource bit reader positioned at the attribute body.
Reimplements
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.
Parameters
writerDestination bit writer.
Reimplements
Private Attributes
| Return | Name | Description |
|---|---|---|
std::vector< char > | _bytes |
_bytes
std::vector< char > _bytes