# NVCollection

<a id="nvcollection"></a>

# NVCollection

```cpp
#include <icy/collection.h>

class NVCollection
```

[Defined in src/base/include/icy/collection.h:187](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L187)

> **Subclassed by:** [`FormWriter`](https://auscaster.com/icey/docs/api-reference/icy-http-FormWriter.md#formwriter), [`Message`](https://auscaster.com/icey/docs/api-reference/icy-http-Message.md#message-1)

A storage container for a name value collections. This collection can store multiple entries for each name, and it's getters are case-insensitive.

## Public Methods

| Return | Name | Description |
|--------|------|-------------|
|  | [`NVCollection`](#nvcollection-1) `inline` |  |
|  | [`NVCollection`](#nvcollection-2) `inline` |  |
|  | [`NVCollection`](#nvcollection-3) `inline` `noexcept` |  |
|  | [`~NVCollection`](#nvcollection-4) `virtual` `inline` |  |
| [`NVCollection`](#nvcollection) & | [`operator=`](#operator-64)  | Assigns the name-value pairs of another [NVCollection](#nvcollection) to this one. |
| [`NVCollection`](#nvcollection) & | [`operator=`](#operator-65) `noexcept` |  |
| `const std::string &` | [`operator[]`](#operator-66) `const` | Returns the value of the (first) name-value pair with the given name. |
| `void` | [`set`](#set-1)  | Sets the value of the (first) name-value pair with the given name. |
| `void` | [`add`](#add-4)  | Adds a new name-value pair with the given name and value. |
| `void` | [`add`](#add-5)  | Adds a new name-value pair using move semantics. |
| `const std::string &` | [`get`](#get-7) `const` | Returns the value of the first name-value pair with the given name. |
| `const std::string &` | [`get`](#get-8) `const` | Returns the value of the first name-value pair with the given name. If no value with the given name has been found, the defaultValue is returned. |
| `bool` | [`has`](#has-2) `const` | Returns true if there is at least one name-value pair with the given name. |
| [`ConstIterator`](#constiterator) | [`find`](#find) `const` | Returns an iterator pointing to the first name-value pair with the given name. |
| [`ConstIterator`](#constiterator) | [`begin`](#begin-5) `const` | Returns an iterator pointing to the begin of the name-value pair collection. |
| [`ConstIterator`](#constiterator) | [`end`](#end-2) `const` | Returns an iterator pointing to the end of the name-value pair collection. |
| `bool` | [`empty`](#empty-2) `const` | Returns true iff the header does not have any content. |
| `int` | [`size`](#size-5) `const` | Returns the number of name-value pairs in the collection. |
| `void` | [`erase`](#erase-1)  | Removes all name-value pairs with the given name. |
| `void` | [`clear`](#clear-3)  | Removes all name-value pairs and their values. |

---

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

### NVCollection

`inline`

```cpp
inline NVCollection()
```

[Defined in src/base/include/icy/collection.h:194](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L194)

---

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

### NVCollection

`inline`

```cpp
inline NVCollection(const NVCollection & nvc)
```

[Defined in src/base/include/icy/collection.h:198](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L198)

---

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

### NVCollection

`inline` `noexcept`

```cpp
inline NVCollection(NVCollection && nvc) noexcept
```

[Defined in src/base/include/icy/collection.h:203](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L203)

---

<a id="nvcollection-4"></a>

### ~NVCollection

`virtual` `inline`

```cpp
virtual inline ~NVCollection()
```

[Defined in src/base/include/icy/collection.h:208](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L208)

---

<a id="operator-64"></a>

### operator=

```cpp
NVCollection & operator=(const NVCollection & nvc)
```

[Defined in src/base/include/icy/collection.h:213](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L213)

Assigns the name-value pairs of another [NVCollection](#nvcollection) to this one.

---

<a id="operator-65"></a>

### operator=

`noexcept`

```cpp
NVCollection & operator=(NVCollection && nvc) noexcept
```

[Defined in src/base/include/icy/collection.h:214](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L214)

---

<a id="operator-66"></a>

### operator[]

`const`

```cpp
const std::string & operator[](std::string_view name) const
```

[Defined in src/base/include/icy/collection.h:219](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L219)

Returns the value of the (first) name-value pair with the given name.

Throws a NotFoundException if the name-value pair does not exist.

---

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

### set

```cpp
void set(const std::string & name, const std::string & value)
```

[Defined in src/base/include/icy/collection.h:222](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L222)

Sets the value of the (first) name-value pair with the given name.

---

<a id="add-4"></a>

### add

```cpp
void add(const std::string & name, const std::string & value)
```

[Defined in src/base/include/icy/collection.h:225](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L225)

Adds a new name-value pair with the given name and value.

---

<a id="add-5"></a>

### add

```cpp
void add(std::string && name, std::string && value)
```

[Defined in src/base/include/icy/collection.h:228](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L228)

Adds a new name-value pair using move semantics.

---

<a id="get-7"></a>

### get

`const`

```cpp
const std::string & get(std::string_view name) const
```

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

Returns the value of the first name-value pair with the given name.

Throws a NotFoundException if the name-value pair does not exist.

---

<a id="get-8"></a>

### get

`const`

```cpp
const std::string & get(std::string_view name, const std::string & defaultValue) const
```

[Defined in src/base/include/icy/collection.h:238](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L238)

Returns the value of the first name-value pair with the given name. If no value with the given name has been found, the defaultValue is returned.

---

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

### has

`const`

```cpp
bool has(std::string_view name) const
```

[Defined in src/base/include/icy/collection.h:242](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L242)

Returns true if there is at least one name-value pair with the given name.

---

<a id="find"></a>

### find

`const`

```cpp
ConstIterator find(std::string_view name) const
```

[Defined in src/base/include/icy/collection.h:246](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L246)

Returns an iterator pointing to the first name-value pair with the given name.

---

<a id="begin-5"></a>

### begin

`const`

```cpp
ConstIterator begin() const
```

[Defined in src/base/include/icy/collection.h:250](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L250)

Returns an iterator pointing to the begin of the name-value pair collection.

---

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

### end

`const`

```cpp
ConstIterator end() const
```

[Defined in src/base/include/icy/collection.h:254](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L254)

Returns an iterator pointing to the end of the name-value pair collection.

---

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

### empty

`const`

```cpp
bool empty() const
```

[Defined in src/base/include/icy/collection.h:257](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L257)

Returns true iff the header does not have any content.

---

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

### size

`const`

```cpp
int size() const
```

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

Returns the number of name-value pairs in the collection.

---

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

### erase

```cpp
void erase(std::string_view name)
```

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

Removes all name-value pairs with the given name.

---

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

### clear

```cpp
void clear()
```

[Defined in src/base/include/icy/collection.h:267](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L267)

Removes all name-value pairs and their values.

## Public Types

| Name | Description |
|------|-------------|
| [`Map`](#map-6)  |  |
| [`Iterator`](#iterator)  |  |
| [`ConstIterator`](#constiterator)  |  |

---

<a id="map-6"></a>

### Map

```cpp
using Map = std::vector< std::pair< std::string, std::string > >
```

[Defined in src/base/include/icy/collection.h:190](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L190)

---

<a id="iterator"></a>

### Iterator

```cpp
using Iterator = Map::iterator
```

[Defined in src/base/include/icy/collection.h:191](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L191)

---

<a id="constiterator"></a>

### ConstIterator

```cpp
using ConstIterator = Map::const_iterator
```

[Defined in src/base/include/icy/collection.h:192](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L192)

## Private Attributes

| Return | Name | Description |
|--------|------|-------------|
| [`Map`](#map-6) | [`_map`](#_map-2)  |  |

---

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

### _map

```cpp
Map _map
```

Type: [`Map`](#map-6)

[Defined in src/base/include/icy/collection.h:270](https://github.com/auscaster/icey/blob/main/src/base/include/icy/collection.h#L270)
