X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Frouter_flexml.cpp;h=fc3c6f02190686497c92b011b36b82e025966865;hb=63ea8aedbfd7dc56ab28dbc82c38b4458dcecb68;hp=47501df0ae101e2af7bcfa8ff08c2d35bc81cf6e;hpb=a7bb1a7f8f0c91fa5bc74f712b3e00cb962a0263;p=metaproxy-moved-to-github.git diff --git a/src/router_flexml.cpp b/src/router_flexml.cpp index 47501df..fc3c6f0 100644 --- a/src/router_flexml.cpp +++ b/src/router_flexml.cpp @@ -1,4 +1,4 @@ -/* $Id: router_flexml.cpp,v 1.6 2005-12-08 22:32:57 adam Exp $ +/* $Id: router_flexml.cpp,v 1.7 2006-01-04 11:19:04 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -6,6 +6,8 @@ #include "config.hpp" #include "router_flexml.hpp" +#include "filter_factory.hpp" +#include "factory_static.hpp" #include #include @@ -54,6 +56,7 @@ namespace yp2 { const xmlNode* jump_to_next(const xmlNode* node, int xml_node_type); const xmlNode* jump_to_children(const xmlNode* node, int xml_node_type); + FilterFactory m_factory; }; } @@ -139,6 +142,32 @@ void yp2::RouterFleXML::Rep::parse_xml_config_dom(xmlDocPtr doc) filter_nr++; std::cout << "processing /yp2/filters/filter[" << filter_nr << "]" << std::endl; + + const struct _xmlAttr *attr; + std::string id_value; + std::string type_value; + for (attr = node2->properties; attr; attr = attr->next) + { + std::string name = std::string((const char *) attr->name); + std::string value; + + if (attr->children && attr->children->type == XML_TEXT_NODE) + value = std::string((const char *)attr->children->content); + + if (name == "id") + id_value = value; + else if (name == "type") + type_value = value; + else + throw XMLError("Error. Only attribute id or type allowed in filter element. Got " + name); + + std::cout << "attr " << name << "=" << value << "\n"; + + //const xmlNode *val; + } + + yp2::filter::Base* filter_base = m_factory.create(type_value); + node2 = jump_to_next(node2, XML_ELEMENT_NODE); } @@ -193,6 +222,10 @@ yp2::RouterFleXML::Rep::Rep() : yp2::RouterFleXML::RouterFleXML(std::string xmlconf) : m_p(new Rep) { + { + yp2::FactoryStatic fs(m_p->m_factory); + } + LIBXML_TEST_VERSION; xmlDocPtr doc = xmlParseMemory(xmlconf.c_str(),