AISDatabaseParser.h

Go to the documentation of this file.
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 
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; // current state
00099         ParseState prev_state; // previous state
00100         int unknown_depth; // handle recursive unknown tags
00101 
00102         string error_msg; // Error message(s), if any.
00103 
00104         xmlParserCtxtPtr ctxt; // used for error msg line numbers
00105         AISResources *ais;  // dump info here
00106 
00107         string primary;  // current entry's primary URL/Regexp
00108         bool regexp;  // True if primary is a regexp
00109 
00110         ResourceVector rv; // add ancillary entries to 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

Generated on Wed Jun 27 12:56:38 2007 for libdap++ by  doxygen 1.4.7