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

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
sizethe size of the destination buffer (including the null terminator)
Returns
a pointer to the null terminator
gcc_pure bool StringArrayContainsCase ( const char *const *  haystack,
const char *  needle 
)
noexcept

Checks whether a string array contains the specified string.

Parameters
haystacka NULL terminated list of strings
needlethe string to search for; the comparison is case-insensitive for ASCII characters
Returns
true if found
char* Strip ( char *  p)
noexcept

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

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.

static gcc_pure char* StripLeft ( char *  p)
inlinestaticnoexcept

Definition at line 49 of file StringUtil.hxx.

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.

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.

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.

void StripRight ( char *  p)
noexcept

Strip trailing whitespace by null-terminating the string.

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

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

Parameters
sizethe destination buffer size