2 #ifndef _LINKPARSERS_HXX_
3 #define _LINKPARSERS_HXX_
5 #include "parserBase.hxx"
6 #include "dataParsers.hxx"
7 #include "propertyParsers.hxx"
13 template <class T=mycontrol>
14 struct controltypeParser: parser
16 static controltypeParser<T> controlParser;
18 virtual void onStart(const XML_Char* el, const XML_Char** attr)
20 std::string element(el);
21 parser* pp=&parser::main_parser;
22 this->maxcount("fromnode",1,element);
23 this->maxcount("tonode",1,element);
24 if(element == "fromnode")pp=&stringtypeParser::stringParser;
25 else if(element == "tonode")pp=&stringtypeParser::stringParser;
26 this->SetUserDataAndPush(pp);
31 virtual void onEnd(const char *el,parser* child)
33 std::string element(el);
34 if(element == "fromnode")fromnode(((stringtypeParser*)child)->post());
35 else if(element == "tonode")tonode(((stringtypeParser*)child)->post());
41 virtual void fromnode (const std::string& name)
45 virtual void tonode (const std::string& name)
49 virtual void property (const myprop& prop)
51 DEBTRACE( "property_set: " << prop._name << prop._value )
52 _link.setProperty(prop._name,prop._value);
56 mincount("fromnode",1);
63 template <class T=mylink>
64 struct linktypeParser: controltypeParser<T>
66 static linktypeParser<T> linkParser;
68 virtual void onStart(const XML_Char* el, const XML_Char** attr)
70 std::string element(el);
71 this->maxcount("fromnode",1,element);
72 this->maxcount("tonode",1,element);
73 this->maxcount("fromport",1,element);
74 this->maxcount("toport",1,element);
75 parser* pp=&parser::main_parser;
76 if(element == "fromnode")pp=&stringtypeParser::stringParser;
77 else if(element == "tonode")pp=&stringtypeParser::stringParser;
78 else if(element == "toport")pp=&stringtypeParser::stringParser;
79 else if(element == "fromport")pp=&stringtypeParser::stringParser;
80 else if(element == "property")pp=&propertytypeParser::propertyParser;
81 this->SetUserDataAndPush(pp);
86 virtual void onEnd(const char *el,parser* child)
88 std::string element(el);
89 if(element == "fromnode")this->fromnode(((stringtypeParser*)child)->post());
90 else if(element == "tonode")this->tonode(((stringtypeParser*)child)->post());
91 else if(element == "toport")toport(((stringtypeParser*)child)->post());
92 else if(element == "fromport")fromport(((stringtypeParser*)child)->post());
93 else if(element == "property")this->property(((propertytypeParser*)child)->post());
95 virtual void buildAttr(const XML_Char** attr)
97 for (int i = 0; attr[i]; i += 2)
99 if((std::string(attr[i]) == "control")
100 && (std::string(attr[i+1]) == "false"))
101 this->_link._withControl=false;
104 virtual void fromport (const std::string& name)
106 this->_link.fromport(name);
108 virtual void toport (const std::string& name)
110 this->_link.toport(name);
114 this->mincount("fromnode",1);
115 this->mincount("tonode",1);
116 this->mincount("fromport",1);
117 this->mincount("toport",1);
122 template <class T=mystream>
123 struct streamtypeParser: linktypeParser<T>
125 static streamtypeParser<T> streamParser;
128 template <class T> streamtypeParser<T> streamtypeParser<T>::streamParser;
129 template <class T> controltypeParser<T> controltypeParser<T>::controlParser;
130 template <class T> linktypeParser<T> linktypeParser<T>::linkParser;