ATLAS Offline Software
ExpatCoreParser.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef XMLCOREPARSER_EXPATCOREPARSER_H
6 #define XMLCOREPARSER_EXPATCOREPARSER_H
7 
8 #include <expat.h>
9 #include <map>
10 #include <mutex>
11 #include <memory>
12 #include "DOMNode.h"
14 
16 {
17 public:
18 
19  typedef std::map <std::string, std::string> ExternalEntityMap;
20 
21  static std::unique_ptr<CoreParser::DOMNode> parse (const std::string& file_name);
22 
23  static void register_external_entity (const std::string& name, const std::string& file_name);
24  static void register_text_entity (const std::string& name, const std::string& text);
25 
26 private:
27 
28  ExpatCoreParser (const std::string& prefix);
29  void do_start (const char* el, const char** attr);
30  void do_end (const char* el);
31  void do_char_data (const XML_Char* s, int len);
32  void do_default_handler (const XML_Char* s, int len);
33  void do_comment (const XML_Char* s);
34  int generic_parse (XML_Parser p, const std::string& file_name);
35  int generic_text_parse (XML_Parser p, const std::string& text);
36  int do_external_entity (XML_Parser parser,
37  const XML_Char* context,
38  const XML_Char* systemId);
39 
40  static void start (void* /*user_data*/, const char* el, const char** attr);
41  static void end (void* /*user_data*/, const char* el);
42  static void char_data (void* /*user_data*/, const XML_Char* s, int len);
43  static void default_handler (void* /*user_data*/, const XML_Char* s, int len);
44  static void comment (void* /*userData*/, const XML_Char* s);
45  static int external_entity (XML_Parser parser,
46  const XML_Char* context,
47  const XML_Char* /*base*/,
48  const XML_Char* systemId,
49  const XML_Char* /*publicId*/);
50  static void entity (void* userData,
51  const XML_Char* entityName,
52  int is_parameter_entity,
53  const XML_Char* value,
54  int value_length,
55  const XML_Char* base,
56  const XML_Char* systemId,
57  const XML_Char* publicId,
58  const XML_Char* /*notationName*/);
59  std::unique_ptr<CoreParser::DOMNode> get_document ();
60 
61  static const std::string& find_external_entity (const std::string& name);
62  static const std::string& find_text_entity (const std::string& name);
63 
64  void clean ();
65 
66  std::unique_ptr<CoreParser::DOMNode> m_top;
68  std::string m_prefix;
69 
71  typedef std::lock_guard<std::mutex> lock_t;
73  static ExternalEntityMap s_text_entities ATLAS_THREAD_SAFE;
74 };
75 
76 #endif
77 
ExpatCoreParser::external_entity
static int external_entity(XML_Parser parser, const XML_Char *context, const XML_Char *, const XML_Char *systemId, const XML_Char *)
Definition: ExpatCoreParser.cxx:71
base
std::string base
Definition: hcg.cxx:78
python.CaloScaleNoiseConfig.parser
parser
Definition: CaloScaleNoiseConfig.py:75
ExpatCoreParser::find_external_entity
static const std::string & find_external_entity(const std::string &name)
Definition: ExpatCoreParser.cxx:393
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ExpatCoreParser::do_end
void do_end(const char *el)
Definition: ExpatCoreParser.cxx:166
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
ExpatCoreParser::do_external_entity
int do_external_entity(XML_Parser parser, const XML_Char *context, const XML_Char *systemId)
Definition: ExpatCoreParser.cxx:347
ExpatCoreParser::find_text_entity
static const std::string & find_text_entity(const std::string &name)
Definition: ExpatCoreParser.cxx:405
ExpatCoreParser::lock_t
std::lock_guard< std::mutex > lock_t
Definition: ExpatCoreParser.h:71
ExpatCoreParser::entity
static void entity(void *userData, const XML_Char *entityName, int is_parameter_entity, const XML_Char *value, int value_length, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId, const XML_Char *)
Definition: ExpatCoreParser.cxx:102
athena.value
value
Definition: athena.py:124
CoreParser::DOMNode
Definition: DOMNode.h:21
ExpatCoreParser::ExternalEntityMap
std::map< std::string, std::string > ExternalEntityMap
Definition: ExpatCoreParser.h:19
ExpatCoreParser::do_char_data
void do_char_data(const XML_Char *s, int len)
Definition: ExpatCoreParser.cxx:174
ExpatCoreParser::m_prefix
std::string m_prefix
Definition: ExpatCoreParser.h:68
ExpatCoreParser::end
static void end(void *, const char *el)
Definition: ExpatCoreParser.cxx:47
DOMNode.h
ExpatCoreParser::ExpatCoreParser
ExpatCoreParser(const std::string &prefix)
Definition: ExpatCoreParser.cxx:139
ExpatCoreParser
Definition: ExpatCoreParser.h:16
physics_parameters.file_name
string file_name
Definition: physics_parameters.py:32
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ExpatCoreParser::clean
void clean()
ExpatCoreParser::register_text_entity
static void register_text_entity(const std::string &name, const std::string &text)
Definition: ExpatCoreParser.cxx:92
ExpatCoreParser::do_comment
void do_comment(const XML_Char *s)
Definition: ExpatCoreParser.cxx:202
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
ExpatCoreParser::m_last
CoreParser::DOMNode * m_last
Definition: ExpatCoreParser.h:67
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
CaloCondBlobAlgs_fillNoiseFromASCII.systemId
systemId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
ExpatCoreParser::do_default_handler
void do_default_handler(const XML_Char *s, int len)
Definition: ExpatCoreParser.cxx:188
ExpatCoreParser::generic_parse
int generic_parse(XML_Parser p, const std::string &file_name)
Definition: ExpatCoreParser.cxx:217
ExpatCoreParser::get_document
std::unique_ptr< CoreParser::DOMNode > get_document()
Definition: ExpatCoreParser.cxx:135
ExpatCoreParser::start
static void start(void *, const char *el, const char **attr)
Definition: ExpatCoreParser.cxx:41
ExpatCoreParser::ATLAS_THREAD_SAFE
static ExternalEntityMap s_text_entities ATLAS_THREAD_SAFE
Definition: ExpatCoreParser.h:73
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ExpatCoreParser::char_data
static void char_data(void *, const XML_Char *s, int len)
Definition: ExpatCoreParser.cxx:53
ExpatCoreParser::ATLAS_THREAD_SAFE
static ExternalEntityMap s_entities ATLAS_THREAD_SAFE
Definition: ExpatCoreParser.h:72
ExpatCoreParser::default_handler
static void default_handler(void *, const XML_Char *s, int len)
Definition: ExpatCoreParser.cxx:59
ExpatCoreParser::do_start
void do_start(const char *el, const char **attr)
Definition: ExpatCoreParser.cxx:146
ExpatCoreParser::parse
static std::unique_ptr< CoreParser::DOMNode > parse(const std::string &file_name)
Definition: ExpatCoreParser.cxx:417
ExpatCoreParser::generic_text_parse
int generic_text_parse(XML_Parser p, const std::string &text)
Definition: ExpatCoreParser.cxx:317
ExpatCoreParser::s_mutex
static std::mutex s_mutex
Definition: ExpatCoreParser.h:70
ExpatCoreParser::comment
static void comment(void *, const XML_Char *s)
Definition: ExpatCoreParser.cxx:65
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
ExpatCoreParser::register_external_entity
static void register_external_entity(const std::string &name, const std::string &file_name)
Definition: ExpatCoreParser.cxx:82
checker_macros.h
Define macros for attributes used to control the static checker.
ExpatCoreParser::m_top
std::unique_ptr< CoreParser::DOMNode > m_top
Definition: ExpatCoreParser.h:66