40#ifndef DRAIN_UTILS_XML
41#define DRAIN_UTILS_XML
69 void attribToStream(std::ostream &ostr,
const std::string & key,
const V &value){
73 static const std::map<char,char> keyMap = {
82 static const std::map<char,std::string> valueMap = {
83 {XML::entity_t::QUOTE,
"'"},
84 {XML::entity_t::LESS_THAN,
"(("},
85 {XML::entity_t::GREATER_THAN,
"))"},
106 assignNode(dst.data, src);
116 template <
typename TX>
118 TX &
assign(TX & dst,
const typename TX::xml_node_t & src){
119 assignNode(dst.data, src);
154 template <
typename T,
typename V>
165 template <
typename T>
168 T &
assign(T & tree, std::initializer_list<std::pair<const char *,const Variable> > l){
171 switch (tree->getType()){
173 for (
const auto & entry: l){
174 T & elem = tree[entry.first];
175 elem->setType(XML::STYLE_SELECT);
180 tree->setType(XML::STYLE_SELECT);
182 case XML::STYLE_SELECT:
198 template <
typename TX>
201 if (tree->isUndefined()){
202 tree->setType(XML::CTEXT);
208 template <
typename TX>
210 TX & appendString(TX & tree,
const std::string & s){
211 if (tree->isCText()){
215 else if (tree->isUndefined()){
216 tree->setType(XML::CTEXT);
223 TX & child = tree.addChild();
224 child->setType(XML::CTEXT);
236 template <
typename TX>
238 TX &
setType(TX & tree,
const typename TX::node_data_t::xml_tag_t & type){
249 template <
typename T>
252 typename T::node_data_t::xml_tag_t type = retrieveDefaultType(tree.data);
257 k << tree.getChildren().size();
258 return tree[k.str()](type);
261 template <
typename T>
263 T &
addChild(T & tree,
const std::string & key){
266 typename T::node_data_t::xml_tag_t type = xmlRetrieveDefaultType(tree.data);
267 return tree[key](type);
282 template <
typename N>
284 typename N::xml_tag_t retrieveDefaultType(
const N & parentNode){
285 typedef typename N::xml_default_elem_map_t map_t;
286 const typename map_t::const_iterator it = N::xml_default_elems.find(parentNode.getNativeType());
287 if (it != N::xml_default_elems.end()){
291 return static_cast<typename N::xml_tag_t
>(0);
Base class for XML "nodes", to be data elements T for drain::Tree<T>
Definition UtilsXML.h:61
static T & assign(T &tree, std::initializer_list< std::pair< const char *, const Variable > > l)
Tree.
Definition UtilsXML.h:168
static T & addChild(T &tree)
Definition UtilsXML.h:251
static T & assign(T &tree, const V &arg)
Assign tree node (data) to another.
Definition UtilsXML.h:156
static T & assign(T &dst, const T &src)
Assign another tree structure to another.
Definition UtilsXML.h:100
static TX & setType(TX &tree, const typename TX::node_data_t::xml_tag_t &type)
Definition UtilsXML.h:238
static TX & assign(TX &dst, const typename TX::xml_node_t &src)
Copy node data to tree.
Definition UtilsXML.h:118
static TX & assignString(TX &tree, const std::string &s)
When assigning a string, create new element unless the element itself is of type CTEXT.
Definition UtilsXML.h:200
Definition DataSelector.cpp:1277