MPD: util/StringUtil.hxx Source File

MPD 0.20.15

StringUtil.hxx
Go to the documentation of this file.
1 /*
2 * Copyright 2003-2017 The Music Player Daemon Project
3 * http://www.musicpd.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MPD_STRING_UTIL_HXX
21 #define MPD_STRING_UTIL_HXX
22
23 #include "Compiler.h"
24
25 #include <stddef.h>
26
35 gcc_nonnull_all
36 char *
37 CopyString(char *dest, const char *src, size_t size) noexcept;
38
43 gcc_pure
44 const char *
45 StripLeft(const char *p) noexcept;
46
47 gcc_pure
48 static inline char *
49 StripLeft(char *p) noexcept
50 {
51 return const_cast<char *>(StripLeft((const char *)p));
52 }
53
54 gcc_pure
55 const char *
56 StripLeft(const char *p, const char *end) noexcept;
57
61 gcc_pure
62 const char *
63 StripRight(const char *p, const char *end) noexcept;
64
68 gcc_pure
69 static inline char *
70 StripRight(char *p, char *end) noexcept
71 {
72 return const_cast<char *>(StripRight((const char *)p,
73 (const char *)end));
74 }
75
80 gcc_pure
81 size_t
82 StripRight(const char *p, size_t length) noexcept;
83
87 void
88 StripRight(char *p) noexcept;
89
94 char *
95 Strip(char *p) noexcept;
96
105 gcc_pure
106 bool
107 StringArrayContainsCase(const char *const*haystack,
108 const char *needle) noexcept;
109
115 void
116 ToUpperASCII(char *dest, const char *src, size_t size) noexcept;
117
118 #endif
CopyString
gcc_nonnull_all char * CopyString(char *dest, const char *src, size_t size) noexcept
Copy a string.
gcc_nonnull_all
#define gcc_nonnull_all
Definition: Compiler.h:122
ToUpperASCII
void ToUpperASCII(char *dest, const char *src, size_t size) noexcept
Convert the specified ASCII string (0x00..0x7f) to upper case.
StripLeft
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...
StripRight
gcc_pure const char * StripRight(const char *p, const char *end) noexcept
Determine the string&#39;s end as if it was stripped on the right side.
Compiler.h
Strip
char * Strip(char *p) noexcept
Skip whitespace at the beginning and terminate the string after the last non-whitespace character...
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
StringArrayContainsCase
gcc_pure bool StringArrayContainsCase(const char *const *haystack, const char *needle) noexcept
Checks whether a string array contains the specified string.