libdap  Updated for version 3.20.6
libdap4 is an implementation of OPeNDAP's DAP protocol.
AISDatabaseParser.h
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
5 // Access Protocol.
6 
7 // Copyright (c) 2003 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 #ifndef ais_database_parser_h
27 #define ais_database_parser_h
28 
29 #include <string>
30 
31 #include <libxml/parserInternals.h>
32 
33 #ifndef _internal_err_h
34 #include "InternalErr.h"
35 #endif
36 
37 #ifndef ais_exceptions_h
38 #include "AISExceptions.h"
39 #endif
40 
41 #ifndef ais_resources_h
42 #include "AISResources.h"
43 #endif
44 
45 namespace libdap
46 {
47 
70 {
71 private:
74  enum ParseState {
75  PARSER_START,
76  PARSER_FINISH,
77  AIS,
78  ENTRY,
79  PRIMARY,
80  ANCILLARY,
81  PARSER_UNKNOWN,
82  PARSER_ERROR
83  };
84 
99  struct AISParserState
100  {
101  ParseState state; // current state
102  ParseState prev_state; // previous state
103  int unknown_depth; // handle recursive unknown tags
104 
105  string error_msg; // Error message(s), if any.
106 
107  xmlParserCtxtPtr ctxt; // used for error msg line numbers
108  AISResources *ais; // dump info here
109 
110  string primary; // current entry's primary URL/Regexp
111  bool regexp; // True if primary is a regexp
112 
113  ResourceVector rv; // add ancillary entries to rv
114  };
115 
116 public:
117  void intern(const string &database, AISResources *ais);
118 
119  static void aisStartDocument(AISParserState *state);
120  static void aisEndDocument(AISParserState *state);
121  static void aisStartElement(AISParserState *state, const char *name,
122  const char **attrs);
123  static void aisEndElement(AISParserState *state, const char *name);
124  static xmlEntityPtr aisGetEntity(AISParserState *state,
125  const xmlChar *name);
126  static void aisWarning(AISParserState *state, const char *msg, ...);
127  static void aisError(AISParserState *state, const char *msg, ...);
128  static void aisFatalError(AISParserState *state, const char *msg, ...);
129 };
130 
131 } // namespace libdap
132 
133 #endif // ais_database_parser_h
static void aisFatalError(AISParserState *state, const char *msg,...)
static void aisWarning(AISParserState *state, const char *msg,...)
Manage AIS resources.
Definition: AISResources.h:70
void intern(const string &database, AISResources *ais)
static void aisStartElement(AISParserState *state, const char *name, const char **attrs)
static void aisError(AISParserState *state, const char *msg,...)
static void aisEndElement(AISParserState *state, const char *name)
static void aisStartDocument(AISParserState *state)
top level DAP object to house generic methods
Definition: AISConnect.cc:30
static void aisEndDocument(AISParserState *state)
static xmlEntityPtr aisGetEntity(AISParserState *state, const xmlChar *name)