ATLAS Offline Software
Loading...
Searching...
No Matches
XMLCoreParser.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef XMLCoreParser_hpp
6#define XMLCoreParser_hpp
7
9#include <string>
10#include <map>
11#include <memory>
12
13class XMLCoreParser;
14class XMLCoreParserImpl;
15
17public:
18
19 virtual ~XMLCoreFactory();
20
21 void start (XMLCoreParser& parser, const XMLCoreNode& node);
22 void end (XMLCoreParser& parser, const XMLCoreNode& node);
23 void comment (XMLCoreParser& parser, const std::string& comment);
24
25 virtual void do_start (XMLCoreParser& parser, const XMLCoreNode& node);
26 virtual void do_end (XMLCoreParser& parser, const XMLCoreNode& node);
27 virtual void do_comment (XMLCoreParser& parser, const std::string& comment);
28
29 static bool has_attribute (const XMLCoreNode& node, const std::string& name);
30 static int get_int (const XMLCoreNode& node, const std::string& name);
31 static double get_double (const XMLCoreNode& node, const std::string& name);
32 static bool get_boolean (const XMLCoreNode& node, const std::string& name);
33 static std::string get_ID (const XMLCoreNode& node, const std::string& name);
34 static std::string get_value (const XMLCoreNode& node, const std::string& name);
35 static std::string get_token (const XMLCoreNode& node, const std::string& name);
36
37 static bool check_int (const int n, const XMLCoreNode& node, const std::string& name);
38 static bool check_double (const int n, const XMLCoreNode& node, const std::string& name);
39
40protected:
41
42 std::string m_xmlelementname;
43};
44
46public:
47
48 std::unique_ptr<XMLCoreNode> parse (const std::string& file_name);
49 std::unique_ptr<XMLCoreNode> parse_string (const std::string& text);
50 void visit (const std::string& file_name);
51
52 void register_default_factory (std::unique_ptr<XMLCoreFactory> factory);
53 void register_factory (const std::string& name,
54 std::unique_ptr<XMLCoreFactory> factory);
55 void register_external_entity (const std::string& name, const std::string& file_name);
56 void register_text_entity (const std::string& name, const std::string& text);
57
58 void up();
59 void down();
60 int level() const;
61
62
63private:
64
65 void visit (const XMLCoreNode& node);
66 void terminate ();
67 XMLCoreFactory* find_factory (const std::string& name);
68
69 typedef std::map <std::string, std::unique_ptr<XMLCoreFactory> > FactoryMap;
71 std::unique_ptr<XMLCoreFactory> m_default_factory;
72 int m_level = 0;
73};
74
75#endif
Simple DOM-like node structure to hold the result of XML parsing.
virtual void do_comment(XMLCoreParser &parser, const std::string &comment)
virtual void do_start(XMLCoreParser &parser, const XMLCoreNode &node)
static std::string get_value(const XMLCoreNode &node, const std::string &name)
void end(XMLCoreParser &parser, const XMLCoreNode &node)
static bool has_attribute(const XMLCoreNode &node, const std::string &name)
virtual ~XMLCoreFactory()
virtual void do_end(XMLCoreParser &parser, const XMLCoreNode &node)
static double get_double(const XMLCoreNode &node, const std::string &name)
static bool check_int(const int n, const XMLCoreNode &node, const std::string &name)
void comment(XMLCoreParser &parser, const std::string &comment)
static bool check_double(const int n, const XMLCoreNode &node, const std::string &name)
static int get_int(const XMLCoreNode &node, const std::string &name)
static std::string get_ID(const XMLCoreNode &node, const std::string &name)
void start(XMLCoreParser &parser, const XMLCoreNode &node)
static bool get_boolean(const XMLCoreNode &node, const std::string &name)
static std::string get_token(const XMLCoreNode &node, const std::string &name)
std::string m_xmlelementname
Simple DOM-like node structure to hold the result of XML parsing.
Definition XMLCoreNode.h:45
std::unique_ptr< XMLCoreFactory > m_default_factory
std::map< std::string, std::unique_ptr< XMLCoreFactory > > FactoryMap
int level() const
std::unique_ptr< XMLCoreNode > parse(const std::string &file_name)
FactoryMap m_factories
void terminate()
void visit(const std::string &file_name)
void register_factory(const std::string &name, std::unique_ptr< XMLCoreFactory > factory)
void register_text_entity(const std::string &name, const std::string &text)
void register_external_entity(const std::string &name, const std::string &file_name)
XMLCoreFactory * find_factory(const std::string &name)
std::unique_ptr< XMLCoreNode > parse_string(const std::string &text)
void register_default_factory(std::unique_ptr< XMLCoreFactory > factory)
Definition node.h:24