diff options
author | randomdan <randomdan@localhost> | 2010-06-13 15:25:33 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2010-06-13 15:25:33 +0000 |
commit | f0f3d94f3f7f606c8498611b9283a017222e4274 (patch) | |
tree | 4ba46bcd1157819425c4db45103dd734115e558d /project2/envproc.cpp | |
parent | Fix odbc select destructor when cursor not opened (diff) | |
download | project2-f0f3d94f3f7f606c8498611b9283a017222e4274.tar.bz2 project2-f0f3d94f3f7f606c8498611b9283a017222e4274.tar.xz project2-f0f3d94f3f7f606c8498611b9283a017222e4274.zip |
Add support for composing Glib::ustrings from columns
Break Project2 components down into generalised classes
Tidy up code
Diffstat (limited to 'project2/envproc.cpp')
-rw-r--r-- | project2/envproc.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/project2/envproc.cpp b/project2/envproc.cpp index be864a5..feb5ad1 100644 --- a/project2/envproc.cpp +++ b/project2/envproc.cpp @@ -17,25 +17,28 @@ EnvironmentProcessor::init() page = elems.size() > 0 ? elems[0] : "index"; } - -boost::shared_ptr<xmlpp::Document> -EnvironmentProcessor::process() const +void +EnvironmentProcessor::Initialise() { xmlpp::DomParser present("present/" + page + ".xml"); while (xmlXIncludeProcessFlags(present.get_document()->cobj(), XML_PARSE_NOXINCNODE) > 0); xmlpp::Element * presentRoot = present.get_document()->get_root_node(); + responseRootNodeName = presentRoot->get_attribute_value("root"); + responseStyle = presentRoot->get_attribute_value("style"); // Collect datasources - RdbmsDataSources rdbmsDataSources; - collectAll<_RdbmsDataSource>(rdbmsDataSources, presentRoot, "rdbmsdatasource", &_Project2SourceObject::name, true, true); + collectAll<_RdbmsDataSource>(datasources, presentRoot, "rdbmsdatasource", &_Project2SourceObject::name, true, true); // Collect views - SqlViews sqlViews; - collectAll<_SqlView>(sqlViews, presentRoot, "sqlview", &_SqlView::name, true, true); - // + collectAll<_SqlView>(views, presentRoot, "sqlview", &_SqlView::name, true, true); +} + +boost::shared_ptr<xmlpp::Document> +EnvironmentProcessor::process() const +{ boost::shared_ptr<xmlpp::Document> responseDoc = boost::shared_ptr<xmlpp::Document>(new xmlpp::Document("1.0")); - xmlpp::Element * responseRoot = responseDoc->create_root_node(presentRoot->get_attribute_value("root")); + xmlpp::Element * responseRoot = responseDoc->create_root_node(responseRootNodeName); try { - BOOST_FOREACH(SqlViews::value_type s, sqlViews) { - s.second->execute(rdbmsDataSources, responseRoot, this); + BOOST_FOREACH(Views::value_type s, views) { + s.second->execute(responseRoot, this); } } catch (...) { @@ -59,7 +62,7 @@ EnvironmentProcessor::process() const // XSLT Style char * buf; if (asprintf(&buf, "type=\"text/xsl\" href=\"%s\"", - presentRoot->get_attribute_value("style").c_str()) > 0) { + responseStyle.c_str()) > 0) { xmlAddPrevSibling(responseRoot->cobj(), xmlNewDocPI(responseDoc->cobj(), BAD_CAST "xml-stylesheet", BAD_CAST buf)); } |