MPD: util/StringUtil.hxx File Reference

MPD 0.20.18

Functions
StringUtil.hxx File Reference
`#include "Compiler.h"`
`#include <stddef.h>`
Include dependency graph for StringUtil.hxx:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Functions
gcc_nonnull_all char * | CopyString (char *dest, const char *src, size_t size) noexcept
| Copy a string. More...
gcc_pure const char * | StripLeft (const char *p) noexcept
| Returns a pointer to the first non-whitespace character in the string, or to the end of the string. More...
static gcc_pure char * | StripLeft (char *p) noexcept
gcc_pure const char * | StripLeft (const char *p, const char *end) noexcept
gcc_pure const char * | StripRight (const char *p, const char *end) noexcept
| Determine the string's end as if it was stripped on the right side. More...
static gcc_pure char * | StripRight (char *p, char *end) noexcept
| Determine the string's end as if it was stripped on the right side. More...
gcc_pure size_t | StripRight (const char *p, size_t length) noexcept
| Determine the string's length as if it was stripped on the right side. More...
void | StripRight (char *p) noexcept
| Strip trailing whitespace by null-terminating the string. More...
char * | Strip (char *p) noexcept
| Skip whitespace at the beginning and terminate the string after the last non-whitespace character. More...
gcc_pure bool | StringArrayContainsCase (const char *const *haystack, const char *needle) noexcept
| Checks whether a string array contains the specified string. More...
void | ToUpperASCII (char *dest, const char *src, size_t size) noexcept
| Convert the specified ASCII string (0x00..0x7f) to upper case. More...

## Function Documentation

## ◆ CopyString()

gcc_nonnull_all char* CopyString | ( | char * | dest,
|  | const char * | src,
|  | size_t | size
| ) |  |
| noexcept

Copy a string.

If the buffer is too small, then the string is truncated. This is a safer version of strncpy().

Parameters

  size | the size of the destination buffer (including the null terminator)

Returns
  a pointer to the null terminator

## ◆ StringArrayContainsCase()

gcc_pure bool StringArrayContainsCase | ( | const char *const * | haystack,
|  | const char * | needle
| ) |  |
| noexcept

Checks whether a string array contains the specified string.

Parameters

  haystack | a NULL terminated list of strings
  needle | the string to search for; the comparison is case-insensitive for ASCII characters

Returns
  true if found

## ◆ Strip()

char* Strip | ( | char * | p | ) |
| noexcept

Skip whitespace at the beginning and terminate the string after the last non-whitespace character.

## ◆ StripLeft() [1/3]

gcc_pure const char* StripLeft | ( | const char * | p | ) |
| noexcept

Returns a pointer to the first non-whitespace character in the string, or to the end of the string.

## ◆ StripLeft() [2/3]

static gcc_pure char* StripLeft | ( | char * | p | ) |
| inlinestaticnoexcept

Definition at line 49 of file StringUtil.hxx.

## ◆ StripLeft() [3/3]

gcc_pure const char* StripLeft | ( | const char * | p,
|  | const char * | end
| ) |  |
| noexcept

## ◆ StripRight() [1/4]

gcc_pure const char* StripRight | ( | const char * | p,
|  | const char * | end
| ) |  |
| noexcept

Determine the string's end as if it was stripped on the right side.

## ◆ StripRight() [2/4]

static gcc_pure char* StripRight | ( | char * | p,
|  | char * | end
| ) |  |
| inlinestaticnoexcept

Determine the string's end as if it was stripped on the right side.

Definition at line 70 of file StringUtil.hxx.

## ◆ StripRight() [3/4]

gcc_pure size_t StripRight | ( | const char * | p,
|  | size_t | length
| ) |  |
| noexcept

Determine the string's length as if it was stripped on the right side.

## ◆ StripRight() [4/4]

void StripRight | ( | char * | p | ) |
| noexcept

Strip trailing whitespace by null-terminating the string.

## ◆ ToUpperASCII()

void ToUpperASCII | ( | char * | dest,
|  | const char * | src,
|  | size_t | size
| ) |  |
| noexcept

Convert the specified ASCII string (0x00..0x7f) to upper case.

Parameters

  size | the destination buffer size