summaryrefslogtreecommitdiff
path: root/project2/variables.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/variables.cpp')
-rw-r--r--project2/variables.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/project2/variables.cpp b/project2/variables.cpp
index 07d30aa..a4a064f 100644
--- a/project2/variables.cpp
+++ b/project2/variables.cpp
@@ -143,8 +143,7 @@ class VariableParse : public VariableImplDyn, public RowUser {
VariableParse(const Glib::ustring & src) :
VariableImplDyn(src)
{
- boost::char_separator<char> sep(" ");
- boost::tokenizer<boost::char_separator<char> > tokens(source.raw(), sep);
+ boost::tokenizer<boost::char_separator<char> > tokens(source.raw(), boost::char_separator<char>(" "));
BOOST_FOREACH(std::string t, tokens) {
vars.push_back(Variable::create(t, this));
}
@@ -156,6 +155,7 @@ class VariableParse : public VariableImplDyn, public RowUser {
BOOST_FOREACH(Variable::VariableImplPtr vip, vars) {
len += vip->value().length() + 1;
}
+ cache.clear();
cache.reserve(len);
BOOST_FOREACH(Variable::VariableImplPtr v, vars) {
if (cache.length()) {
@@ -193,6 +193,9 @@ Variable::Variable(xmlpp::Element * e) :
Variable::VariableImplPtr
Variable::create(const Glib::ustring & s, RowUser * dep)
{
+ if (s.empty()) {
+ return VariableImplPtr(new VariableLiteral(s));
+ }
switch (s[0]) {
case '$': // param
return VariableImplPtr(new VariableParam(s));
@@ -203,9 +206,8 @@ Variable::create(const Glib::ustring & s, RowUser * dep)
case '/': // uri
return VariableImplPtr(new VariableUri(s));
case '*': // parser
- return VariableImplPtr(new VariableParse(s));
- case '=': // literal (explicit)
return VariableImplPtr(new VariableParse(s.substr(1)));
+ case '=': // literal (explicit)
default:
return VariableImplPtr(new VariableLiteral(s));
}