-/* This file is part of
- * ======================================================
+/**
+ * \file lstrings.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * LyX, The Document Processor
+ * \author Lars Gullik Bjønnes
+ * \author Jean-Marc Lasgouttes
*
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2001 The LyX Team.
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS
+ */
#include <config.h>
#include "debug.h"
#include <boost/regex.hpp>
+#include <boost/tokenizer.hpp>
#include <algorithm>
string regex(pattern);
regex = subst(regex, ".", "\\.");
regex = subst(regex, "*", ".*");
- boost::regex reg(regex);
- return boost::regex_match(a, reg);
+ boost::regex reg(STRCONV(regex));
+ return boost::regex_match(STRCONV(a), reg);
}
vector<string> const getVectorFromString(string const & str,
string const & delim)
{
- vector<string> vec;
- if (str.empty())
+// Lars would like this code to go, but for now his replacement (below)
+// doesn't fullfil the same function. I have, therefore, reactivated the
+// old code for now. Angus 11 Nov 2002.
+#if 1
+ vector<string> vec;
+ if (str.empty())
+ return vec;
+ string keys(rtrim(str));
+ for(;;) {
+ string::size_type const idx = keys.find(delim);
+ if (idx == string::npos) {
+ vec.push_back(ltrim(keys));
+ break;
+ }
+ string const key = trim(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;
- string keys(rtrim(str));
- for(;;) {
- string::size_type const idx = keys.find(delim);
- if (idx == string::npos) {
- vec.push_back(ltrim(keys));
- break;
+#else
+ boost::char_separator<char> sep(delim.c_str());
+ boost::tokenizer<boost::char_separator<char> > tokens(str, sep);
+#ifndef USE_INCLUDED_STRING
+ return vector<string>(tokens.begin(), tokens.end());
+#else
+ vector<string> vec;
+ using boost::tokenizer;
+ using boost::char_separator;
+
+ tokenizer<char_separator<char> >::iterator it = tokens.begin();
+ tokenizer<char_separator<char> >::iterator end = tokens.end();
+ for (; it != end; ++it) {
+ vec.push_back(STRCONV((*it)));
}
- string const key = trim(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;
+ return vec;
+#endif
+#endif
}
+
// the same vice versa
string const getStringFromVector(vector<string> const & vec,
string const & delim)