μHAL (v2.6.5)
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  namespace utilities
67  {
68 
69 
76  void PugiXMLParseResultPrettifier ( const pugi::xml_parse_result& aLoadResult , const boost::filesystem::path& aPath , const std::vector<uint8_t>& aFile );
77 
78 
86  template < bool DebugInfo >
87  bool GetXMLattribute ( const pugi::xml_node& aNode , const char* aAttrName , std::string& aTarget );
88 
89 
97  template < bool DebugInfo >
98  bool GetXMLattribute ( const pugi::xml_node& aNode , const char* aAttrName , const char* aTarget );
99 
100 
108  template < bool DebugInfo >
109  bool GetXMLattribute ( const pugi::xml_node& aNode , const char* aAttrName , int32_t& aTarget );
110 
111 
119  template < bool DebugInfo >
120  bool GetXMLattribute ( const pugi::xml_node& aNode , const char* aAttrName , uint32_t& aTarget );
121 
122 
130  template < bool DebugInfo >
131  bool GetXMLattribute ( const pugi::xml_node& aNode , const char* aAttrName , double& aTarget );
132 
133 
141  template < bool DebugInfo >
142  bool GetXMLattribute ( const pugi::xml_node& aNode , const char* aAttrName , float& aTarget );
143 
144 
152  template < bool DebugInfo >
153  bool GetXMLattribute ( const pugi::xml_node& aNode , const char* aAttrName , bool& aTarget );
154 
155  }
156 }
157 
158 
159 #endif
bool GetXMLattribute(const pugi::xml_node &aNode, const char *aAttrName, bool &aTarget)
Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type...
Definition: xml.cpp:368
#define UHAL_DEFINE_EXCEPTION_CLASS(ClassName, ClassDescription)
Definition: exception.hpp:64
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