35
/*! \file file/nxmlcallback.h
36
* \brief Deals with parsing XML program data at the file level.
39
#ifndef __NXMLCALLBACK_H
35
#ifndef __LEGACY_NXMLCALLBACK_H
41
#define __NXMLCALLBACK_H
46
#include "regina-core.h"
47
#include "file/nxmlelementreader.h"
57
* Provides the callbacks for an XMLParser required to parse an entire
58
* file using a series of NXMLElementReader objects.
59
* See the NXMLElementReader class notes for details of precisely how
60
* processing will take place.
62
* \ifacespython Not present.
64
class REGINA_API NXMLCallback : public regina::xml::XMLParserCallback {
66
static const int WAITING;
67
/**< Signifies that the top-level XML element has not yet been
69
static const int WORKING;
70
/**< Signifies that XML elements are currently being processed. */
71
static const int DONE;
72
/**< Signifies that processing of all XML elements has finished. */
73
static const int ABORTED;
74
/**< Signifies that XML processing was aborted. */
77
NXMLElementReader& topReader;
78
/**< The top-level element reader. */
79
std::stack<NXMLElementReader*> readers;
80
/**< A stack of all currently active element readers. */
81
std::ostream& errStream;
82
/**< The output stream to use for warning or error messages. */
83
std::string currChars;
84
/**< The initial characters that have currently been received
85
for the current deepest-level XML element. */
87
/**< \c true if and only if we have not yet finished
88
receiving initial characters for the current deepest-level
91
/**< The current state of this callback object; this will be
92
one of the state constants defined in this class. */
96
* Creates a new callback object.
98
* @param newTopReader the element reader to use for the
99
* top-level XML element. This is the only element reader that
100
* will not be destroyed once parsing has finished.
101
* @param newErrStream the output stream to which any warning or
102
* error messages should be sent.
104
NXMLCallback(NXMLElementReader& newTopReader,
105
std::ostream& newErrStream);
107
* Destroys this callback object. Any element reader (aside from
108
* the top-level reader) that has not yet been destroyed will
109
* have abort() called upon it and will be destroyed at this point.
111
virtual ~NXMLCallback();
114
* Returns the state that this callback object is currently in.
115
* The returned value will be one of the state constants defined
118
* @return the current state of this callback object.
120
int getState() const;
123
* Aborts processing of the XML file completely. The XMLParser
124
* may continue sending information but it will be completely
125
* ignored by this NXMLCallback object from this point onwards.
127
* All currently active readers will have
128
* NXMLElementReader::abort() called upon them and all except for
129
* the top-level reader will be destroyed.
133
virtual void start_document(regina::xml::XMLParser* parser);
134
virtual void end_document();
135
virtual void start_element(const std::string& n,
136
const regina::xml::XMLPropertyDict& p);
137
virtual void end_element(const std::string& n);
138
virtual void characters(const std::string& s);
139
virtual void warning(const std::string& s);
140
virtual void error(const std::string& s);
141
virtual void fatal_error(const std::string& s);
145
* Returns the element reader processing the deepest-level
146
* XML element that is currently being parsed.
148
* @return the current deepest element reader.
150
NXMLElementReader* currentReader();
155
// Inline functions for NXMLCallback
157
inline NXMLCallback::NXMLCallback(NXMLElementReader& newTopReader,
158
std::ostream& newErrStream) : topReader(newTopReader),
159
errStream(newErrStream), charsAreInitial(true), state(WAITING) {
162
inline NXMLElementReader* NXMLCallback::currentReader() {
163
return (readers.empty() ? &topReader : readers.top());
166
inline int NXMLCallback::getState() const {
170
} // namespace regina
37
#define __LEGACY_NXMLCALLBACK_H
40
#warning This header is deprecated; please use utilities/nxmlcallback.h instead.
42
#include "utilities/nxmlcallback.h"