aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-22 19:38:00 (GMT)
committerfluxgen <fluxgen>2003-08-22 19:38:00 (GMT)
commit7b059d2399956a7d9753c92d8df00f9b7b508201 (patch)
treef2b5da9d96988db3b2b41325a359e60174db81bb /src
parent6ec807a118c0c2ffede19ae93255fd221a0f99f9 (diff)
downloadfluxbox_paul-7b059d2399956a7d9753c92d8df00f9b7b508201.zip
fluxbox_paul-7b059d2399956a7d9753c92d8df00f9b7b508201.tar.bz2
cleaning, added toUpper and findExtension
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/StringUtil.cc31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc
index 8532662..26dbb84 100644
--- a/src/FbTk/StringUtil.cc
+++ b/src/FbTk/StringUtil.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: StringUtil.cc,v 1.4 2003/08/10 12:50:04 rathnor Exp $ 22// $Id: StringUtil.cc,v 1.5 2003/08/22 19:38:00 fluxgen Exp $
23 23
24#include "StringUtil.hh" 24#include "StringUtil.hh"
25 25
@@ -29,6 +29,7 @@
29#include <cctype> 29#include <cctype>
30#include <cassert> 30#include <cassert>
31#include <memory> 31#include <memory>
32#include <algorithm>
32 33
33using namespace std; 34using namespace std;
34 35
@@ -88,6 +89,18 @@ string expandFilename(const std::string &filename) {
88} 89}
89 90
90/** 91/**
92@return string from last "." to end of string
93*/
94string findExtension(const std::string &filename) {
95 //get start of extension
96 std::string::size_type start_pos = filename.find_last_of(".");
97 if (start_pos == std::string::npos && start_pos != filename.size())
98 return "";
99 // return from last . to end of string
100 return filename.substr(start_pos + 1);
101}
102
103/**
91 Parses a string between "first" and "last" characters 104 Parses a string between "first" and "last" characters
92 and ignoring ok_chars as whitespaces. The value is 105 and ignoring ok_chars as whitespaces. The value is
93 returned in "out". 106 returned in "out".
@@ -146,16 +159,16 @@ int getStringBetween(std::string& out, const char *instr, const char first, cons
146 return (j+1+total_add); 159 return (j+1+total_add);
147} 160}
148 161
149void toLower(char * const conv) { 162std::string toLower(const std::string &conv) {
150 for (size_t byte_pos = 0; byte_pos < strlen(conv); ++byte_pos) 163 std::string ret = conv;
151 conv[byte_pos] = tolower(conv[byte_pos]); 164 std::transform(ret.begin(), ret.end(), ret.begin(), tolower);
165 return ret;
152} 166}
153 167
154std::string toLower(const std::string &conv) { 168std::string toUpper(const std::string &conv) {
155 char ret_str[conv.size()+1]; 169 std::string ret = conv;
156 ::strcpy(ret_str, conv.c_str()); 170 std::transform(ret.begin(), ret.end(), ret.begin(), toupper);
157 toLower(ret_str); 171 return ret;
158 return ret_str;
159} 172}
160 173
161}; // end namespace StringUtil 174}; // end namespace StringUtil