Blame expr.h

Packit a4aae4
Packit a4aae4
// -*- mode: c++; c-basic-offset:4 -*-
Packit a4aae4
Packit a4aae4
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
Packit a4aae4
// Access Protocol.
Packit a4aae4
Packit a4aae4
// Copyright (c) 2002,2003 OPeNDAP, Inc.
Packit a4aae4
// Author: James Gallagher <jgallagher@opendap.org>
Packit a4aae4
//
Packit a4aae4
// This library is free software; you can redistribute it and/or
Packit a4aae4
// modify it under the terms of the GNU Lesser General Public
Packit a4aae4
// License as published by the Free Software Foundation; either
Packit a4aae4
// version 2.1 of the License, or (at your option) any later version.
Packit a4aae4
//
Packit a4aae4
// This library is distributed in the hope that it will be useful,
Packit a4aae4
// but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit a4aae4
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit a4aae4
// Lesser General Public License for more details.
Packit a4aae4
//
Packit a4aae4
// You should have received a copy of the GNU Lesser General Public
Packit a4aae4
// License along with this library; if not, write to the Free Software
Packit a4aae4
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit a4aae4
//
Packit a4aae4
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
Packit a4aae4
Packit a4aae4
// (c) COPYRIGHT URI/MIT 1995-1999
Packit a4aae4
// Please read the full copyright statement in the file COPYRIGHT_URI.
Packit a4aae4
//
Packit a4aae4
// Authors:
Packit a4aae4
//      jhrg,jimg       James Gallagher <jgallagher@gso.uri.edu>
Packit a4aae4
Packit a4aae4
// Types for the expr parser.
Packit a4aae4
//
Packit a4aae4
// 11/4/95 jhrg
Packit a4aae4
Packit a4aae4
#ifndef _expr_h
Packit a4aae4
#define _expr_h
Packit a4aae4
Packit a4aae4
#include <string>
Packit a4aae4
#include <vector>
Packit a4aae4
Packit a4aae4
#include <Type.h>
Packit a4aae4
Packit a4aae4
namespace libdap
Packit a4aae4
{
Packit a4aae4
Packit a4aae4
class BaseType;
Packit a4aae4
class DDS;
Packit a4aae4
class ConstraintEvaluator;
Packit a4aae4
Packit a4aae4
// VALUE is used to return constant values from the scanner to the parser.
Packit a4aae4
// Constants are packaged in BaseType *s for evaluation by the parser.
Packit a4aae4
Packit a4aae4
typedef struct
Packit a4aae4
{
Packit a4aae4
    Type type;   // Type is an enum defined in Type.h
Packit a4aae4
    union {
Packit a4aae4
        unsigned int ui;
Packit a4aae4
        int i;
Packit a4aae4
        double f;
Packit a4aae4
        std::string *s;
Packit a4aae4
    } v;
Packit a4aae4
} value;
Packit a4aae4
Packit a4aae4
// Syntactic sugar for `pointer to function returning boolean' (bool_func)
Packit a4aae4
// and `pointer to function returning BaseType *' (btp_func). Both function
Packit a4aae4
// types take four arguments, an integer (argc), a vector of BaseType *s
Packit a4aae4
// (argv), the DDS for the dataset for which these function is being
Packit a4aae4
// evaluated (analogous to the ENVP in UNIX) and a pointer for the function's
Packit a4aae4
// return value. ARGC is the length of ARGV.
Packit a4aae4
Packit a4aae4
typedef void (*bool_func)(int argc, BaseType *argv[], DDS &dds, bool *result);
Packit a4aae4
typedef void (*btp_func)(int argc, BaseType *argv[], DDS &dds, BaseType **btpp);
Packit a4aae4
Packit a4aae4
// Projection function: A function that appears in the projection part of the
Packit a4aae4
// CE and is executed for its side-effect. Usually adds a new variable to
Packit a4aae4
// the DDS. These are run _during the parse_ so their side-effects can be used
Packit a4aae4
// by subsequent parts of the CE.
Packit a4aae4
Packit a4aae4
typedef void (*proj_func)(int argc, BaseType *argv[], DDS &dds, ConstraintEvaluator &ce);
Packit a4aae4
Packit a4aae4
// INT_LIST and INT_LIST_LIST are used by the parser to store the array
Packit a4aae4
// indexes.
Packit a4aae4
Packit a4aae4
// To add the new feature of 'to the end' in an array projection (denoted using
Packit a4aae4
// start), I used the value -1 for an index. This makes do difference here. jhrg
Packit a4aae4
// 12/20/12
Packit a4aae4
Packit a4aae4
typedef std::vector<int> int_list;
Packit a4aae4
typedef std::vector<int>::const_iterator int_citer ;
Packit a4aae4
typedef std::vector<int>::iterator int_iter ;
Packit a4aae4
typedef std::vector<int_list *> int_list_list;
Packit a4aae4
typedef std::vector<int_list *>::const_iterator int_list_citer ;
Packit a4aae4
typedef std::vector<int_list *>::iterator int_list_iter ;
Packit a4aae4
Packit a4aae4
} // namespace libdap
Packit a4aae4
Packit a4aae4
#endif /* _expr_h */