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

« back to all changes in this revision

Viewing changes to engine/utilities/xmlutils.h

  • Committer: Package Import Robot
  • Author(s): Ben Burton
  • Date: 2011-09-10 07:17:25 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: package-import@ubuntu.com-20110910071725-97n90tywdq60w2cr
Tags: 4.90-1
* New upstream release!
* The user interface has been ported from KDE3 to KDE4 (closes: #556318).
  Re-enabled the GUI as a result.
* The build system has been ported from autotools to cmake.
* The new upstream release builds fine on amd64 (closes: #624882).
* Moved the users' handbook into regina-normal-doc.
* Upgraded several suggests/recommends.  Upgraded regina-normal-mpi to
  depend on mpi-default-bin, and regina-normal to depend on both graphviz
  and regina-normal-doc (which the GUI expends to be present).  Upgraded
  regina-normal to recommend gap.
* Bumped standards-version to 3.9.2.0 (no changes required).

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-2009, Ben Burton                                   *
 
7
 *  Copyright (c) 1999-2011, 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         *
26
26
 
27
27
/* end stub */
28
28
 
29
 
/*! \file xmlutils.h
 
29
/*! \file utilities/xmlutils.h
30
30
 *  \brief Various classes and routines for XML manipulation, some taken
31
31
 *  or modified from the libxml++ library.  The libxml2 library is used
32
32
 *  to do most of the underlying work.
40
40
#define __XMLUTILS_H
41
41
#endif
42
42
 
 
43
#include <map>
43
44
#include <string>
44
45
#include <sstream>
45
46
#include <libxml/parser.h>
 
47
#include "regina-core.h"
46
48
#include "utilities/nbooleans.h"
47
 
#include "utilities/hashmap.h"
48
 
#include "utilities/hashutils.h"
49
49
 
50
50
namespace regina {
51
51
 
66
66
class XMLParser;
67
67
 
68
68
/**
69
 
 * Represents a hashed map from property names to property values.
 
69
 * Represents a map from property names to property values.
70
70
 *
71
71
 * \ifacespython Not present.
72
72
 */
73
 
class XMLPropertyDict : public stdhash::hash_map<std::string,
74
 
        std::string, HashString> {
 
73
class REGINA_API XMLPropertyDict : private std::map<std::string, std::string> {
75
74
    public:
76
75
        /**
77
 
         * Create a new hashed map.
 
76
         * Create a new map.
78
77
         */
79
78
        XMLPropertyDict();
80
79
 
81
80
        /**
82
81
         * Return a value for the given key, even if the key does not
83
 
         * exist in the hashed map.
 
82
         * exist in the map.
84
83
         *
85
84
         * @param key the key to look up.
86
85
         * @param defaultVal the value to return if the key does not exist.
87
86
         * @return the value associated with the given key, or parameter
88
 
         * \a default if the key does not exist in the hashed map.
 
87
         * \a default if the key does not exist in the map.
89
88
         */
90
89
        const std::string& lookup(const std::string& key,
91
90
            const std::string& defaultVal = std::string()) const;
 
91
 
 
92
        using std::map<std::string, std::string>::const_iterator;
 
93
        using std::map<std::string, std::string>::begin;
 
94
        using std::map<std::string, std::string>::end;
 
95
        using std::map<std::string, std::string>::find;
 
96
        using std::map<std::string, std::string>::operator [];
92
97
};
93
98
 
94
99
/**
105
110
 * @author This class was taken and modified from the libxml++ library
106
111
 * (<tt>http://lusis.org/~ari/xml++/</tt>).
107
112
 */
108
 
class XMLParserCallback {
 
113
class REGINA_API XMLParserCallback {
109
114
    public:
110
115
        /**
111
116
         * Default destructor that does nothing.
126
131
         * Called when an element's opening tag is encountered.
127
132
         *
128
133
         * @param n the name of the tag.
129
 
         * @param p a hashed dictionary of all the properties of the tag.
 
134
         * @param p a dictionary of all the properties of the tag.
130
135
         */
131
136
        virtual void start_element(const std::string& n,
132
137
            const regina::xml::XMLPropertyDict& p);
190
195
 * @author This class was taken and modified from the libxml++ library
191
196
 * (<tt>http://lusis.org/~ari/xml++/</tt>).
192
197
 */
193
 
class XMLParser {
 
198
class REGINA_API XMLParser {
194
199
    private:
195
200
        XMLParserCallback& _parser_callback;
196
201
            /**< Provides the callback routines to use with this parser. */
291
296
 * @return the converted string with special characters replaced by
292
297
 * XML entities.
293
298
 */
294
 
std::string xmlEncodeSpecialChars(const std::string& original);
 
299
REGINA_API std::string xmlEncodeSpecialChars(const std::string& original);
295
300
 
296
301
/**
297
302
 * Returns the given string encoded so it is suitable for use inside an
305
310
 * changed.
306
311
 * @return the string converted to be usable inside an XML comment.
307
312
 */
308
 
std::string xmlEncodeComment(const std::string& comment);
 
313
REGINA_API std::string xmlEncodeComment(const std::string& comment);
309
314
 
310
315
/**
311
316
 * Returns an XML tag with a single property containing the given value.
395
400
}
396
401
 
397
402
inline void XMLParser::parse_chunk(const std::string& s) {
398
 
    xmlParseChunk(_context, s.c_str(), s.length(), 0);
 
403
    xmlParseChunk(_context, s.c_str(), static_cast<int>(s.length()), 0);
399
404
}
400
405
 
401
406
inline void XMLParser::finish() {