# UInt32Attribute

<a id="uint32attribute"></a>

# UInt32Attribute

```cpp
#include <icy/stun/attributes.h>

class UInt32Attribute
```

[Defined in src/stun/include/icy/stun/attributes.h:269](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L269)

> **Inherits:** [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute)

Implements a STUN/TURN attribute that holds a 32-bit integer.

## List of all members

| Name | Kind | Owner |
|------|------|-------|
| [`UInt32Attribute`](#uint32attribute-1) | `function` | Declared here |
| [`UInt32Attribute`](#uint32attribute-2) | `function` | Declared here |
| [`clone`](#clone-19) | `function` | Declared here |
| [`value`](#value-1) | `function` | Declared here |
| [`setValue`](#setvalue-1) | `function` | Declared here |
| [`getBit`](#getbit) | `function` | Declared here |
| [`setBit`](#setbit) | `function` | Declared here |
| [`read`](#read-14) | `function` | Declared here |
| [`write`](#write-43) | `function` | Declared here |
| [`Size`](#size-17) | `variable` | Declared here |
| [`_bits`](#_bits) | `variable` | Declared here |
| [`~Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute-1) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`clone`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#clone-12) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`read`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#read-7) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`write`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#write-36) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`type`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#type-17) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`size`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#size-12) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`paddingBytes`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#paddingbytes) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`paddedBytes`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#paddedbytes) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`consumePadding`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#consumepadding) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`writePadding`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#writepadding) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`typeString`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#typestring) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`TypeID`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#typeid) | `variable` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`create`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#create-10) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`paddingBytes`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#paddingbytes-1) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`paddedBytes`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#paddedbytes-1) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`typeString`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#typestring-1) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`_type`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#_type-1) | `variable` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`_size`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#_size-3) | `variable` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute-2) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`setLength`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#setlength) | `function` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |
| [`Type`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#type-18) | `enum` | Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) |

## Inherited from [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute)

| Kind | Name | Description |
|------|------|-------------|
| `function` | [`~Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute-1) `virtual` `inline` |  |
| `function` | [`clone`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#clone-12) `virtual` | Returns a deep copy of this attribute. |
| `function` | [`read`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#read-7) `virtual` | Reads the body (not the type or size) for this type of attribute from the given buffer. |
| `function` | [`write`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#write-36) `virtual` `const` | Writes the body (not the type or size) to the given buffer. |
| `function` | [`type`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#type-17) `const` |  |
| `function` | [`size`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#size-12) `const` |  |
| `function` | [`paddingBytes`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#paddingbytes) `const` `inline` |  |
| `function` | [`paddedBytes`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#paddedbytes) `const` `inline` |  |
| `function` | [`consumePadding`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#consumepadding) `const` | Advances the reader past any 4-byte alignment padding that follows this attribute's body. |
| `function` | [`writePadding`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#writepadding) `const` | Writes zero-fill padding bytes to align this attribute to a 4-byte boundary. |
| `function` | [`typeString`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#typestring)  |  |
| `variable` | [`TypeID`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#typeid) `static` `constexpr` |  |
| `function` | [`create`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#create-10) `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`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#paddingbytes-1) `static` `inline` `constexpr` | Returns the 4-byte alignment padding required for a body of `size` bytes. |
| `function` | [`paddedBytes`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#paddedbytes-1) `static` `inline` `constexpr` | Returns the body length including 4-byte alignment padding. |
| `function` | [`typeString`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#typestring-1) `static` |  |
| `variable` | [`_type`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#_type-1)  |  |
| `variable` | [`_size`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#_size-3)  |  |
| `function` | [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute-2)  |  |
| `function` | [`setLength`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#setlength)  | Updates the stored body length. |
| `enum` | [`Type`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#type-18)  |  |

## Public Methods

| Return | Name | Description |
|--------|------|-------------|
|  | [`UInt32Attribute`](#uint32attribute-1)  |  |
|  | [`UInt32Attribute`](#uint32attribute-2)  | Copy constructor. |
| std::unique_ptr< [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) > | [`clone`](#clone-19) `virtual` `override` | Returns a deep copy of this attribute. |
| `uint32_t` | [`value`](#value-1) `const` `inline` |  |
| `void` | [`setValue`](#setvalue-1) `inline` | Sets the stored 32-bit value. |
| `bool` | [`getBit`](#getbit) `const` | Returns the state of a single bit within the stored word. |
| `void` | [`setBit`](#setbit)  | Sets or clears a single bit within the stored word. |
| `void` | [`read`](#read-14) `virtual` `override` | Reads the body (not the type or size) for this type of attribute from the given buffer. |
| `void` | [`write`](#write-43) `virtual` `const` `override` | Writes the body (not the type or size) to the given buffer. |

---

<a id="uint32attribute-1"></a>

### UInt32Attribute

```cpp
UInt32Attribute(uint16_t type)
```

[Defined in src/stun/include/icy/stun/attributes.h:273](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L273)

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `type` | `uint16_t` | Wire type code for the concrete attribute. |

---

<a id="uint32attribute-2"></a>

### UInt32Attribute

```cpp
UInt32Attribute(const UInt32Attribute & r)
```

[Defined in src/stun/include/icy/stun/attributes.h:276](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L276)

Copy constructor.

---

<a id="clone-19"></a>

### clone

`virtual` `override`

```cpp
virtual std::unique_ptr< Attribute > clone() override
```

[Defined in src/stun/include/icy/stun/attributes.h:279](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L279)

Returns a deep copy of this attribute.

#### Reimplements

- [`Attribute::clone`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#clone-12)

---

<a id="value-1"></a>

### value

`const` `inline`

```cpp
inline uint32_t value() const
```

[Defined in src/stun/include/icy/stun/attributes.h:284](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L284)

#### Returns
The stored 32-bit value.

---

<a id="setvalue-1"></a>

### setValue

`inline`

```cpp
inline void setValue(uint32_t bits)
```

[Defined in src/stun/include/icy/stun/attributes.h:288](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L288)

Sets the stored 32-bit value.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `bits` | `uint32_t` | Value to store. |

---

<a id="getbit"></a>

### getBit

`const`

```cpp
bool getBit(int index) const
```

[Defined in src/stun/include/icy/stun/attributes.h:293](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L293)

Returns the state of a single bit within the stored word. 
#### Returns
true if the bit is set.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `index` | `int` | Bit position (0 = LSB, 31 = MSB). |

---

<a id="setbit"></a>

### setBit

```cpp
void setBit(int index, bool value)
```

[Defined in src/stun/include/icy/stun/attributes.h:298](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L298)

Sets or clears a single bit within the stored word.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `index` | `int` | Bit position (0 = LSB, 31 = MSB). |
| `value` | `bool` | true to set, false to clear. |

---

<a id="read-14"></a>

### read

`virtual` `override`

```cpp
virtual void read(BitReader & reader) override
```

[Defined in src/stun/include/icy/stun/attributes.h:300](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L300)

Reads the body (not the type or size) for this type of attribute from the given buffer.

#### Reimplements

- [`Attribute::read`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#read-7)

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `reader` | [`BitReader`](https://auscaster.com/icey/docs/api-reference/icy-BitReader.md#bitreader) & | Source bit reader positioned at the attribute body. |

---

<a id="write-43"></a>

### write

`virtual` `const` `override`

```cpp
virtual void write(BitWriter & writer) const override
```

[Defined in src/stun/include/icy/stun/attributes.h:301](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L301)

Writes the body (not the type or size) to the given buffer.

#### Reimplements

- [`Attribute::write`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#write-36)

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `writer` | [`BitWriter`](https://auscaster.com/icey/docs/api-reference/icy-BitWriter.md#bitwriter) & | Destination bit writer. |

## Public Static Attributes

| Return | Name | Description |
|--------|------|-------------|
| `constexpr uint16_t` | [`Size`](#size-17) `static` `constexpr` |  |

---

<a id="size-17"></a>

### Size

`static` `constexpr`

```cpp
constexpr uint16_t Size = 4
```

[Defined in src/stun/include/icy/stun/attributes.h:281](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L281)

## Private Attributes

| Return | Name | Description |
|--------|------|-------------|
| `uint32_t` | [`_bits`](#_bits)  |  |

---

<a id="_bits"></a>

### _bits

```cpp
uint32_t _bits
```

[Defined in src/stun/include/icy/stun/attributes.h:304](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L304)
