# util

<a id="util"></a>

# util

Miscellaneous string, parsing, and version utilities.

## Classes

| Name | Description |
|------|-------------|
| [`Version`](https://auscaster.com/icey/docs/api-reference/icy-util-Version.md#version) | Semantic version number with major, minor, and patch fields. |

## Functions

| Return | Name | Description |
|--------|------|-------------|
| `std::string` | [`format`](#format-26)  | Printf-style string formatting for POD types. |
| `void` | [`toUnderscore`](#tounderscore)  | Replaces all non-alphanumeric characters in str with underscores and converts to lowercase. |
| `bool` | [`isNumber`](#isnumber)  | Returns true if str consists entirely of digit characters. |
| `bool` | [`endsWith`](#endswith)  | Returns true if str ends with the given suffix. |
| `void` | [`removeSpecialCharacters`](#removespecialcharacters)  | Replaces non-alphanumeric characters. Removes all non-alphanumeric characters from str in place. |
| `void` | [`replaceSpecialCharacters`](#replacespecialcharacters)  | Replaces all non-alphanumeric characters in str with `with` in place. |
| `bool` | [`tryParseHex`](#tryparsehex)  | Attempts to parse a hex string into an unsigned integer. |
| `unsigned` | [`parseHex`](#parsehex)  | Parses a hex string into an unsigned integer. |
| `std::string` | [`dumpbin`](#dumpbin)  | Formats the binary contents of data as a hex+ASCII dump string. |
| `bool` | [`compareVersion`](#compareversion)  | Compares two dot-separated version strings. |
| `bool` | [`matchNodes`](#matchnodes)  | Checks whether node matches xnode by splitting both on delim and comparing element-wise. |
| `bool` | [`matchNodes`](#matchnodes-1)  | Checks whether params matches xparams element-wise. |
| `std::string` | [`memAddress`](#memaddress)  | Returns the memory address of ptr as a hex string (e.g. "0x7f3a2b10c0"). |
| `std::string` | [`itostr`](#itostr)  | Converts an integer (or any stream-insertable type) to its string representation. |
| `T` | [`strtoi`](#strtoi)  | Parses a string into integer type T using std::istringstream. Returns 0 if parsing fails. Ensure T has sufficient range for the value. |
| `uint32_t` | [`randomNumber`](#randomnumber)  | Generates a 31-bit pseudo random number using the internal [Random](https://auscaster.com/icey/docs/api-reference/icy-Random.md#random) instance. |
| `std::string` | [`randomString`](#randomstring)  | Generates a random alphanumeric string of the given length. |
| `std::string` | [`randomBinaryString`](#randombinarystring)  | Generates a random binary string of the given byte length. |
| `void` | [`split`](#split)  | Splits str on the delimiter string and appends tokens to elems. |
| `std::vector< std::string >` | [`split`](#split-1)  | Splits str on the delimiter string and returns the tokens as a vector. |
| `void` | [`split`](#split-2)  | Splits str on the delimiter character and appends tokens to elems. |
| `std::vector< std::string >` | [`split`](#split-3)  | Splits str on the delimiter character and returns the tokens as a vector. |
| `S &` | [`replaceInPlace`](#replaceinplace)  | Replace all occurrences of `from` in `str` with `to`, starting at position `start`. Modifies and returns `str` in place. `from` must not be empty. |
| `S &` | [`replaceInPlace`](#replaceinplace-1)  | Replace all occurrences of `from` in `str` with `to`, starting at position `start`. C-string overload. Modifies and returns `str` in place. |
| `S` | [`replace`](#replace)  | Replace all occurences of from (which must not be the empty string) in str with to, starting at position start. |
| `S` | [`replace`](#replace-1)  | Returns a copy of str with all occurrences of from replaced by to (C-string overload). |
| `S` | [`trimLeft`](#trimleft)  | Returns a copy of str with all leading whitespace removed. |
| `S &` | [`trimLeftInPlace`](#trimleftinplace)  | Removes all leading whitespace in str. |
| `S` | [`trimRight`](#trimright)  | Returns a copy of str with all trailing whitespace removed. |
| `S &` | [`trimRightInPlace`](#trimrightinplace)  | Removes all trailing whitespace in str. |
| `S` | [`trim`](#trim)  | Returns a copy of str with all leading and trailing whitespace removed. |
| `S &` | [`trimInPlace`](#triminplace)  | Removes all leading and trailing whitespace in str. |
| `S` | [`toUpper`](#toupper)  | Returns a copy of str containing all upper-case characters. |
| `S &` | [`toUpperInPlace`](#toupperinplace)  | Replaces all characters in str with their upper-case counterparts. |
| `S` | [`toLower`](#tolower)  | Returns a copy of str containing all lower-case characters. |
| `S &` | [`toLowerInPlace`](#tolowerinplace)  | Replaces all characters in str with their lower-case counterparts. |
| `int` | [`icompare`](#icompare) `inline` | Case-insensitive string comparison (locale-independent, ASCII only). |
| `std::streamsize` | [`copyStreamUnbuffered`](#copystreamunbuffered)  | Copies all bytes from istr to ostr one byte at a time (no internal buffer). |
| `std::streamsize` | [`copyStream`](#copystream)  | Copies all bytes from istr to ostr using an internal buffer. |
| `std::streamsize` | [`copyToString`](#copytostring)  | Reads all bytes from istr and appends them to str. |
| `void` | [`clearList`](#clearlist) `inline` | Delete all elements from a list of pointers. |
| `void` | [`clearDeque`](#cleardeque) `inline` | Delete all elements from a deque of pointers. |
| `void` | [`clearVector`](#clearvector) `inline` | Delete all elements from a vector of pointers. |
| `void` | [`clearMap`](#clearmap) `inline` | Delete all associated values from a map (not the key elements). |

---

<a id="format-26"></a>

### format

```cpp
std::string format(const char * fmt, ...)
```

[Defined in src/base/include/icy/util.h:40](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L40)

Printf-style string formatting for POD types. 
#### Returns
Formatted string.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `fmt` | `const char *` | printf format string. |

---

<a id="tounderscore"></a>

### toUnderscore

```cpp
void toUnderscore(std::string & str)
```

[Defined in src/base/include/icy/util.h:44](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L44)

Replaces all non-alphanumeric characters in str with underscores and converts to lowercase.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `str` | `std::string &` | String to transform in place. |

---

<a id="isnumber"></a>

### isNumber

```cpp
bool isNumber(std::string_view str)
```

[Defined in src/base/include/icy/util.h:49](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L49)

Returns true if str consists entirely of digit characters. 
#### Returns
true if every character in str is a decimal digit.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `str` | `std::string_view` | String to test. |

---

<a id="endswith"></a>

### endsWith

```cpp
bool endsWith(std::string_view str, std::string_view suffix)
```

[Defined in src/base/include/icy/util.h:55](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L55)

Returns true if str ends with the given suffix. 
#### Returns
true if str ends with suffix.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `str` | `std::string_view` | String to test. |
| `suffix` | `std::string_view` | Suffix to look for. |

---

<a id="removespecialcharacters"></a>

### removeSpecialCharacters

```cpp
void removeSpecialCharacters(std::string & str, bool allowSpaces = false)
```

[Defined in src/base/include/icy/util.h:61](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L61)

Replaces non-alphanumeric characters. Removes all non-alphanumeric characters from str in place.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `str` | `std::string &` | String to modify. |
| `allowSpaces` | `bool` | If true, ASCII spaces are preserved. |

---

<a id="replacespecialcharacters"></a>

### replaceSpecialCharacters

```cpp
void replaceSpecialCharacters(std::string & str, char with = '_', bool allowSpaces = false)
```

[Defined in src/base/include/icy/util.h:67](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L67)

Replaces all non-alphanumeric characters in str with `with` in place.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `str` | `std::string &` | String to modify. |
| `with` | `char` | Replacement character (default: '_'). |
| `allowSpaces` | `bool` | If true, ASCII spaces are preserved rather than replaced. |

---

<a id="tryparsehex"></a>

### tryParseHex

```cpp
bool tryParseHex(std::string_view s, unsigned & value)
```

[Defined in src/base/include/icy/util.h:74](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L74)

Attempts to parse a hex string into an unsigned integer. 
#### Returns
true if parsing succeeded, false otherwise.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `s` | `std::string_view` | Hex string (with or without 0x prefix). |
| `value` | `unsigned &` | Output: parsed value on success. |

---

<a id="parsehex"></a>

### parseHex

```cpp
unsigned parseHex(std::string_view s)
```

[Defined in src/base/include/icy/util.h:80](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L80)

Parses a hex string into an unsigned integer. 
#### Returns
Parsed value.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `s` | `std::string_view` | Hex string (with or without 0x prefix). |

#### Exceptions

| Exception | Description |
|-----------|-------------|
| `std::invalid_argument` | if the string is not valid hex. |

---

<a id="dumpbin"></a>

### dumpbin

```cpp
std::string dumpbin(const char * data, size_t len)
```

[Defined in src/base/include/icy/util.h:86](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L86)

Formats the binary contents of data as a hex+ASCII dump string. 
#### Returns
Multi-line hex dump string.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `data` | `const char *` | Pointer to the buffer to dump. |
| `len` | `size_t` | Number of bytes to dump. |

---

<a id="compareversion"></a>

### compareVersion

```cpp
bool compareVersion(std::string_view l, std::string_view r)
```

[Defined in src/base/include/icy/util.h:92](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L92)

Compares two dot-separated version strings. 
#### Returns
true if l is strictly greater than r, false if l is equal or less.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `l` | `std::string_view` | Left (local) version string. |
| `r` | `std::string_view` | Right (remote) version string. |

---

<a id="matchnodes"></a>

### matchNodes

```cpp
bool matchNodes(std::string_view node, std::string_view xnode, std::string_view delim = "\r\n")
```

[Defined in src/base/include/icy/util.h:99](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L99)

Checks whether node matches xnode by splitting both on delim and comparing element-wise. 
#### Returns
true if all elements of node match the corresponding elements of xnode.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `node` | `std::string_view` | Node list string to test. |
| `xnode` | `std::string_view` | Expected node list pattern. |
| `delim` | `std::string_view` | Delimiter used to split both strings (default: "\r\n"). |

---

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

### matchNodes

```cpp
bool matchNodes(const std::vector< std::string > & params, const std::vector< std::string > & xparams)
```

[Defined in src/base/include/icy/util.h:106](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L106)

Checks whether params matches xparams element-wise. 
#### Returns
true if every element of params matches the corresponding element of xparams.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `params` | `const std::vector< std::string > &` | Parameter list to test. |
| `xparams` | `const std::vector< std::string > &` | Expected parameter list. |

---

<a id="memaddress"></a>

### memAddress

```cpp
std::string memAddress(const void * ptr)
```

[Defined in src/base/include/icy/util.h:112](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L112)

Returns the memory address of ptr as a hex string (e.g. "0x7f3a2b10c0"). 
#### Returns
Hex string representation of the pointer value.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `ptr` | `const void *` | Pointer whose address to format. |

---

<a id="itostr"></a>

### itostr

```cpp
template<typename T> std::string itostr(const T & t)
```

[Defined in src/base/include/icy/util.h:124](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L124)

Converts an integer (or any stream-insertable type) to its string representation. 
#### Returns
String representation of t.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `t` | `const T &` | Value to convert. |

---

<a id="strtoi"></a>

### strtoi

```cpp
template<typename T> T strtoi(std::string_view s)
```

[Defined in src/base/include/icy/util.h:137](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L137)

Parses a string into integer type T using std::istringstream. Returns 0 if parsing fails. Ensure T has sufficient range for the value. 
#### Returns
Parsed value, or 0 on failure.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `s` | `std::string_view` | String to parse. |

---

<a id="randomnumber"></a>

### randomNumber

```cpp
uint32_t randomNumber()
```

[Defined in src/base/include/icy/util.h:152](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L152)

Generates a 31-bit pseudo random number using the internal [Random](https://auscaster.com/icey/docs/api-reference/icy-Random.md#random) instance. 
#### Returns
Pseudo random uint32_t value.

---

<a id="randomstring"></a>

### randomString

```cpp
std::string randomString(int size)
```

[Defined in src/base/include/icy/util.h:157](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L157)

Generates a random alphanumeric string of the given length. 
#### Returns
[Random](https://auscaster.com/icey/docs/api-reference/icy-Random.md#random) string of length size.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `size` | `int` | Number of characters to generate. |

---

<a id="randombinarystring"></a>

### randomBinaryString

```cpp
std::string randomBinaryString(int size, bool doBase64 = false)
```

[Defined in src/base/include/icy/util.h:163](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L163)

Generates a random binary string of the given byte length. 
#### Returns
[Random](https://auscaster.com/icey/docs/api-reference/icy-Random.md#random) binary string, optionally base64-encoded.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `size` | `int` | Number of random bytes to generate. |
| `doBase64` | `bool` | If true, returns the bytes as a base64-encoded string. |

---

<a id="split"></a>

### split

```cpp
void split(std::string_view str, std::string_view delim, std::vector< std::string > & elems, int limit = -1)
```

[Defined in src/base/include/icy/util.h:175](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L175)

Splits str on the delimiter string and appends tokens to elems.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `str` | `std::string_view` | String to split. |
| `delim` | `std::string_view` | Delimiter string. |
| `elems` | `std::vector< std::string > &` | Output vector; tokens are appended to it. |
| `limit` | `int` | Maximum number of splits (-1 for unlimited). |

---

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

### split

```cpp
std::vector< std::string > split(std::string_view str, std::string_view delim, int limit = -1)
```

[Defined in src/base/include/icy/util.h:182](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L182)

Splits str on the delimiter string and returns the tokens as a vector. 
#### Returns
Vector of token strings.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `str` | `std::string_view` | String to split. |
| `delim` | `std::string_view` | Delimiter string. |
| `limit` | `int` | Maximum number of splits (-1 for unlimited). |

---

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

### split

```cpp
void split(std::string_view str, char delim, std::vector< std::string > & elems, int limit = -1)
```

[Defined in src/base/include/icy/util.h:189](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L189)

Splits str on the delimiter character and appends tokens to elems.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `str` | `std::string_view` | String to split. |
| `delim` | `char` | Delimiter character. |
| `elems` | `std::vector< std::string > &` | Output vector; tokens are appended to it. |
| `limit` | `int` | Maximum number of splits (-1 for unlimited). |

---

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

### split

```cpp
std::vector< std::string > split(std::string_view str, char delim, int limit = -1)
```

[Defined in src/base/include/icy/util.h:196](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L196)

Splits str on the delimiter character and returns the tokens as a vector. 
#### Returns
Vector of token strings.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `str` | `std::string_view` | String to split. |
| `delim` | `char` | Delimiter character. |
| `limit` | `int` | Maximum number of splits (-1 for unlimited). |

---

<a id="replaceinplace"></a>

### replaceInPlace

```cpp
template<class S> S & replaceInPlace(S & str, const S & from, const S & to, typename S::size_type start = 0)
```

[Defined in src/base/include/icy/util.h:206](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L206)

Replace all occurrences of `from` in `str` with `to`, starting at position `start`. Modifies and returns `str` in place. `from` must not be empty.

---

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

### replaceInPlace

```cpp
template<class S> S & replaceInPlace(S & str, const typename S::value_type * from, const typename S::value_type * to, typename S::size_type start = 0)
```

[Defined in src/base/include/icy/util.h:231](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L231)

Replace all occurrences of `from` in `str` with `to`, starting at position `start`. C-string overload. Modifies and returns `str` in place.

---

<a id="replace"></a>

### replace

```cpp
template<class S> S replace(const S & str, const S & from, const S & to, typename S::size_type start = 0)
```

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

Replace all occurences of from (which must not be the empty string) in str with to, starting at position start.

---

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

### replace

```cpp
template<class S> S replace(const S & str, const typename S::value_type * from, const typename S::value_type * to, typename S::size_type start = 0)
```

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

Returns a copy of str with all occurrences of from replaced by to (C-string overload). 
#### Returns
New string with all replacements applied.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `str` | `const S &` | Source string. |
| `from` | `const typename S::value_type *` | Substring to search for; must not be empty. |
| `to` | `const typename S::value_type *` | Replacement string. |
| `start` | `typename S::size_type` | Position in str at which to begin searching (default: 0). |

---

<a id="trimleft"></a>

### trimLeft

```cpp
template<class S> S trimLeft(const S & str)
```

[Defined in src/base/include/icy/util.h:289](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L289)

Returns a copy of str with all leading whitespace removed.

---

<a id="trimleftinplace"></a>

### trimLeftInPlace

```cpp
template<class S> S & trimLeftInPlace(S & str)
```

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

Removes all leading whitespace in str.

---

<a id="trimright"></a>

### trimRight

```cpp
template<class S> S trimRight(const S & str)
```

[Defined in src/base/include/icy/util.h:315](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L315)

Returns a copy of str with all trailing whitespace removed.

---

<a id="trimrightinplace"></a>

### trimRightInPlace

```cpp
template<class S> S & trimRightInPlace(S & str)
```

[Defined in src/base/include/icy/util.h:326](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L326)

Removes all trailing whitespace in str.

---

<a id="trim"></a>

### trim

```cpp
template<class S> S trim(const S & str)
```

[Defined in src/base/include/icy/util.h:340](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L340)

Returns a copy of str with all leading and trailing whitespace removed.

---

<a id="triminplace"></a>

### trimInPlace

```cpp
template<class S> S & trimInPlace(S & str)
```

[Defined in src/base/include/icy/util.h:355](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L355)

Removes all leading and trailing whitespace in str.

---

<a id="toupper"></a>

### toUpper

```cpp
template<class S> S toUpper(const S & str)
```

[Defined in src/base/include/icy/util.h:378](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L378)

Returns a copy of str containing all upper-case characters.

---

<a id="toupperinplace"></a>

### toUpperInPlace

```cpp
template<class S> S & toUpperInPlace(S & str)
```

[Defined in src/base/include/icy/util.h:392](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L392)

Replaces all characters in str with their upper-case counterparts.

---

<a id="tolower"></a>

### toLower

```cpp
template<class S> S toLower(const S & str)
```

[Defined in src/base/include/icy/util.h:406](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L406)

Returns a copy of str containing all lower-case characters.

---

<a id="tolowerinplace"></a>

### toLowerInPlace

```cpp
template<class S> S & toLowerInPlace(S & str)
```

[Defined in src/base/include/icy/util.h:420](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L420)

Replaces all characters in str with their lower-case counterparts.

---

<a id="icompare"></a>

### icompare

`inline`

```cpp
inline int icompare(std::string_view a, std::string_view b)
```

[Defined in src/base/include/icy/util.h:441](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L441)

Case-insensitive string comparison (locale-independent, ASCII only). 
#### Returns
Negative if a < b, zero if a == b, positive if a > b.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `a` | `std::string_view` | First string. |
| `b` | `std::string_view` | Second string. |

---

<a id="copystreamunbuffered"></a>

### copyStreamUnbuffered

```cpp
std::streamsize copyStreamUnbuffered(std::istream & istr, std::ostream & ostr)
```

[Defined in src/base/include/icy/util.h:467](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L467)

Copies all bytes from istr to ostr one byte at a time (no internal buffer). 
#### Returns
Total number of bytes copied.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `istr` | `std::istream &` | Source stream. |
| `ostr` | `std::ostream &` | Destination stream. |

---

<a id="copystream"></a>

### copyStream

```cpp
std::streamsize copyStream(std::istream & istr, std::ostream & ostr, size_t bufferSize = 8192)
```

[Defined in src/base/include/icy/util.h:474](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L474)

Copies all bytes from istr to ostr using an internal buffer. 
#### Returns
Total number of bytes copied.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `istr` | `std::istream &` | Source stream. |
| `ostr` | `std::ostream &` | Destination stream. |
| `bufferSize` | `size_t` | Internal buffer size in bytes (default: 8192). |

---

<a id="copytostring"></a>

### copyToString

```cpp
std::streamsize copyToString(std::istream & istr, std::string & str, size_t bufferSize = 8192)
```

[Defined in src/base/include/icy/util.h:482](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L482)

Reads all bytes from istr and appends them to str. 
#### Returns
Total number of bytes read.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `istr` | `std::istream &` | Source stream. |
| `str` | `std::string &` | Output string to append data to. |
| `bufferSize` | `size_t` | Internal buffer size in bytes (default: 8192). |

---

<a id="clearlist"></a>

### clearList

`inline`

```cpp
template<typename Val> inline void clearList(std::list< Val * > & L)
```

[Defined in src/base/include/icy/util.h:569](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L569)

Delete all elements from a list of pointers.

---

<a id="cleardeque"></a>

### clearDeque

`inline`

```cpp
template<typename Val> inline void clearDeque(std::deque< Val * > & D)
```

[Defined in src/base/include/icy/util.h:578](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L578)

Delete all elements from a deque of pointers.

---

<a id="clearvector"></a>

### clearVector

`inline`

```cpp
template<typename Val> inline void clearVector(std::vector< Val * > & V)
```

[Defined in src/base/include/icy/util.h:587](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L587)

Delete all elements from a vector of pointers.

---

<a id="clearmap"></a>

### clearMap

`inline`

```cpp
template<typename Key, typename Val> inline void clearMap(std::map< Key, Val * > & M)
```

[Defined in src/base/include/icy/util.h:596](https://github.com/auscaster/icey/blob/main/src/base/include/icy/util.h#L596)

Delete all associated values from a map (not the key elements).
