parameterised NodeSetValue

This commit is contained in:
jez_higgins 2005-08-17 08:31:47 +00:00
parent 5bdf787880
commit 598647ddc7
4 changed files with 19 additions and 18 deletions

View file

@ -96,7 +96,7 @@ public:
{
NodeSet<std::string> nodes;
enumerateOver(context, nodes, executionContext);
return XPathValuePtr<std::string>(new NodeSetValue(nodes));
return XPathValuePtr<std::string>(new NodeSetValue<std::string, Arabica::default_string_adaptor<std::string> >(nodes));
} // evaluate
virtual XPathValuePtr<std::string> evaluate(NodeSet<std::string>& context, const ExecutionContext& executionContext) const
@ -104,7 +104,7 @@ public:
NodeSet<std::string> nodes;
for(NodeSet<std::string>::iterator n = context.begin(); n != context.end(); ++n)
enumerateOver(*n, nodes, executionContext);
return XPathValuePtr<std::string>(new NodeSetValue(nodes));
return XPathValuePtr<std::string>(new NodeSetValue<std::string, Arabica::default_string_adaptor<std::string> >(nodes));
} // evaluate
private:
@ -160,7 +160,7 @@ public:
return expr_->evaluate(context, executionContext);
NodeSet<std::string> ns = expr_->evaluate(context, executionContext)->asNodeSet();
return XPathValuePtr<std::string>(new NodeSetValue(applyPredicates(ns, executionContext)));
return XPathValuePtr<std::string>(new NodeSetValue<std::string, Arabica::default_string_adaptor<std::string> >(applyPredicates(ns, executionContext)));
} // evaluate
virtual XPathValuePtr<std::string> evaluate(NodeSet<std::string>& context, const ExecutionContext& executionContext) const
@ -387,7 +387,7 @@ public:
nodes = v->asNodeSet();
} // for ...
return XPathValuePtr<std::string>(new NodeSetValue(nodes));
return XPathValuePtr<std::string>(new NodeSetValue<std::string, Arabica::default_string_adaptor<std::string> >(nodes));
} // do_evaluate
private:

View file

@ -67,7 +67,7 @@ public:
private:
XPathValuePtr<string_type> wrap(const NodeSet<string_type>& ns) const
{
return XPathValuePtr<string_type>(new NodeSetValue(ns));
return XPathValuePtr<string_type>(new NodeSetValue<std::string, Arabica::default_string_adaptor<std::string> >(ns));
} // wrap
}; // UnionExpression

View file

@ -113,19 +113,20 @@ private:
string_type value_;
}; // class StringValue
class NodeSetValue : public XPathValue<std::string>, public XPathExpression<std::string>
template<class string_type, class string_adaptor>
class NodeSetValue : public XPathValue<string_type>, public XPathExpression<string_type>
{
public:
NodeSetValue(const NodeSet<std::string>& set) : set_(set) { }
NodeSetValue(const NodeSet<string_type>& set) : set_(set) { }
virtual XPathValuePtr<std::string> evaluate(const DOM::Node<std::string>& context, const ExecutionContext& executionContext) const
virtual XPathValuePtr<string_type> evaluate(const DOM::Node<string_type>& context, const ExecutionContext& executionContext) const
{
return XPathValuePtr<std::string>(this);
return XPathValuePtr<string_type>(this);
} // evaluate
virtual bool evaluateAsBool(const DOM::Node<std::string>& context) const{ return asBool(); }
virtual double evaluateAsNumber(const DOM::Node<std::string>& context) const { return asNumber(); }
virtual std::string evaluateAsString(const DOM::Node<std::string>& context) const { return asString(); }
virtual const NodeSet<std::string>& evaluateAsNodeSet() const { return asNodeSet(); }
virtual bool evaluateAsBool(const DOM::Node<string_type>& context) const{ return asBool(); }
virtual double evaluateAsNumber(const DOM::Node<string_type>& context) const { return asNumber(); }
virtual string_type evaluateAsString(const DOM::Node<string_type>& context) const { return asString(); }
virtual const NodeSet<string_type>& evaluateAsNodeSet() const { return asNodeSet(); }
virtual bool asBool() const
{
@ -135,16 +136,16 @@ public:
{
return stringAsNumber(asString());
} // asNumber
virtual std::string asString() const
virtual string_type asString() const
{
return !set_.empty() ? nodeStringValue(set_.top()) : "";
return !set_.empty() ? nodeStringValue(set_.top()) : string_adaptor().makeStringT("");
} // asStringx
virtual const NodeSet<std::string>& asNodeSet() const { return set_; }
virtual const NodeSet<string_type>& asNodeSet() const { return set_; }
virtual ValueType type() const { return NODE_SET; }
private:
NodeSet<std::string> set_;
NodeSet<string_type> set_;
}; // NodeSetValue
} // namespace XPath

View file

@ -39,7 +39,7 @@ public:
VarMap::const_iterator n = map_.find(name);
if(n == map_.end())
throw UnboundVariableException(name);
return XPathValuePtr<std::string>(new NodeSetValue((*n).second));
return XPathValuePtr<std::string>(new NodeSetValue<std::string, Arabica::default_string_adaptor<std::string> >((*n).second));
} // resolveVariable
void setVariable(const std::string& name, const NodeSet<std::string>& value)