~ubuntu-branches/ubuntu/vivid/regina-normal/vivid

« back to all changes in this revision

Viewing changes to engine/file/nxmlcallback.h

  • Committer: Package Import Robot
  • Author(s): Ben Burton
  • Date: 2014-08-29 17:37:46 UTC
  • mfrom: (19.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140829173746-igmqc9b67y366a7u
Tags: 4.96-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 *  Regina - A Normal Surface Theory Calculator                           *
5
5
 *  Computational Engine                                                  *
6
6
 *                                                                        *
7
 
 *  Copyright (c) 1999-2013, Ben Burton                                   *
 
7
 *  Copyright (c) 1999-2014, Ben Burton                                   *
8
8
 *  For further details contact Ben Burton (bab@debian.org).              *
9
9
 *                                                                        *
10
10
 *  This program is free software; you can redistribute it and/or         *
32
32
 
33
33
/* end stub */
34
34
 
35
 
/*! \file file/nxmlcallback.h
36
 
 *  \brief Deals with parsing XML program data at the file level.
37
 
 */
38
 
 
39
 
#ifndef __NXMLCALLBACK_H
 
35
#ifndef __LEGACY_NXMLCALLBACK_H
40
36
#ifndef __DOXYGEN
41
 
#define __NXMLCALLBACK_H
42
 
#endif
43
 
 
44
 
#include <iostream>
45
 
#include <stack>
46
 
#include "regina-core.h"
47
 
#include "file/nxmlelementreader.h"
48
 
 
49
 
namespace regina {
50
 
 
51
 
/**
52
 
 * \weakgroup file
53
 
 * @{
54
 
 */
55
 
 
56
 
/**
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.
61
 
 *
62
 
 * \ifacespython Not present.
63
 
 */
64
 
class REGINA_API NXMLCallback : public regina::xml::XMLParserCallback {
65
 
    public:
66
 
        static const int WAITING;
67
 
            /**< Signifies that the top-level XML element has not yet been
68
 
                 seen. */
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. */
75
 
 
76
 
    private:
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. */
86
 
        bool charsAreInitial;
87
 
            /**< \c true if and only if we have not yet finished
88
 
                 receiving initial characters for the current deepest-level
89
 
                 XML element. */
90
 
        int state;
91
 
            /**< The current state of this callback object; this will be
92
 
                 one of the state constants defined in this class. */
93
 
 
94
 
    public:
95
 
        /**
96
 
         * Creates a new callback object.
97
 
         *
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.
103
 
         */
104
 
        NXMLCallback(NXMLElementReader& newTopReader,
105
 
            std::ostream& newErrStream);
106
 
        /**
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.
110
 
         */
111
 
        virtual ~NXMLCallback();
112
 
 
113
 
        /**
114
 
         * Returns the state that this callback object is currently in.
115
 
         * The returned value will be one of the state constants defined
116
 
         * in this class.
117
 
         *
118
 
         * @return the current state of this callback object.
119
 
         */
120
 
        int getState() const;
121
 
 
122
 
        /**
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.
126
 
         *
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.
130
 
         */
131
 
        void abort();
132
 
 
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);
142
 
 
143
 
    private:
144
 
        /**
145
 
         * Returns the element reader processing the deepest-level
146
 
         * XML element that is currently being parsed.
147
 
         *
148
 
         * @return the current deepest element reader.
149
 
         */
150
 
        NXMLElementReader* currentReader();
151
 
};
152
 
 
153
 
/*@}*/
154
 
 
155
 
// Inline functions for NXMLCallback
156
 
 
157
 
inline NXMLCallback::NXMLCallback(NXMLElementReader& newTopReader,
158
 
        std::ostream& newErrStream) : topReader(newTopReader),
159
 
        errStream(newErrStream), charsAreInitial(true), state(WAITING) {
160
 
}
161
 
 
162
 
inline NXMLElementReader* NXMLCallback::currentReader() {
163
 
    return (readers.empty() ? &topReader : readers.top());
164
 
}
165
 
 
166
 
inline int NXMLCallback::getState() const {
167
 
    return state;
168
 
}
169
 
 
170
 
} // namespace regina
171
 
 
172
 
#endif
173
 
 
 
37
#define __LEGACY_NXMLCALLBACK_H
 
38
#endif
 
39
 
 
40
#warning This header is deprecated; please use utilities/nxmlcallback.h instead.
 
41
 
 
42
#include "utilities/nxmlcallback.h"
 
43
 
 
44
#endif