diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2013-01-03 07:41:02 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2013-01-03 07:41:02 +0000 |
commit | 157ca678dee75e7881a0198425d0c8328f0bee04 (patch) | |
tree | 3c63c23b4948b2ee923c0b2027fbb5ac525a1b85 /sca-cpp/trunk/kernel/element.hpp | |
parent | 36adc76235fb0a38e7042bc751f988b71627e2a0 (diff) |
Improve handling of nested lists, trees, null and floating point values.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1428191 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/kernel/element.hpp')
-rw-r--r-- | sca-cpp/trunk/kernel/element.hpp | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/sca-cpp/trunk/kernel/element.hpp b/sca-cpp/trunk/kernel/element.hpp index 9ae1e632cb..d8907c8d21 100644 --- a/sca-cpp/trunk/kernel/element.hpp +++ b/sca-cpp/trunk/kernel/element.hpp @@ -228,33 +228,12 @@ inline const list<value> valuesToElements(const list<value>& l) { } /** - * Returns a selector lambda function which can be used to filter - * elements against the given element pattern. - */ -inline const lambda<const bool(const value&)> selector(const list<value>& select) { - return [select](const value& v) -> const bool { - const lambda<const bool(const list<value>&, const list<value>&)> evalSelect = [&evalSelect](const list<value>& s, const list<value>& v) -> const bool { - if (isNil(s)) - return true; - if (isNil(v)) - return false; - if (car(s) != car(v)) - return false; - return evalSelect(cdr(s), cdr(v)); - }; - if (!isList(v)) - return false; - return evalSelect(select, v); - }; -} - -/** * Returns the value of the attribute with the given name. */ -inline const value attributeValue(const value& name, const value& l) { +inline const value attributeValue(const value& name, const list<value>& l) { const list<value> f = filter<value>([name](const value& v) { return isAttribute(v) && attributeName((list<value>)v) == name; - }, list<value>(l)); + }, l); if (isNil(f)) return nilValue; return caddr<value>(car(f)); @@ -263,16 +242,16 @@ inline const value attributeValue(const value& name, const value& l) { /** * Returns child elements with the given name. */ -inline const value elementChildren(const value& name, const value& l) { +inline const list<value> elementChildren(const value& name, const list<value>& l) { return filter<value>([name](const value& v) { return isElement(v) && elementName((list<value>)v) == name; - }, list<value>(l)); + }, l); } /** * Return the child element with the given name. */ -inline const value elementChild(const value& name, const value& l) { +inline const value elementChild(const value& name, const list<value>& l) { const list<value> f = elementChildren(name, l); if (isNil(f)) return nilValue; |