#pragma implementation
#endif
-#include <algorithm>
-
-#include <cctype>
-#include <cstdlib>
-
#include "LString.h"
#include "lstrings.h"
-#include "LRegex.h"
#include "LAssert.h"
#include "debug.h"
+#include <boost/regex.hpp>
+
+#include <algorithm>
+
+#include <cctype>
+#include <cstdlib>
+
using std::count;
using std::transform;
+using std::vector;
#ifndef CXX_GLOBAL_CSTD
+using std::atof;
+using std::isdigit;
+using std::strlen;
using std::tolower;
using std::toupper;
-using std::strlen;
#endif
string regex(pattern);
regex = subst(regex, ".", "\\.");
regex = subst(regex, "*", ".*");
- LRegex reg(regex);
- return reg.exact_match(a);
+ boost::regex reg(regex);
+ return boost::regex_match(a, reg);
}
}
return enc;
}
+
+
+/// gives a vector of stringparts which have the delimiter delim
+vector<string> const getVectorFromString(string const & str,
+ string const & delim)
+{
+ vector<string> vec;
+ if (str.empty())
+ return vec;
+ string keys(strip(str));
+ for(;;) {
+ string::size_type const idx = keys.find(delim);
+ if (idx == string::npos) {
+ vec.push_back(frontStrip(keys));
+ break;
+ }
+ string const key = strip(frontStrip(keys.substr(0, idx)));
+ if (!key.empty())
+ vec.push_back(key);
+ string::size_type const start = idx + delim.size();
+ keys = keys.substr(start);
+ }
+ return vec;
+}
+
+// the same vice versa
+string const getStringFromVector(vector<string> const & vec,
+ string const & delim)
+{
+ string str;
+ int i = 0;
+ for (vector<string>::const_iterator it = vec.begin();
+ it != vec.end(); ++it) {
+ string item = strip(frontStrip(*it));
+ if (item.empty()) continue;
+
+ if (i++ > 0) str += delim;
+ str += item;
+ }
+ return str;
+}