37#ifndef DRAIN_UTILS_XML
38#define DRAIN_UTILS_XML
63 assignNode(dst.data, src);
73 template <
typename TX>
75 TX &
assign(TX & dst,
const typename TX::xml_node_t & src){
76 assignNode(dst.data, src);
85 template <
typename T,
typename V>
99 T &
assign(T & tree, std::initializer_list<std::pair<const char *,const Variable> > l){
102 switch (tree->getType()){
104 for (
const auto & entry: l){
105 T & elem = tree[entry.first];
106 elem->setType(XML::STYLE_SELECT);
111 tree->setType(XML::STYLE_SELECT);
113 case XML::STYLE_SELECT:
129 template <
typename TX>
132 if (tree->isUndefined()){
133 tree->setType(XML::CTEXT);
139 template <
typename TX>
141 TX & appendString(TX & tree,
const std::string & s){
142 if (tree->isCText()){
146 else if (tree->isUndefined()){
147 tree->setType(XML::CTEXT);
154 TX & child = tree.addChild();
155 child->setType(XML::CTEXT);
167 template <
typename TX>
169 TX &
setType(TX & tree,
const typename TX::node_data_t::xml_tag_t & type){
179 template <
typename N>
182 typedef typename N::xml_default_elem_map_t map_t;
183 const typename map_t::const_iterator it = N::xml_default_elems.find(parentNode.getNativeType());
184 if (it != N::xml_default_elems.end()){
188 return static_cast<typename N::xml_tag_t
>(0);
192 template <
typename T>
194 bool initChildWithDefaultType(
const T & tree, T & child){
196 if (
static_cast<int>(type) != 0){
197 child->setType(type);
Base class for XML "nodes", to be data elements T for drain::Tree<T>
Definition UtilsXML.h:46
static T & assign(T &tree, std::initializer_list< std::pair< const char *, const Variable > > l)
Tree.
Definition UtilsXML.h:99
static T & assign(T &tree, const V &arg)
Assign property to a XML tree node.
Definition UtilsXML.h:87
static T & assign(T &dst, const T &src)
Assign another tree structure to another.
Definition UtilsXML.h:57
static N::xml_tag_t retrieveDefaultType(const N &parentNode)
Find node type (tag id) from a predefined list of default types for (some) parent types.
Definition UtilsXML.h:181
static TX & setType(TX &tree, const typename TX::node_data_t::xml_tag_t &type)
Definition UtilsXML.h:169
static TX & assign(TX &dst, const typename TX::xml_node_t &src)
Copy node data to tree.
Definition UtilsXML.h:75
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:131
Definition DataSelector.cpp:1277