all repos — fluxbox @ 7b059d2399956a7d9753c92d8df00f9b7b508201

custom fork of the fluxbox windowmanager

cleaning, added toUpper and findExtension
fluxgen fluxgen
commit

7b059d2399956a7d9753c92d8df00f9b7b508201

parent

6ec807a118c0c2ffede19ae93255fd221a0f99f9

1 files changed, 22 insertions(+), 9 deletions(-)

jump to
M src/FbTk/StringUtil.ccsrc/FbTk/StringUtil.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: StringUtil.cc,v 1.4 2003/08/10 12:50:04 rathnor Exp $ +// $Id: StringUtil.cc,v 1.5 2003/08/22 19:38:00 fluxgen Exp $ #include "StringUtil.hh"

@@ -29,6 +29,7 @@ #include <cstdlib>

#include <cctype> #include <cassert> #include <memory> +#include <algorithm> using namespace std;

@@ -88,6 +89,18 @@ return retval;

} /** +@return string from last "." to end of string +*/ +string findExtension(const std::string &filename) { + //get start of extension + std::string::size_type start_pos = filename.find_last_of("."); + if (start_pos == std::string::npos && start_pos != filename.size()) + return ""; + // return from last . to end of string + return filename.substr(start_pos + 1); +} + +/** Parses a string between "first" and "last" characters and ignoring ok_chars as whitespaces. The value is returned in "out".

@@ -146,16 +159,16 @@ //return value to last character

return (j+1+total_add); } -void toLower(char * const conv) { - for (size_t byte_pos = 0; byte_pos < strlen(conv); ++byte_pos) - conv[byte_pos] = tolower(conv[byte_pos]); +std::string toLower(const std::string &conv) { + std::string ret = conv; + std::transform(ret.begin(), ret.end(), ret.begin(), tolower); + return ret; } -std::string toLower(const std::string &conv) { - char ret_str[conv.size()+1]; - ::strcpy(ret_str, conv.c_str()); - toLower(ret_str); - return ret_str; +std::string toUpper(const std::string &conv) { + std::string ret = conv; + std::transform(ret.begin(), ret.end(), ret.begin(), toupper); + return ret; } }; // end namespace StringUtil