summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/atom/atom.hpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-02 10:27:26 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-02 10:27:26 +0000
commit95fa76f5f3208d913320c13a05171ecdcd7134c2 (patch)
tree872e101cd2fb1505baf313940e48c6b615fd6725 /sca-cpp/trunk/modules/atom/atom.hpp
parent1d04916fda43146fb62488c20ba03b7b3006c8e9 (diff)
Performance improvements when running both in multi-threaded and pre-forked HTTPD. Changed memory management to use Apache APR pools instead of ref counting pointers as it's much faster and easier to integrate with the Python and Ruby interpreters. Changed to use simple pool-based string and stream implementations instead of the STL ones, which cause a lots of mutex locks in a multi-threaded environment. Added build options to compile with threading and profiling.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@895165 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/atom/atom.hpp')
-rw-r--r--sca-cpp/trunk/modules/atom/atom.hpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/sca-cpp/trunk/modules/atom/atom.hpp b/sca-cpp/trunk/modules/atom/atom.hpp
index 7e2eb66cd2..4dbf7c7728 100644
--- a/sca-cpp/trunk/modules/atom/atom.hpp
+++ b/sca-cpp/trunk/modules/atom/atom.hpp
@@ -26,7 +26,7 @@
* ATOM data conversion functions.
*/
-#include <string>
+#include "string.hpp"
#include "list.hpp"
#include "value.hpp"
#include "monad.hpp"
@@ -40,9 +40,9 @@ namespace atom {
*/
const list<value> entryValues(const list<value>& e) {
const list<value> lt = filter<value>(selector(mklist<value>(element, "title")), e);
- const value t = isNil(lt)? value(std::string("")) : elementValue(car(lt));
+ const value t = isNil(lt)? value(emptyString) : elementValue(car(lt));
const list<value> li = filter<value>(selector(mklist<value>(element, "id")), e);
- const value i = isNil(li)? value(std::string("")) : elementValue(car(li));
+ const value i = isNil(li)? value(emptyString) : elementValue(car(li));
const list<value> lc = filter<value>(selector(mklist<value>(element, "content")), e);
return mklist<value>(t, i, cadr(elementChildren(car(lc))));
}
@@ -59,10 +59,10 @@ const list<value> entriesValues(const list<value>& e) {
/**
* Convert a list of strings to a list of values representing an ATOM entry.
*/
-const failable<list<value>, std::string> readEntry(const list<std::string>& ilist) {
+const failable<list<value> > readEntry(const list<string>& ilist) {
const list<value> e = readXML(ilist);
if (isNil(e))
- return mkfailure<list<value>, std::string>("Empty entry");
+ return mkfailure<list<value> >("Empty entry");
return entryValues(car(e));
}
@@ -77,10 +77,10 @@ const value entryValue(const list<value>& e) {
/**
* Convert a list of strings to a list of values representing an ATOM feed.
*/
-const failable<list<value>, std::string> readFeed(const list<std::string>& ilist) {
+const failable<list<value> > readFeed(const list<string>& ilist) {
const list<value> f = readXML(ilist);
if (isNil(f))
- return mkfailure<list<value>, std::string>("Empty feed");
+ return mkfailure<list<value> >("Empty feed");
const list<value> t = filter<value>(selector(mklist<value>(element, "title")), car(f));
const list<value> i = filter<value>(selector(mklist<value>(element, "id")), car(f));
const list<value> e = filter<value>(selector(mklist<value>(element, "entry")), car(f));
@@ -95,11 +95,11 @@ const failable<list<value>, std::string> readFeed(const list<std::string>& ilist
*/
const list<value> entryElement(const list<value>& l) {
return list<value>()
- << element << "entry" << (list<value>() << attribute << "xmlns" << "http://www.w3.org/2005/Atom")
- << (list<value>() << element << "title" << (list<value>() << attribute << "type" << "text") << car(l))
- << (list<value>() << element << "id" << cadr(l))
- << (list<value>() << element << "content" << (list<value>() << attribute << "type" << "application/xml") << caddr(l))
- << (list<value>() << element << "link" << (list<value>() << attribute << "href" << cadr(l)));
+ + element + "entry" + (list<value>() + attribute + "xmlns" + "http://www.w3.org/2005/Atom")
+ + (list<value>() + element + "title" + (list<value>() + attribute + "type" + "text") + car(l))
+ + (list<value>() + element + "id" + cadr(l))
+ + (list<value>() + element + "content" + (list<value>() + attribute + "type" + "application/xml") + caddr(l))
+ + (list<value>() + element + "link" + (list<value>() + attribute + "href" + cadr(l)));
}
/**
@@ -115,26 +115,26 @@ const list<value> entriesElements(const list<value>& l) {
* Convert a list of values representing an ATOM entry to an ATOM entry.
* The first two values in the list are the entry id and title.
*/
-template<typename R> const failable<R, std::string> writeATOMEntry(const lambda<R(const std::string&, const R)>& reduce, const R& initial, const list<value>& l) {
+template<typename R> const failable<R> writeATOMEntry(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& l) {
return writeXML<R>(reduce, initial, mklist<value>(entryElement(l)));
}
-const failable<list<std::string>, std::string> writeATOMEntry(const list<value>& l) {
- const failable<list<std::string>, std::string> ls = writeATOMEntry<list<std::string> >(rcons<std::string>, list<std::string>(), l);
+const failable<list<string> > writeATOMEntry(const list<value>& l) {
+ const failable<list<string> > ls = writeATOMEntry<list<string> >(rcons<string>, list<string>(), l);
if (!hasContent(ls))
return ls;
- return reverse(list<std::string>(content(ls)));
+ return reverse(list<string>(content(ls)));
}
/**
* Convert a list of values representing an ATOM feed to an ATOM feed.
* The first two values in the list are the feed id and title.
*/
-template<typename R> const failable<R, std::string> writeATOMFeed(const lambda<R(const std::string&, const R)>& reduce, const R& initial, const list<value>& l) {
+template<typename R> const failable<R> writeATOMFeed(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& l) {
const list<value> f = list<value>()
- << element << "feed" << (list<value>() << attribute << "xmlns" << "http://www.w3.org/2005/Atom")
- << (list<value>() << element << "title" << (list<value>() << attribute << "type" << "text") << car(l))
- << (list<value>() << element << "id" << cadr(l));
+ + element + "feed" + (list<value>() + attribute + "xmlns" + "http://www.w3.org/2005/Atom")
+ + (list<value>() + element + "title" + (list<value>() + attribute + "type" + "text") + car(l))
+ + (list<value>() + element + "id" + cadr(l));
if (isNil(cddr(l)))
return writeXML<R>(reduce, initial, mklist<value>(f));
const list<value> fe = append(f, entriesElements(cddr(l)));
@@ -145,11 +145,11 @@ template<typename R> const failable<R, std::string> writeATOMFeed(const lambda<R
* Convert a list of values representing an ATOM feed to a list of strings.
* The first two values in the list are the feed id and title.
*/
-const failable<list<std::string>, std::string> writeATOMFeed(const list<value>& l) {
- const failable<list<std::string>, std::string> ls = writeATOMFeed<list<std::string> >(rcons<std::string>, list<std::string>(), l);
+const failable<list<string> > writeATOMFeed(const list<value>& l) {
+ const failable<list<string> > ls = writeATOMFeed<list<string>>(rcons<string>, list<string>(), l);
if (!hasContent(ls))
return ls;
- return reverse(list<std::string>(content(ls)));
+ return reverse(list<string>(content(ls)));
}
/**