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 <string_view>
11#include <map>
12#include <memory>
13
14class XMLCoreParser;
15class XMLCoreParserImpl;
16
18public:
19
20 virtual ~XMLCoreFactory();
21
22 void start (XMLCoreParser& parser, const XMLCoreNode& node);
23 void end (XMLCoreParser& parser, const XMLCoreNode& node);
24 void comment (XMLCoreParser& parser, const std::string& comment);
25
26 virtual void do_start (XMLCoreParser& parser, const XMLCoreNode& node);
27 virtual void do_end (XMLCoreParser& parser, const XMLCoreNode& node);
28 virtual void do_comment (XMLCoreParser& parser, const std::string& comment);
29
30 static bool has_attribute (const XMLCoreNode& node, const std::string& name);
31 static int get_int (const XMLCoreNode& node, const std::string& name);
32 static double get_double (const XMLCoreNode& node, const std::string& name);
33 static bool get_boolean (const XMLCoreNode& node, const std::string& name);
34 static std::string get_ID (const XMLCoreNode& node, const std::string& name);
35 static std::string get_value (const XMLCoreNode& node, const std::string& name);
36 static std::string get_token (const XMLCoreNode& node, const std::string& name);
37
38 static bool check_int (const int n, const XMLCoreNode& node, const std::string& name);
39 static bool check_double (const int n, const XMLCoreNode& node, const std::string& name);
40
41protected:
42
43 std::string m_xmlelementname;
44};
45
47public:
48
49 std::unique_ptr<XMLCoreNode> parse (std::string_view file_name);
50 std::unique_ptr<XMLCoreNode> parse_string (const std::string& text);
51 void visit (std::string_view file_name);
52
53 void register_default_factory (std::unique_ptr<XMLCoreFactory> factory);
54 void register_factory (const std::string& name,
55 std::unique_ptr<XMLCoreFactory> factory);
56 void register_external_entity (const std::string& name, const std::string& file_name);
57 void register_text_entity (const std::string& name, const std::string& text);
58
59 void up();
60 void down();
61 int level() const;
62
63
64private:
65
66 void visit (const XMLCoreNode& node);
67 void terminate ();
68 XMLCoreFactory* find_factory (const std::string& name);
69
70 typedef std::map <std::string, std::unique_ptr<XMLCoreFactory> > FactoryMap;
72 std::unique_ptr<XMLCoreFactory> m_default_factory;
73 int m_level = 0;
74};
75
76#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
FactoryMap m_factories
void terminate()
std::unique_ptr< XMLCoreNode > parse(std::string_view file_name)
void visit(std::string_view 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