aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
XmlDocument.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 by *
5
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
6
* - Christophe GONZALES(_at_AMU) *
7
* *
8
* The aGrUM/pyAgrum library is free software; you can redistribute it *
9
* and/or modify it under the terms of either : *
10
* *
11
* - the GNU Lesser General Public License as published by *
12
* the Free Software Foundation, either version 3 of the License, *
13
* or (at your option) any later version, *
14
* - the MIT license (MIT), *
15
* - or both in dual license, as here. *
16
* *
17
* (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18
* *
19
* This aGrUM/pyAgrum library is distributed in the hope that it will be *
20
* useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26
* OTHER DEALINGS IN THE SOFTWARE. *
27
* *
28
* See LICENCES for more details. *
29
* *
30
* SPDX-FileCopyrightText: Copyright 2005-2026 *
31
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
32
* - Christophe GONZALES(_at_AMU) *
33
* SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34
* *
35
* Contact : info_at_agrum_dot_org *
36
* homepage : http://agrum.gitlab.io *
37
* gitlab : https://gitlab.com/agrumery/agrum *
38
* *
39
****************************************************************************/
40
58
59
#ifndef GUM_XML_DOCUMENT_H
60
#define GUM_XML_DOCUMENT_H
61
62
#include <exception>
63
#include <memory>
64
#include <string>
65
#include <vector>
66
67
#include <agrum/config.h>
68
69
namespace
gum
{
70
72
class
GUM_PUBLIC_BN
XmlException
:
public
std::exception {
73
public
:
74
explicit
XmlException
(std::string message);
75
76
const
char
*
what
()
const
noexcept
override
;
77
78
private
:
79
std::string
_message_
;
80
};
81
89
class
GUM_PUBLIC_BN
XmlElement
{
90
public
:
91
XmlElement
() =
default
;
92
93
bool
isNull
() const noexcept {
return
_handle_
==
nullptr
; }
94
96
XmlElement
firstChildElement(
const
std::string& tag)
const
;
97
99
XmlElement
firstChildElement(
const
std::string& tag,
bool
throwIfNotFound)
const
;
100
102
std::vector< XmlElement > children(
const
std::string& tag)
const
;
103
104
std::string textOrDefault(
const
std::string&
defaultValue
)
const
;
105
107
std::string attribute(
const
std::string& name)
const
;
108
111
bool
attribute(
const
std::string& name, std::string* out,
bool
throwIfNotFound =
false
)
const
;
112
113
private
:
114
friend
class
XmlDocument
;
115
116
explicit
XmlElement
(
void
* ticppElement) noexcept :
_handle_
(ticppElement) {}
117
118
void
*
_handle_
=
nullptr
;
119
};
120
125
class
GUM_PUBLIC_BN
XmlDocument
{
126
public
:
127
XmlDocument
();
128
explicit
XmlDocument
(
const
std::string& filePath);
129
~XmlDocument
();
130
131
XmlDocument
(
XmlDocument
&&) noexcept;
132
XmlDocument
& operator=(
XmlDocument
&&) noexcept;
133
XmlDocument
(const
XmlDocument
&) = delete;
134
XmlDocument
& operator=(const
XmlDocument
&) = delete;
135
137
void
parse
(const
std
::
string
& content);
138
140
void
loadFile
();
141
142
bool
noChildren
() const;
143
145
XmlElement
firstChildElement
(const
std
::
string
& tag) const;
146
147
private:
148
struct
Impl
;
149
std
::unique_ptr<
Impl
>
_pimpl_
;
150
};
151
152
}
/* namespace gum */
153
154
#endif
// GUM_XML_DOCUMENT_H
gum::XmlDocument::XmlDocument
XmlDocument(XmlDocument &&) noexcept
gum::XmlDocument::firstChildElement
XmlElement firstChildElement(const std::string &tag) const
Definition
XmlDocument.cpp:133
gum::XmlDocument::_pimpl_
std::unique_ptr< Impl > _pimpl_
Definition
XmlDocument.h:149
gum::XmlDocument::~XmlDocument
~XmlDocument()
gum::XmlDocument::XmlDocument
XmlDocument()
Definition
XmlDocument.cpp:110
gum::XmlDocument::loadFile
void loadFile()
Loads the file passed to the constructor.
Definition
XmlDocument.cpp:125
gum::XmlDocument::parse
void parse(const std::string &content)
Definition
XmlDocument.cpp:119
gum::XmlDocument::noChildren
bool noChildren() const
Definition
XmlDocument.cpp:131
gum::XmlElement
A non-owning handle to an XML element, opaque over ticpp::Element.
Definition
XmlDocument.h:89
gum::XmlElement::_handle_
void * _handle_
opaque ticpp::Element*, never exposed
Definition
XmlDocument.h:118
gum::XmlElement::XmlElement
XmlElement()=default
gum::XmlElement::isNull
bool isNull() const noexcept
Definition
XmlDocument.h:93
gum::XmlElement::XmlElement
XmlElement(void *ticppElement) noexcept
Definition
XmlDocument.h:116
gum::XmlElement::XmlDocument
friend class XmlDocument
Definition
XmlDocument.h:114
gum::XmlException::_message_
std::string _message_
Definition
XmlDocument.h:79
gum::XmlException::XmlException
XmlException(std::string message)
Definition
XmlDocument.cpp:48
gum::XmlException::what
const char * what() const noexcept override
Definition
XmlDocument.cpp:50
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
gum::defaultValue
const float MultiDimFunctionGraph< float >::defaultValue
Definition
multiDimFunctionGraph.cpp:67
std
STL namespace.
gum::XmlDocument::Impl
Definition
XmlDocument.cpp:102
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0