00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef RAX_PARSER_H
00019 #define RAX_PARSER_H
00020
00021 #include <stack>
00022 #include <map>
00023
00024 #include "xercesc/sax/HandlerBase.hpp"
00025
00026 #include "askosdata/pointer.h"
00027
00028 #include "rax_handler.h"
00029
00030
00035 class RAX_Handler_Pointer : public Pointer<RAX_Handler> {
00036
00037 private:
00038
00039 static Pointer<RAX_Handler> default_handler;
00040
00041
00042
00043 public:
00044
00049 RAX_Handler_Pointer();
00050
00053 RAX_Handler_Pointer(const Pointer<RAX_Handler> handler);
00054
00057
00058
00059 };
00060
00061
00066 class RAX_Parser : private HandlerBase {
00067
00068 private:
00069
00070
00071 std::stack< std::map<std::string,RAX_Handler_Pointer> > handlers;
00072
00073 std::string collected_text;
00074
00075
00076
00077 std::stack<std::string> element_stack;
00078
00081 virtual void startElement(const XMLCh* const name, AttributeList& attributes);
00082
00085 virtual void endElement(const XMLCh* const name);
00086
00089 virtual void characters(const XMLCh* const chars, const unsigned int length);
00090
00095 virtual void warning(const SAXParseException& exception);
00096
00101 virtual void error(const SAXParseException& exception);
00102
00107 virtual void fatalError(const SAXParseException& exception);
00108
00111 void text(const std::string& name);
00112
00113 public:
00114
00117 static const std::string xmlch_to_string(const XMLCh* const name);
00118
00121 RAX_Parser();
00122
00134 virtual void start_element(const std::string& name, AttributeList& attributes);
00135
00145 virtual void end_element(const std::string& name);
00146
00158 virtual void text(const std::string& name, const std::string& t);
00159
00164 bool parse(const std::string& filename);
00165
00168 void push_handlers();
00169
00172 void pop_handlers();
00173
00176 void set_handler(const std::string& element_name, Pointer<RAX_Handler> handler);
00177
00180 virtual ~RAX_Parser();
00181
00182 };
00183
00184
00185 #endif // RAX_PARSER_H