My Project
xmlinterface.hh
Go to the documentation of this file.
1/* -*- mia-c++ -*-
2 *
3 * This file is part of MIA - a toolbox for medical image analysis
4 * Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
5 *
6 * MIA is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21
22#ifndef mia_core_xmlinterface_hh
23#define mia_core_xmlinterface_hh
24
25#include <mia/core/defines.hh>
26#include <memory>
27#include <vector>
28
29
31
33
50{
51public:
52 typedef std::shared_ptr<CXMLElement> Pointer;
53
58 CXMLElement(const char *name);
59
61
62 // do not allow copying
63 CXMLElement(const CXMLElement& orig) = delete;
64 CXMLElement& operator = (const CXMLElement& orig) = delete;
65
76
84 void set_attribute(const char *name, const std::string& value);
85
90 void set_child_text(const std::string& value);
91
93 const std::string& get_name() const;
94
101 const std::string get_attribute(const std::string& name) const;
102
103
105
106 const std::vector<CXMLElement::Pointer>& get_all_children() const;
107
108
115 std::vector<CXMLElement::Pointer> get_children(const char *name) const;
116
118 const std::string& get_content() const;
119
120private:
121
122 struct CXMLElementImpl *impl;
123 friend CXMLElementImpl;
124 friend class CXMLDocument;
125};
126
127
137{
138public:
144
149 CXMLDocument(const char *init);
150
151
158
164
170 bool read_from_string(const char *init);
171
178 std::string write_to_string(const char *encoding = NULL, bool formatted = true) const;
179
180private:
181 friend class CXMLElement;
183
184 std::string m_last_error;
185};
186
188
189#endif
facate for an XML document
CXMLElement::Pointer create_root_node(const char *name)
bool read_from_string(const char *init)
CXMLDocument(const char *init)
std::string write_to_string(const char *encoding=NULL, bool formatted=true) const
CXMLElement::Pointer get_root_node() const
This class implements a facade for the xml Element.
const std::string get_attribute(const std::string &name) const
CXMLElement(const char *name)
CXMLElement(const CXMLElement &orig)=delete
std::vector< CXMLElement::Pointer > get_children(const char *name) const
void set_child_text(const std::string &value)
const std::string & get_content() const
void set_attribute(const char *name, const std::string &value)
Set an attribute of the node.
CXMLElement::Pointer add_child(const char *name)
add a new child element
std::shared_ptr< CXMLElement > Pointer
const std::vector< CXMLElement::Pointer > & get_all_children() const
const std::string & get_name() const
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition defines.hh:101
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36