summaryrefslogtreecommitdiff
path: root/server/src/saxparser.h
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/saxparser.h')
-rw-r--r--server/src/saxparser.h44
1 files changed, 25 insertions, 19 deletions
diff --git a/server/src/saxparser.h b/server/src/saxparser.h
index 265727f..c303d41 100644
--- a/server/src/saxparser.h
+++ b/server/src/saxparser.h
@@ -31,6 +31,8 @@
#include <map>
#include <expat.h>
+typedef std::map< std::string, std::string> attributes_t;
+
/**
* This class implements a SAX Parser, utilising the eXpat XML parser library.
* It uses virtual methods for the callbacks, and transforms tagnames and
@@ -61,11 +63,11 @@ public:
/**
* Character data callback method.
* Reimplement this to get character callbacks.
- * This callback might be called several times, if a character block is big. In
- * that cae it might be nessecary to buffer to received bytes.
+ * This callback might be called several times, if a character block is big.
+ * In that cae it might be nessecary to buffer to received bytes.
* @param data A std::string containing the character data.
*/
- virtual void characterData(std::string &data) {}
+ virtual void characterData(std::string &data);
/**
* Start tag callback mehtod.
@@ -75,7 +77,7 @@ public:
* @param attributes A std::map of std::string to std::string containing all
* attributes for the tag.
*/
- virtual void startTag(std::string name, std::map< std::string, std::string> attributes) {}
+ virtual void startTag(std::string name, attributes_t &attr);
/**
* End tag callback mehtod.
@@ -83,19 +85,22 @@ public:
* It is called each time an end tag is seen.
* @param name A std::string containing the tag name.
*/
- virtual void endTag(std::string name) {}
+ virtual void endTag(std::string name);
/**
* Error callback method.
* Reimplement this to handle error messages.
- * A default implementation prints out the current buffer, linenumber and error
- * message to the screen.
+ * A default implementation prints out the current buffer, linenumber and
+ * error message to the screen.
* @param buf A char* containing the current buffer being parsed.
- * @param len A size_t containing the length of the current buffer being parsed.
+ * @param len A size_t containing the length of the current buffer being
+ * parsed.
* @param error A std::string containing the error message.
- * @param lineno An integer containing the line number on which the error occurred.
+ * @param lineno An integer containing the line number on which the error
+ * occurred.
*/
- virtual void parseError(const char *buf, size_t len, std::string error, int lineno);
+ virtual void parseError(const char *buf, size_t len, std::string error,
+ int lineno);
/**
* Buffer parse method.
@@ -111,10 +116,11 @@ public:
/**
* Get the number of bytes used from the last buffer.
- * If the buffer parse method is used, and the buffer comes from a stream of xml
- * doxuments, this method can be used to figure out how many bytes from the stream
- * should be replayed, to another parser.
- * @return an integer containing the number of bytes used from the last buffer.
+ * If the buffer parse method is used, and the buffer comes from a stream of
+ * xml doxuments, this method can be used to figure out how many bytes from
+ * the stream should be replayed, to another parser.
+ * @return an integer containing the number of bytes used from the last
+ * buffer.
* @see bool parse(char *buf, size_t size)
*/
unsigned int usedBytes();
@@ -129,13 +135,13 @@ protected:
* This method is used when the parse() method is used.
* It can be used to connect the parser with eg. a file.
* @param data A char* containing the buffer to be filled.
- * @param size A size_t containing the maximum number of bytes to be filled (ie.
- * the size of data)
- * @return An integer contaning the actual number of bytes filled. 0 if no more
- * bytes are available.
+ * @param size A size_t containing the maximum number of bytes to be filled
+ * (ie. the size of data)
+ * @return An integer contaning the actual number of bytes filled. 0 if no
+ * more bytes are available.
* @see int parse()
*/
- virtual int readData(char *data, size_t size) { return 0; }
+ virtual int readData(char *data, size_t size);
XML_Parser p;