UQTk: Uncertainty Quantification Toolkit 3.1.5
XMLExpatParser.h
Go to the documentation of this file.
1/* =====================================================================================
2
3 The UQ Toolkit (UQTk) version 3.1.5
4 Copyright (2024) NTESS
5 https://www.sandia.gov/UQToolkit/
6 https://github.com/sandialabs/UQTk
7
8 Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
9 Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government
10 retains certain rights in this software.
11
12 This file is part of The UQ Toolkit (UQTk)
13
14 UQTk is open source software: you can redistribute it and/or modify
15 it under the terms of BSD 3-Clause License
16
17 UQTk is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 BSD 3 Clause License for more details.
21
22 You should have received a copy of the BSD 3 Clause License
23 along with UQTk. If not, see https://choosealicense.com/licenses/bsd-3-clause/.
24
25 Questions? Contact the UQTk Developers at https://github.com/sandialabs/UQTk/discussions
26 Sandia National Laboratories, Livermore, CA, USA
27===================================================================================== */
28// -*- C++ -*-
29
30#ifndef _util_xml_class_XMLExpatParser_
31#define _util_xml_class_XMLExpatParser_
32
33#include "XMLParser.h"
34#include <iostream>
35#include <vector>
36#include <expat.h>
37
48class XMLExpatParser : public XMLParser {
49 template <class T> friend class RefPtr;
50 template <class T> friend class ConstRefPtr;
51public:
54
55private:
59
60public:
62 virtual ~XMLExpatParser() throw();
63
64private:
66 XMLExpatParser& operator=(const XMLExpatParser&);
67
68public:
70 RefPtr<XMLElement> parse(std::istream&);
71
72private:
74 XML_Parser parser_;
75
77 std::vector< RefPtr<XMLElement> > path_;
78
81
83 void do_start(const XML_Char*, const XML_Char**);
84
86 void do_end(const XML_Char*);
87
89 void do_character_data(const XML_Char*, int);
90
92 void init();
93
94public:
98 static void start_(void*, const XML_Char*, const XML_Char**);
99
103 static void end_(void*, const XML_Char*);
104
108 static void character_data_(void*, const XML_Char*, int);
109};
110
111#endif // _util_xml_class_XMLExpatParser_
Definition RefPtr.h:46
Definition XMLElement.h:58
Definition XMLExpatParser.h:48
void init()
Initialize the state of the parser.
Definition XMLExpatParser.cpp:191
static void start_(void *, const XML_Char *, const XML_Char **)
Definition XMLExpatParser.cpp:211
RefPtr< XMLElement > parse(std::istream &)
Parse the given input buffer and return a parse tree.
Definition XMLExpatParser.cpp:86
static void end_(void *, const XML_Char *)
Definition XMLExpatParser.cpp:221
void do_start(const XML_Char *, const XML_Char **)
The method used to parse the start tag.
Definition XMLExpatParser.cpp:129
void do_end(const XML_Char *)
The method used to parse the end tag.
Definition XMLExpatParser.cpp:152
static void character_data_(void *, const XML_Char *, int)
Definition XMLExpatParser.cpp:228
XML_Parser parser_
The Expat parser.
Definition XMLExpatParser.h:74
RefPtr< XMLElement > leaf_
The current leaf of the parse tree.
Definition XMLExpatParser.h:80
XMLExpatParser()
Construct a new parser.
Definition XMLExpatParser.cpp:51
friend class ConstRefPtr
Definition XMLExpatParser.h:50
std::vector< RefPtr< XMLElement > > path_
The path that we have traversed so far in building the tree.
Definition XMLExpatParser.h:77
void do_character_data(const XML_Char *, int)
The method used to parse character (content) data.
Definition XMLExpatParser.cpp:166
virtual ~XMLExpatParser()
Destructor.
Definition XMLExpatParser.cpp:69
Definition XMLParser.h:42