μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
xml.hpp
Go to the documentation of this file.
1/*
2---------------------------------------------------------------------------
3
4 This file is part of uHAL.
5
6 uHAL is a hardware access library and programming framework
7 originally developed for upgrades of the Level-1 trigger of the CMS
8 experiment at CERN.
9
10 uHAL is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14
15 uHAL is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with uHAL. If not, see <http://www.gnu.org/licenses/>.
22
23
24 Andrew Rose, Imperial College, London
25 email: awr01 <AT> imperial.ac.uk
26
27 Marc Magrans de Abril, CERN
28 email: marc.magrans.de.abril <AT> cern.ch
29
30 Tom Williams, Rutherford Appleton Laboratory, Oxfordshire
31 email: tom.williams <AT> cern.ch
32
33---------------------------------------------------------------------------
34*/
35
36
37#ifndef _uhal_utilities_xml_hpp_
38#define _uhal_utilities_xml_hpp_
39
40
41#include <stdint.h>
42#include <string>
43#include <vector>
44
45#include <boost/filesystem/path.hpp>
46
48
49
50// Forward declarations
51namespace pugi
52{
53 class xml_node;
54 struct xml_parse_result;
55}
56
57
58namespace uhal
59{
60 namespace exception
61 {
63 UHAL_DEFINE_EXCEPTION_CLASS ( StringNumberWillNotFitInto32BitNumber , "Exception class to handle the case where the string will not fit into a 32-bit number." )
64
65
66 UHAL_DEFINE_EXCEPTION_CLASS ( NodeAttributeIncorrectValue , "Exception class to handle the case when a node attribute has the incorrect value." )
67 }
68
69 namespace utilities
70 {
77 void PugiXMLParseResultPrettifier ( const pugi::xml_parse_result& aLoadResult , const boost::filesystem::path& aPath , const std::vector<uint8_t>& aFile );
78
79
87 template < bool DebugInfo >
88 bool GetXMLattribute ( const pugi::xml_node& aNode , const std::string& aAttrName , std::string& aTarget );
89
90
98 template < bool DebugInfo >
99 bool GetXMLattribute ( const pugi::xml_node& aNode , const std::string& aAttrName , int32_t& aTarget );
100
101
109 template < bool DebugInfo >
110 bool GetXMLattribute ( const pugi::xml_node& aNode , const std::string& aAttrName , uint32_t& aTarget );
111
112
120 template < bool DebugInfo >
121 bool GetXMLattribute ( const pugi::xml_node& aNode , const std::string& aAttrName , double& aTarget );
122
123
131 template < bool DebugInfo >
132 bool GetXMLattribute ( const pugi::xml_node& aNode , const std::string& aAttrName , float& aTarget );
133
134
142 template < bool DebugInfo >
143 bool GetXMLattribute ( const pugi::xml_node& aNode , const std::string& aAttrName , bool& aTarget );
144
145 }
146}
147
148
149#endif
Wrapper to generate a new Python exception type.
Definition: pybind11.h:2517
\rst Holds a reference to a Python object (no reference counting)
Definition: pytypes.h:194
#define UHAL_DEFINE_EXCEPTION_CLASS(ClassName, ClassDescription)
Definition: exception.hpp:59
bool GetXMLattribute(const pugi::xml_node &aNode, const std::string &aAttrName, std::string &aTarget)
Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type.
Definition: xml.cpp:116
void PugiXMLParseResultPrettifier(const pugi::xml_parse_result &aLoadResult, const boost::filesystem::path &aPath, const std::vector< uint8_t > &aFile)
Helper function to make debugging failures when parsing XML files easier.
Definition: xml.cpp:57