summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/scdl
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/modules/scdl')
-rw-r--r--sca-cpp/trunk/modules/scdl/scdl-test.cpp24
-rw-r--r--sca-cpp/trunk/modules/scdl/scdl.hpp29
2 files changed, 23 insertions, 30 deletions
diff --git a/sca-cpp/trunk/modules/scdl/scdl-test.cpp b/sca-cpp/trunk/modules/scdl/scdl-test.cpp
index 4c10f515df..9daacb5559 100644
--- a/sca-cpp/trunk/modules/scdl/scdl-test.cpp
+++ b/sca-cpp/trunk/modules/scdl/scdl-test.cpp
@@ -33,15 +33,15 @@
namespace tuscany {
namespace scdl {
-bool testComposite() {
+const bool testComposite() {
ifstream is("test.composite");
- const list<value> c = readXML(streamList(is));
+ const list<value> c = content(xml::readElements(streamList(is)));
return true;
}
-bool testComponents() {
+const bool testComponents() {
ifstream is("test.composite");
- const list<value> c = components(readXML(streamList(is)));
+ const list<value> c = components(content(xml::readElements(streamList(is))));
assert(length(c) == 4);
const value store = car(c);
@@ -58,9 +58,9 @@ bool testComponents() {
return true;
}
-bool testServices() {
+const bool testServices() {
ifstream is("test.composite");
- const list<value> c = components(readXML(streamList(is)));
+ const list<value> c = components(content(xml::readElements(streamList(is))));
const value store = car(c);
assert(length(services(store)) == 1);
@@ -74,9 +74,9 @@ bool testServices() {
return true;
}
-bool testReferences() {
+const bool testReferences() {
ifstream is("test.composite");
- const list<value> c = components(readXML(streamList(is)));
+ const list<value> c = components(content(xml::readElements(streamList(is))));
const value store = car(c);
assert(length(references(store)) == 3);
@@ -86,7 +86,7 @@ bool testReferences() {
assert(length(bindings(catalog)) == 1);
const value binding = car(bindings(catalog));
- assert(uri(binding) == value());
+ assert(uri(binding) == nilValue);
assert(bindingType(binding) == "binding.jsonrpc");
const list<value> t = mkbtree(sort(referenceToTargetAssoc(references(store))));
@@ -94,9 +94,9 @@ bool testReferences() {
return true;
}
-bool testProperties() {
+const bool testProperties() {
ifstream is("test.composite");
- const list<value> c = components(readXML(streamList(is)));
+ const list<value> c = components(content(xml::readElements(streamList(is))));
const value catalog = named(string("Catalog"), c);
assert(length(properties(catalog)) == 1);
@@ -110,7 +110,7 @@ bool testProperties() {
}
int main() {
- tuscany::gc_scoped_pool p;
+ const tuscany::gc_scoped_pool p;
tuscany::cout << "Testing..." << tuscany::endl;
tuscany::scdl::testComposite();
diff --git a/sca-cpp/trunk/modules/scdl/scdl.hpp b/sca-cpp/trunk/modules/scdl/scdl.hpp
index 7cf43e3b14..35a717d478 100644
--- a/sca-cpp/trunk/modules/scdl/scdl.hpp
+++ b/sca-cpp/trunk/modules/scdl/scdl.hpp
@@ -30,7 +30,7 @@
#include "list.hpp"
#include "value.hpp"
#include "monad.hpp"
-#include "xml.hpp"
+#include "../modules/xml/xml.hpp"
namespace tuscany {
namespace scdl {
@@ -82,33 +82,26 @@ const list<value> nameToElementAssoc(const list<value>& l) {
/**
* Returns the scdl declaration with the given name.
*/
-struct filterName {
- const value n;
- filterName(const value& n) : n(n) {
- }
- const bool operator()(const value& v) const {
+const value named(const value& n, const value& l) {
+ const vblambda filterName = [n](const value& v) -> const bool {
return name(v) == n;
- }
-};
-
-const value named(const value& name, const value& l) {
- const list<value> c = filter<value>(filterName(name), l);
+ };
+ const list<value> c = filter<value>(filterName, l);
if (isNil(c))
- return value();
+ return nilValue;
return car(c);
}
/**
* Returns the implementation of a component.
*/
-const bool filterImplementation(const value& v) {
- return isElement(v) && contains(string(cadr<value>(v)), "implementation.");
-}
-
const value implementation(const value& l) {
+ const vblambda filterImplementation = [](const value& v) -> const bool {
+ return isElement(v) && contains(string(cadr<value>(v)), "implementation.");
+ };
const list<value> n = filter<value>(filterImplementation, l);
if (isNil(n))
- return value();
+ return nilValue;
return car(n);
}
@@ -156,7 +149,7 @@ const list<value> bindings(const value& l) {
*/
const value bindingsTarget(const list<value>& l) {
if (isNil(l))
- return value();
+ return nilValue;
const value u = uri(car(l));
if (!isNil(u))
return u;