00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ais_database_parser_h
00027 #define ais_database_parser_h
00028
00029 #include <string>
00030
00031 #include <libxml/parserInternals.h>
00032
00033 #ifndef _internal_err_h
00034 #include "InternalErr.h"
00035 #endif
00036
00037 #ifndef ais_exceptions_h
00038 #include "AISExceptions.h"
00039 #endif
00040
00041 #ifndef ais_resources_h
00042 #include "AISResources.h"
00043 #endif
00044
00066 class AISDatabaseParser
00067 {
00068 private:
00071 enum ParseState {
00072 PARSER_START,
00073 PARSER_FINISH,
00074 AIS,
00075 ENTRY,
00076 PRIMARY,
00077 ANCILLARY,
00078 PARSER_UNKNOWN,
00079 PARSER_ERROR
00080 };
00081
00096 struct AISParserState
00097 {
00098 ParseState state;
00099 ParseState prev_state;
00100 int unknown_depth;
00101
00102 string error_msg;
00103
00104 xmlParserCtxtPtr ctxt;
00105 AISResources *ais;
00106
00107 string primary;
00108 bool regexp;
00109
00110 ResourceVector rv;
00111 };
00112
00113 public:
00114 void intern(const string &database, AISResources *ais);
00115
00116 static void aisStartDocument(AISParserState *state);
00117 static void aisEndDocument(AISParserState *state);
00118 static void aisStartElement(AISParserState *state, const char *name,
00119 const char **attrs);
00120 static void aisEndElement(AISParserState *state, const char *name);
00121 static xmlEntityPtr aisGetEntity(AISParserState *state,
00122 const xmlChar *name);
00123 static void aisWarning(AISParserState *state, const char *msg, ...);
00124 static void aisError(AISParserState *state, const char *msg, ...);
00125 static void aisFatalError(AISParserState *state, const char *msg, ...);
00126 };
00127
00128 #endif // ais_database_parser_h