MPD  0.20.18
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 
36 char *
37 CopyString(char *dest, const char *src, size_t size) noexcept;
38 
44 const char *
45 StripLeft(const char *p) noexcept;
46 
48 static inline char *
49 StripLeft(char *p) noexcept
50 {
51  return const_cast<char *>(StripLeft((const char *)p));
52 }
53 
55 const char *
56 StripLeft(const char *p, const char *end) noexcept;
57 
62 const char *
63 StripRight(const char *p, const char *end) noexcept;
64 
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 
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
gcc_nonnull_all char * CopyString(char *dest, const char *src, size_t size) noexcept
Copy a string.
#define gcc_nonnull_all
Definition: Compiler.h:122
void ToUpperASCII(char *dest, const char *src, size_t size) noexcept
Convert the specified ASCII string (0x00..0x7f) to upper case.
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...
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.
char * Strip(char *p) noexcept
Skip whitespace at the beginning and terminate the string after the last non-whitespace character...
#define gcc_pure
Definition: Compiler.h:116
gcc_pure bool StringArrayContainsCase(const char *const *haystack, const char *needle) noexcept
Checks whether a string array contains the specified string.