+ unsigned start=0;
+ while(start<str.size())
+ {
+ unsigned end=long_sep ? str.find(sep, start) : str.find_first_of(sep, start);
+ if(end!=start || allow_empty)
+ {
+ if(max_split>=0 && result.size()==static_cast<unsigned>(max_split))
+ {
+ result.push_back(str.substr(start));
+ break;
+ }
+ else
+ result.push_back(str.substr(start, end-start));
+ }
+
+ if(end>str.size())
+ break;
+
+ start=end+(long_sep ? sep.size() : 1);
+
+ if(allow_empty && start==str.size())
+ result.push_back(string());
+ }
+
+ 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 {