X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Futils.cpp;fp=source%2Futils.cpp;h=baf1333138b82807864df7bb1f04ebc7365e3f33;hp=d67cc7e8bcd3947f62947be762af28aa60bf3f30;hb=f9e0275e476540c1b5d61c03a6a87d521856059b;hpb=f5aa787e1a715867a8024816ccd58e9a4c7e23a4 diff --git a/source/utils.cpp b/source/utils.cpp index d67cc7e..baf1333 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of libmspstrings -Copyright © 2006-2007 Mikko Rasa +Copyright © 2006-2008 Mikko Rasa Distributed under the LGPL */ @@ -46,6 +46,14 @@ vector do_split(const string &str, const string &sep, int max_split) return result; } +bool check_str(const std::string &str, int (*pred)(int)) +{ + for(string::const_iterator i=str.begin(); i!=str.end(); ++i) + if(!pred(*i)) + return false; + return true; +} + } namespace Msp { @@ -79,6 +87,21 @@ string toupper(const string &str) return result; } +bool isnumrc(const string &str) +{ + return check_str(str, isdigit); +} + +bool isalpha(const string &str) +{ + return check_str(str, isalpha); +} + +bool isalnum(const string &str) +{ + return check_str(str, isalnum); +} + vector split(const string &str, const string &sep, int max_split) { return do_split(str, sep, max_split);