μHAL (v2.7.9)
Part of the IPbus software repository
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 
47 #include "uhal/log/exception.hpp"
48 
49 
50 // Forward declarations
51 namespace pugi
52 {
53  class xml_node;
54  struct xml_parse_result;
55 }
56 
57 
58 namespace 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 , const char* aTarget );
100 
101 
109  template < bool DebugInfo >
110  bool GetXMLattribute ( const pugi::xml_node& aNode , const std::string& aAttrName , int32_t& aTarget );
111 
112 
120  template < bool DebugInfo >
121  bool GetXMLattribute ( const pugi::xml_node& aNode , const std::string& aAttrName , uint32_t& aTarget );
122 
123 
131  template < bool DebugInfo >
132  bool GetXMLattribute ( const pugi::xml_node& aNode , const std::string& aAttrName , double& aTarget );
133 
134 
142  template < bool DebugInfo >
143  bool GetXMLattribute ( const pugi::xml_node& aNode , const std::string& aAttrName , float& aTarget );
144 
145 
153  template < bool DebugInfo >
154  bool GetXMLattribute ( const pugi::xml_node& aNode , const std::string& aAttrName , bool& aTarget );
155 
156  }
157 }
158 
159 
160 #endif
UHAL_DEFINE_EXCEPTION_CLASS
#define UHAL_DEFINE_EXCEPTION_CLASS(ClassName, ClassDescription)
Definition: exception.hpp:59
uhal
Definition: HttpResponseGrammar.hpp:49
pugi::xml_node
Definition: pugixml.hpp:455
uhal::utilities::PugiXMLParseResultPrettifier
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
uhal::utilities::GetXMLattribute
bool GetXMLattribute(const pugi::xml_node &aNode, const std::string &aAttrName, bool &aTarget)
Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type.
Definition: xml.cpp:367
pugi
Definition: pugixml.hpp:124
exception.hpp
pugi::xml_parse_result
Definition: pugixml.hpp:979