aboutsummaryrefslogtreecommitdiff
path: root/src/StringUtil.hh
diff options
context:
space:
mode:
authorunknown <unknown>2002-01-11 11:59:54 (GMT)
committerunknown <unknown>2002-01-11 11:59:54 (GMT)
commit61661d638e34b3ce6c986d5a53b8c08c1051d422 (patch)
treef0b87676e95070afee163f76902efd0c4d5b5fe6 /src/StringUtil.hh
parentf98c3c9045397bd9497621deb55b310366f8a5de (diff)
parenta3d2a1cf0a5ab724e19a91915fe97842f52260d5 (diff)
downloadfluxbox-61661d638e34b3ce6c986d5a53b8c08c1051d422.zip
fluxbox-61661d638e34b3ce6c986d5a53b8c08c1051d422.tar.bz2
This commit was manufactured by cvs2svn to create tagRelease-0_1_6
'Release-0_1_6'.
Diffstat (limited to 'src/StringUtil.hh')
-rw-r--r--src/StringUtil.hh77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/StringUtil.hh b/src/StringUtil.hh
new file mode 100644
index 0000000..59ce57c
--- /dev/null
+++ b/src/StringUtil.hh
@@ -0,0 +1,77 @@
1// StringUtil.hh for fluxbox
2// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22//$Id: StringUtil.hh,v 1.4 2002/01/09 14:11:20 fluxgen Exp $
23
24#ifndef _STRINGUTIL_HH_
25#define _STRINGUTIL_HH_
26
27#include <string>
28
29struct StringUtil
30{
31 static char *strdup(const char *);
32
33 //Similar to `strstr' but this function ignores the case of both strings
34 static const char *strcasestr(const char *str, const char *ptn);
35
36 static char *expandFilename(const char *filename);
37
38 //--------- stringtok ----------------------------------
39 // Breaks a string into tokens
40 // Usage check:
41 // http://gcc.gnu.org/onlinedocs/libstdc++/21_strings/howto.html#3
42 // Taken from an example at:
43 // http://gcc.gnu.org/onlinedocs/libstdc++/21_strings/stringtok_std_h.txt
44 //--------------------------------------------------
45 template <typename Container>
46 static void
47 stringtok (Container &container, std::string const &in,
48 const char * const delimiters = " \t\n")
49 {
50 const std::string::size_type len = in.length();
51 std::string::size_type i = 0;
52
53 while ( i < len ) {
54 // eat leading whitespace
55 i = in.find_first_not_of(delimiters, i);
56 if (i == std::string::npos)
57 return; // nothing left but white space
58
59 // find the end of the token
60 std::string::size_type j = in.find_first_of(delimiters, i);
61
62 // push token
63 if (j == std::string::npos) {
64 container.push_back(in.substr(i));
65 return;
66 } else
67 container.push_back(in.substr(i, j-i));
68
69 // set up for next loop
70 i = j + 1;
71 }
72 }
73};
74
75
76
77#endif // _STRINGUTIL_HH_