libAlgAudio  v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rapidxml_algaudio.hpp
Go to the documentation of this file.
1 #ifndef RAPIDXML_ALGAUDIO_HPP
2 #define RAPIDXML_ALGAUDIO_HPP
3 /*
4 This file is part of AlgAudio.
5 
6 AlgAudio, Copyright (C) 2015 CeTA - Audiovisual Technology Center
7 
8 AlgAudio is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as
10 published by the Free Software Foundation, either version 3 of the
11 License, or (at your option) any later version.
12 
13 AlgAudio is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with AlgAudio. If not, see <http://www.gnu.org/licenses/>.
20 */
21 #include "rapidxml/rapidxml.hpp"
22 #include <iostream>
23 
24 namespace rapidxml{
25 
29 template<typename Ch>
30 void clone_node_copying(const xml_node<Ch> *source, xml_node<Ch> *dest, xml_document<>* target_doc)
31 {
32  // Target document
33  auto doc = target_doc;
34  if(!doc) std::cout << "WARNING: cloning an XML subtree to a destination with no parent document, crash likely!" << std::endl;
35  // Prepare result node
36  dest->remove_all_attributes();
37  dest->remove_all_nodes();
38  dest->type(source->type());
39 
40  // Clone name and value, copyin values.
41  dest->name(doc->allocate_string(source->name()), source->name_size());
42  dest->value(doc->allocate_string(source->value()), source->value_size());
43 
44  // Clone child nodes and attributes
45  for (xml_node<Ch> *child = source->first_node(); child; child = child->next_sibling()){
46  auto newnode = doc->allocate_node(child->type());
47  clone_node_copying(child, newnode, doc);
48  dest->append_node(newnode);
49  }
50  for (xml_attribute<Ch> *attr = source->first_attribute(); attr; attr = attr->next_attribute())
51  dest->append_attribute(doc->allocate_attribute(doc->allocate_string(attr->name()), doc->allocate_string(attr->value()), attr->name_size(), attr->value_size()));
52 }
53 
54 } // namespace rapidxml
55 
56 #endif // RAPIDXML_ALGAUDIO_HPP
void clone_node_copying(const xml_node< Ch > *source, xml_node< Ch > *dest, xml_document<> *target_doc)
Definition: rapidxml_algaudio.hpp:30
Definition: Module.hpp:37
Definition: Module.hpp:35