xmlinterface.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef mia_core_xmlinterface_hh
#define mia_core_xmlinterface_hh
#include <mia/core/defines.hh>
#include <memory>
#include <vector>
NS_MIA_BEGIN
class EXPORT_CORE CXMLDocument;
class EXPORT_CORE CXMLElement
{
public:
typedef std::shared_ptr<CXMLElement> Pointer;
CXMLElement(const char *name);
~CXMLElement();
// do not allow copying
CXMLElement(const CXMLElement& orig) = delete;
CXMLElement& operator = (const CXMLElement& orig) = delete;
CXMLElement::Pointer add_child(const char *name);
void set_attribute(const char *name, const std::string& value);
void set_child_text(const std::string& value);
const std::string& get_name() const;
const std::string get_attribute(const std::string& name) const;
const std::vector<CXMLElement::Pointer>& get_all_children() const;
std::vector<CXMLElement::Pointer> get_children(const char *name) const;
const std::string& get_content() const;
private:
struct CXMLElementImpl *impl;
friend CXMLElementImpl;
friend class CXMLDocument;
};
class EXPORT_CORE CXMLDocument
{
public:
CXMLDocument();
CXMLDocument(const char *init);
CXMLElement::Pointer create_root_node(const char *name);
CXMLElement::Pointer get_root_node() const;
bool read_from_string(const char *init);
std::string write_to_string(const char *encoding = NULL, bool formatted = true) const;
private:
friend class CXMLElement;
CXMLElement::Pointer m_root;
std::string m_last_error;
};
NS_MIA_END
#endif
CXMLDocument
facate for an XML document
Definition xmlinterface.hh:137
CXMLDocument::create_root_node
CXMLElement::Pointer create_root_node(const char *name)
CXMLDocument::read_from_string
bool read_from_string(const char *init)
CXMLDocument::CXMLDocument
CXMLDocument()
CXMLDocument::CXMLDocument
CXMLDocument(const char *init)
CXMLDocument::CXMLElement
friend class CXMLElement
Definition xmlinterface.hh:181
CXMLDocument::write_to_string
std::string write_to_string(const char *encoding=NULL, bool formatted=true) const
CXMLDocument::get_root_node
CXMLElement::Pointer get_root_node() const
CXMLElement::get_attribute
const std::string get_attribute(const std::string &name) const
CXMLElement::CXMLElement
CXMLElement(const char *name)
CXMLElement::CXMLElement
CXMLElement(const CXMLElement &orig)=delete
CXMLElement::~CXMLElement
~CXMLElement()
CXMLElement::get_children
std::vector< CXMLElement::Pointer > get_children(const char *name) const
CXMLElement::CXMLDocument
friend class CXMLDocument
Definition xmlinterface.hh:124
CXMLElement::set_child_text
void set_child_text(const std::string &value)
CXMLElement::get_content
const std::string & get_content() const
CXMLElement::set_attribute
void set_attribute(const char *name, const std::string &value)
Set an attribute of the node.
CXMLElement::add_child
CXMLElement::Pointer add_child(const char *name)
add a new child element
CXMLElement::Pointer
std::shared_ptr< CXMLElement > Pointer
Definition xmlinterface.hh:52
CXMLElement::get_all_children
const std::vector< CXMLElement::Pointer > & get_all_children() const
CXMLElement::get_name
const std::string & get_name() const
defines.hh
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
EXPORT_CORE
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition defines.hh:101
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36