X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Futils.cpp;h=1feb08659bff1a54d0360ca196287af04919821b;hp=3ef7b797b5040c5cb8b6f6a545ec83d04b944fcb;hb=9da6abdcabec59f4845da256a8ad75a810ed1589;hpb=4ec2cf9b91a9918f02990c40145bb39a87b0e2bb diff --git a/source/utils.cpp b/source/utils.cpp index 3ef7b79..1feb086 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspstrings +Copyright © 2006-2007 Mikko Rasa +Distributed under the LGPL +*/ + #include #include "utils.h" @@ -33,7 +40,7 @@ Returns a lowercase copy of the given string. */ string tolower(const string &str) { - string result(str); + string result(str); transform(result.begin(), result.end(), result.begin(), ::tolower); return result; } @@ -43,7 +50,7 @@ Returns an uppercase copy of the given string. */ string toupper(const string &str) { - string result(str); + string result(str); transform(result.begin(), result.end(), result.begin(), ::toupper); return result; } @@ -59,23 +66,35 @@ Splits a string to parts. vector split(const string &str, const string &sep, bool allow_empty) { vector result; - unsigned start=str.find_first_not_of(sep); + + unsigned start=0; + if(!allow_empty) + start=str.find_first_not_of(sep); + while(start split(const string &str, char sep, bool allow_empty) { - return split(str, string(1,sep), allow_empty); + return split(str, string(1, sep), allow_empty); } /**