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
00045 namespace libdap
00046 {
00047
00069 class AISDatabaseParser
00070 {
00071 private:
00074 enum ParseState {
00075 PARSER_START,
00076 PARSER_FINISH,
00077 AIS,
00078 ENTRY,
00079 PRIMARY,
00080 ANCILLARY,
00081 PARSER_UNKNOWN,
00082 PARSER_ERROR
00083 };
00084
00099 struct AISParserState
00100 {
00101 ParseState state;
00102 ParseState prev_state;
00103 int unknown_depth;
00104
00105 string error_msg;
00106
00107 xmlParserCtxtPtr ctxt;
00108 AISResources *ais;
00109
00110 string primary;
00111 bool regexp;
00112
00113 ResourceVector rv;
00114 };
00115
00116 public:
00117 void intern(const string &database, AISResources *ais);
00118
00119 static void aisStartDocument(AISParserState *state);
00120 static void aisEndDocument(AISParserState *state);
00121 static void aisStartElement(AISParserState *state, const char *name,
00122 const char **attrs);
00123 static void aisEndElement(AISParserState *state, const char *name);
00124 static xmlEntityPtr aisGetEntity(AISParserState *state,
00125 const xmlChar *name);
00126 static void aisWarning(AISParserState *state, const char *msg, ...);
00127 static void aisError(AISParserState *state, const char *msg, ...);
00128 static void aisFatalError(AISParserState *state, const char *msg, ...);
00129 };
00130
00131 }
00132
00133 #endif // ais_database_parser_h