libdap++ Updated for version 3.8.2
|
00001 00002 // -*- mode: c++; c-basic-offset:4 -*- 00003 00004 // This file is part of libdap, A C++ implementation of the OPeNDAP Data 00005 // Access Protocol. 00006 00007 // Copyright (c) 2003 OPeNDAP, Inc. 00008 // Author: James Gallagher <jgallagher@opendap.org> 00009 // 00010 // This library is free software; you can redistribute it and/or 00011 // modify it under the terms of the GNU Lesser General Public 00012 // License as published by the Free Software Foundation; either 00013 // version 2.1 of the License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 // 00024 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112. 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; // current state 00102 ParseState prev_state; // previous state 00103 int unknown_depth; // handle recursive unknown tags 00104 00105 string error_msg; // Error message(s), if any. 00106 00107 xmlParserCtxtPtr ctxt; // used for error msg line numbers 00108 AISResources *ais; // dump info here 00109 00110 string primary; // current entry's primary URL/Regexp 00111 bool regexp; // True if primary is a regexp 00112 00113 ResourceVector rv; // add ancillary entries to 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 } // namespace libdap 00132 00133 #endif // ais_database_parser_h