libdap++ Updated for version 3.8.2

parser.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) 2002,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 // (c) COPYRIGHT URI/MIT 1994-1999
00027 // Please read the full copyright statement in the file COPYRIGHT_URI.
00028 //
00029 // Authors:
00030 //      jhrg,jimg       James Gallagher <jgallagher@gso.uri.edu>
00031 
00032 // Constants, types and function prototypes for use with the DAP parsers.
00033 //
00034 // jhrg 2/3/96
00035 
00036 #ifndef _parser_h
00037 #define _parser_h
00038 
00039 #ifndef _error_h
00040 #include "Error.h"
00041 #endif
00042 
00043 #define YYDEBUG 1
00044 #undef YYERROR_VERBOSE
00045 #define YY_NO_UNPUT 1
00046 
00047 #define ID_MAX 256
00048 
00049 #ifndef TRUE
00050 #define TRUE 1
00051 #define FALSE 0
00052 #endif
00053 
00054 namespace libdap
00055 {
00056 
00068 struct parser_arg
00069 {
00070     void *_object;  // nominally a pointer to an object
00071     Error *_error;  // a pointer to an Error object
00072     int _status;  // parser status
00073 
00074     parser_arg() : _object(0), _error(0), _status(1)
00075     {}
00076     parser_arg(void *obj) : _object(obj), _error(0), _status(1)
00077     {}
00078     virtual ~parser_arg()
00079     {
00080         if (_error) {
00081             delete _error; _error = 0;
00082         }
00083     }
00084 
00085     void *object()
00086     {
00087         return _object;
00088     }
00089     void set_object(void *obj)
00090     {
00091         _object = obj;
00092     }
00093     Error *error()
00094     {
00095         return _error;
00096     }
00097     void set_error(Error *obj)
00098     {
00099         _error = obj;
00100     }
00101     int status()
00102     {
00103         return _status;
00104     }
00105     void set_status(int val = 0)
00106     {
00107         _status = val;
00108     }
00109 };
00110 
00130 void parse_error(parser_arg *arg, const char *s, const int line_num = 0,
00131                  const char *context = 0);
00132 void parse_error(const string &msg, const int line_num,
00133                  const char *context = 0);
00135 
00150 void save_str(char *dst, const char *src, const int line_num);
00151 void save_str(string &dst, const char *src, const int);
00152 
00153 bool is_keyword(string id, const string &keyword);
00154 
00166 int check_byte(const char *val);
00167 
00175 int check_int16(const char *val);
00176 int check_uint16(const char *val);
00177 int check_int32(const char *val);
00178 int check_uint32(const char *val);
00179 
00184 int check_float32(const char *val);
00185 int check_float64(const char *val);
00186 
00191 int check_url(const char *val);
00192 
00193 } // namespace libdap
00194 
00195 #endif // _parser_h
00196