ATLAS Offline Software
XMLCoreParser.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_hpp
6 #define XMLCoreParser_hpp
7 
8 #include <string>
9 #include <map>
10 #include <memory>
11 
12 class XMLCoreParser;
13 class XMLCoreParserImpl;
14 
15 namespace CoreParser
16 {
17  class DOMNode;
18 }
19 
21 {
22 public:
24  : m_node (node),
25  m_owns (false)
26  {
27  }
28 
29  XMLCoreNode (std::unique_ptr<CoreParser::DOMNode> node)
30  : m_node (node.release()),
31  m_owns (true)
32  {
33  }
34 
36  : m_node (other.m_node),
37  m_owns (false)
38  {
39  }
40 
42  : m_node (other.m_node),
44  {
45  other.m_node = nullptr;
46  other.m_owns = false;
47  }
48 
50 
52 
53  ~XMLCoreNode();
54 
55  operator const CoreParser::DOMNode& () const
56  {
57  return (*m_node);
58  }
59 
60  const CoreParser::DOMNode& get_node () const
61  {
62  return (*m_node);
63  }
64 
65 private:
67  bool m_owns;
68 };
69 
71 {
72 public:
73 
74  virtual ~XMLCoreFactory();
75 
76  void start (XMLCoreParser& parser, const XMLCoreNode& node);
77  void end (XMLCoreParser& parser, const XMLCoreNode& node);
78  void comment (XMLCoreParser& parser, const std::string& comment);
79 
80  virtual void do_start (XMLCoreParser& parser, const XMLCoreNode& node);
81  virtual void do_end (XMLCoreParser& parser, const XMLCoreNode& node);
82  virtual void do_comment (XMLCoreParser& parser, const std::string& comment);
83 
84  std::string get_name (const XMLCoreNode& node);
85  int sibling_number (const XMLCoreNode& node);
86 
87  static int attribute_number (const XMLCoreNode& node);
88 
89  static bool has_attribute (const XMLCoreNode& node, const std::string& name);
90  static int get_int (const XMLCoreNode& node, const std::string& name);
91  static double get_double (const XMLCoreNode& node, const std::string& name);
92  static bool get_boolean (const XMLCoreNode& node, const std::string& name);
93  static std::string get_ID (const XMLCoreNode& node, const std::string& name);
94  static std::string get_value (const XMLCoreNode& node, const std::string& name);
95  static std::string get_name (const XMLCoreNode& node, int index);
96  static std::string get_token (const XMLCoreNode& node, const std::string& name);
97 
98  static bool check_int (const int n, const XMLCoreNode& node, const std::string& name);
99  static bool check_double (const int n, const XMLCoreNode& node, const std::string& name);
100 
101 protected:
102 
103  std::string m_xmlelementname;
104 };
105 
107 {
108 public:
109 
110  XMLCoreParser ();
111  ~XMLCoreParser ();
112  void set_validation_scheme (const char* parm);
113  void set_do_namespaces ();
114  void set_do_schema ();
117  XMLCoreNode parse (const std::string& file_name);
118  void visit (const std::string& file_name);
119 
120  void register_default_factory (std::unique_ptr<XMLCoreFactory> factory);
121  void register_factory (const std::string& name,
122  std::unique_ptr<XMLCoreFactory> factory);
123  void register_external_entity (const std::string& name, const std::string& file_name);
124  void register_text_entity (const std::string& name, const std::string& text);
125 
126  void up();
127  void down();
128  int level() const;
129 
130 
131 private:
132 
133  void visit (const XMLCoreNode& node);
134  void terminate ();
135  XMLCoreFactory* find_factory (const std::string& name);
136 
137 
138  typedef std::map <std::string, std::unique_ptr<XMLCoreFactory> > FactoryMap;
140  std::unique_ptr<XMLCoreFactory> m_default_factory;
141  int m_level = 0;
142 };
143 
144 #endif
XMLCoreParser::find_factory
XMLCoreFactory * find_factory(const std::string &name)
Definition: XMLCoreParser.cxx:530
XMLCoreParser::parse
XMLCoreNode parse(const std::string &file_name)
Definition: XMLCoreParser.cxx:371
XMLCoreFactory::do_comment
virtual void do_comment(XMLCoreParser &parser, const std::string &comment)
Definition: XMLCoreParser.cxx:117
python.CaloScaleNoiseConfig.parser
parser
Definition: CaloScaleNoiseConfig.py:75
XMLCoreNode::XMLCoreNode
XMLCoreNode(const CoreParser::DOMNode *node)
Definition: XMLCoreParser.h:23
XMLCoreParser::terminate
void terminate()
XMLCoreNode::operator=
XMLCoreNode & operator=(const XMLCoreNode &other)
Definition: XMLCoreParser.cxx:29
index
Definition: index.py:1
XMLCoreFactory::has_attribute
static bool has_attribute(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:132
XMLCoreFactory::start
void start(XMLCoreParser &parser, const XMLCoreNode &node)
Definition: XMLCoreParser.cxx:71
CoreParser::DOMNode
Definition: DOMNode.h:21
XMLCoreFactory::get_int
static int get_int(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:142
XMLCoreNode::XMLCoreNode
XMLCoreNode(std::unique_ptr< CoreParser::DOMNode > node)
Definition: XMLCoreParser.h:29
XMLCoreFactory::get_boolean
static bool get_boolean(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:162
XMLCoreFactory::check_int
static bool check_int(const int n, const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:260
XMLCoreNode
Definition: XMLCoreParser.h:21
XMLCoreParser::register_text_entity
void register_text_entity(const std::string &name, const std::string &text)
Definition: XMLCoreParser.cxx:518
XMLCoreParser::m_level
int m_level
Definition: XMLCoreParser.h:141
XMLCoreParser::down
void down()
Definition: XMLCoreParser.cxx:547
physics_parameters.file_name
string file_name
Definition: physics_parameters.py:32
XMLCoreParser
Definition: XMLCoreParser.h:107
XMLCoreParser::set_validation_scheme
void set_validation_scheme(const char *parm)
Definition: XMLCoreParser.cxx:351
XMLCoreParser::m_default_factory
std::unique_ptr< XMLCoreFactory > m_default_factory
Definition: XMLCoreParser.h:140
XMLCoreNode::m_owns
bool m_owns
Definition: XMLCoreParser.h:67
beamspotman.n
n
Definition: beamspotman.py:731
XMLCoreFactory::get_value
static std::string get_value(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:180
XMLCoreFactory::attribute_number
static int attribute_number(const XMLCoreNode &node)
Definition: XMLCoreParser.cxx:125
XMLCoreFactory::do_start
virtual void do_start(XMLCoreParser &parser, const XMLCoreNode &node)
Definition: XMLCoreParser.cxx:101
XMLCoreParser::register_factory
void register_factory(const std::string &name, std::unique_ptr< XMLCoreFactory > factory)
Definition: XMLCoreParser.cxx:495
XMLCoreFactory::end
void end(XMLCoreParser &parser, const XMLCoreNode &node)
Definition: XMLCoreParser.cxx:81
XMLCoreFactory
Definition: XMLCoreParser.h:71
XMLCoreNode::XMLCoreNode
XMLCoreNode(const XMLCoreNode &other)
Definition: XMLCoreParser.h:35
XMLCoreNode::m_node
const CoreParser::DOMNode * m_node
Definition: XMLCoreParser.h:66
XMLCoreNode::XMLCoreNode
XMLCoreNode(XMLCoreNode &&other)
Definition: XMLCoreParser.h:41
XMLCoreParser::set_do_namespaces
void set_do_namespaces()
Definition: XMLCoreParser.cxx:355
XMLCoreFactory::check_double
static bool check_double(const int n, const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:299
python.EventInfoMgtInit.release
release
Definition: EventInfoMgtInit.py:24
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
XMLCoreParser::m_factories
FactoryMap m_factories
Definition: XMLCoreParser.h:139
XMLCoreFactory::get_ID
static std::string get_ID(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:173
XMLCoreParser::register_default_factory
void register_default_factory(std::unique_ptr< XMLCoreFactory > factory)
Definition: XMLCoreParser.cxx:490
XMLCoreParser::FactoryMap
std::map< std::string, std::unique_ptr< XMLCoreFactory > > FactoryMap
Definition: XMLCoreParser.h:138
XMLCoreFactory::m_xmlelementname
std::string m_xmlelementname
Definition: XMLCoreParser.h:103
XMLCoreParser::set_validation_schema_full_checking
void set_validation_schema_full_checking()
Definition: XMLCoreParser.cxx:363
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
XMLCoreParser::set_do_schema
void set_do_schema()
Definition: XMLCoreParser.cxx:359
XMLCoreParser::set_create_entity_reference_nodes
void set_create_entity_reference_nodes()
Definition: XMLCoreParser.cxx:367
XMLCoreFactory::~XMLCoreFactory
virtual ~XMLCoreFactory()
Definition: XMLCoreParser.cxx:63
XMLCoreNode::get_node
const CoreParser::DOMNode & get_node() const
Definition: XMLCoreParser.h:60
CoreParser
Definition: DOMNode.h:14
XMLCoreParser::register_external_entity
void register_external_entity(const std::string &name, const std::string &file_name)
Definition: XMLCoreParser.cxx:507
XMLCoreNode::~XMLCoreNode
~XMLCoreNode()
Definition: XMLCoreParser.cxx:51
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
XMLCoreParser::XMLCoreParser
XMLCoreParser()
Definition: XMLCoreParser.cxx:343
XMLCoreFactory::get_token
static std::string get_token(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:233
XMLCoreFactory::sibling_number
int sibling_number(const XMLCoreNode &node)
Definition: XMLCoreParser.cxx:210
XMLCoreParser::level
int level() const
Definition: XMLCoreParser.cxx:553
XMLCoreParser::~XMLCoreParser
~XMLCoreParser()
Definition: XMLCoreParser.cxx:347
XMLCoreFactory::get_name
std::string get_name(const XMLCoreNode &node)
Definition: XMLCoreParser.cxx:203
XMLCoreFactory::comment
void comment(XMLCoreParser &parser, const std::string &comment)
Definition: XMLCoreParser.cxx:91
XMLCoreFactory::get_double
static double get_double(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:152
XMLCoreParser::up
void up()
Definition: XMLCoreParser.cxx:541
XMLCoreParser::visit
void visit(const std::string &file_name)
Definition: XMLCoreParser.cxx:382
node
Definition: memory_hooks-stdcmalloc.h:74
XMLCoreFactory::do_end
virtual void do_end(XMLCoreParser &parser, const XMLCoreNode &node)
Definition: XMLCoreParser.cxx:109