# UInt8Attribute

<a id="uint8attribute"></a>

# UInt8Attribute

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

class UInt8Attribute
```

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

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

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

## List of all members

| Name | Kind | Owner |
|------|------|-------|
| [`UInt8Attribute`](#uint8attribute-1) | `function` | Declared here |
| [`UInt8Attribute`](#uint8attribute-2) | `function` | Declared here |
| [`clone`](#clone-21) | `function` | Declared here |
| [`value`](#value-3) | `function` | Declared here |
| [`setValue`](#setvalue-3) | `function` | Declared here |
| [`getBit`](#getbit-2) | `function` | Declared here |
| [`setBit`](#setbit-2) | `function` | Declared here |
| [`read`](#read-16) | `function` | Declared here |
| [`write`](#write-45) | `function` | Declared here |
| [`Size`](#size-19) | `variable` | Declared here |
| [`_bits`](#_bits-2) | `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 |
|--------|------|-------------|
|  | [`UInt8Attribute`](#uint8attribute-1)  |  |
|  | [`UInt8Attribute`](#uint8attribute-2)  | Copy constructor. |
| std::unique_ptr< [`Attribute`](https://auscaster.com/icey/docs/api-reference/icy-stun-Attribute.md#attribute) > | [`clone`](#clone-21) `virtual` `override` | Returns a deep copy of this attribute. |
| `uint8_t` | [`value`](#value-3) `const` `inline` |  |
| `void` | [`setValue`](#setvalue-3) `inline` | Sets the stored 8-bit value. |
| `bool` | [`getBit`](#getbit-2) `const` | Returns the state of a single bit within the stored byte. |
| `void` | [`setBit`](#setbit-2)  | Sets or clears a single bit within the stored byte. |
| `void` | [`read`](#read-16) `virtual` `override` | Reads the body (not the type or size) for this type of attribute from the given buffer. |
| `void` | [`write`](#write-45) `virtual` `const` `override` | Writes the body (not the type or size) to the given buffer. |

---

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

### UInt8Attribute

```cpp
UInt8Attribute(uint16_t type)
```

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

#### Parameters

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

---

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

### UInt8Attribute

```cpp
UInt8Attribute(const UInt8Attribute & r)
```

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

Copy constructor.

---

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

### clone

`virtual` `override`

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

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

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-3"></a>

### value

`const` `inline`

```cpp
inline uint8_t value() const
```

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

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

---

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

### setValue

`inline`

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

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

Sets the stored 8-bit value.

#### Parameters

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

---

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

### getBit

`const`

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

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

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

#### Parameters

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

---

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

### setBit

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

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

Sets or clears a single bit within the stored byte.

#### Parameters

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

---

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

### read

`virtual` `override`

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

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

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-45"></a>

### write

`virtual` `const` `override`

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

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

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-19) `static` `constexpr` |  |

---

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

### Size

`static` `constexpr`

```cpp
constexpr uint16_t Size = 1
```

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

## Private Attributes

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

---

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

### _bits

```cpp
uint8_t _bits
```

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