libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
D4FunctionEvaluator.h
Go to the documentation of this file.
1// -*- mode: c++; c-basic-offset:4 -*-
2
3// This file is part of libdap, A C++ implementation of the OPeNDAP Data
4// Access Protocol.
5
6// Copyright (c) 2014 OPeNDAP, Inc.
7// Author: James Gallagher <jgallagher@opendap.org>
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22//
23// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24
25#ifndef D4_FUNCTION_DRIVER_H_
26#define D4_FUNCTION_DRIVER_H_
27
28#include <stack>
29#include <string>
30#include <vector>
31
32namespace libdap {
33
34class location;
35
36class BaseType;
37class Array;
39
40class DMR;
41class D4Dimension;
42class D4RValue;
43class D4RValueList;
44
49 bool d_trace_scanning = false;
50 bool d_trace_parsing = false;
51 std::string d_expr;
52
53 DMR *d_dmr = nullptr;
54 ServerFunctionsList *d_sf_list = nullptr;
55
56 D4RValueList *d_result = nullptr;
57
58 std::stack<BaseType *> d_basetype_stack;
59
60 unsigned long long d_arg_length_hint = 0;
61
62 // d_expr should be set by parse! Its value is used by the parser right before
63 // the actual parsing operation starts. jhrg 11/26/13
64 std::string *expression() { return &d_expr; }
65
66 void push_basetype(BaseType *btp) { d_basetype_stack.push(btp); }
67 BaseType *top_basetype() const { return d_basetype_stack.empty() ? nullptr : d_basetype_stack.top(); }
68 void pop_basetype() { d_basetype_stack.pop(); }
69
70 D4RValue *build_rvalue(const std::string &id);
71
72 friend class D4FunctionParser;
73
74public:
77
78 virtual ~D4FunctionEvaluator() = default;
79
80 bool parse(const std::string &expr);
81
82 bool trace_scanning() const { return d_trace_scanning; }
83 void set_trace_scanning(bool ts) { d_trace_scanning = ts; }
84
85 bool trace_parsing() const { return d_trace_parsing; }
86 void set_trace_parsing(bool tp) { d_trace_parsing = tp; }
87
92 D4RValueList *result() const { return d_result; }
93 void set_result(D4RValueList *rv_list) { d_result = rv_list; }
94
95 void eval(DMR *dmr);
96
97 unsigned long long get_arg_length_hint() const { return d_arg_length_hint; }
98 void set_arg_length_hint(unsigned long long alh) { d_arg_length_hint = alh; }
99
100 DMR *dmr() const { return d_dmr; }
101 void set_dmr(DMR *dmr) { d_dmr = dmr; }
102
103 ServerFunctionsList *sf_list() const { return d_sf_list; }
105
106 template <typename t> std::vector<t> *init_arg_list(t val);
107
108 [[noreturn]] static void error(const libdap::location &l, const std::string &m);
109};
110
111} /* namespace libdap */
112#endif /* D4_FUNCTION_DRIVER_H_ */
A multidimensional array of identical data types.
Definition Array.h:121
The basic data type for the DODS DAP types.
Definition BaseType.h:118
ServerFunctionsList * sf_list() const
std::vector< t > * init_arg_list(t val)
static void error(const libdap::location &l, const std::string &m)
unsigned long long get_arg_length_hint() const
void set_result(D4RValueList *rv_list)
bool parse(const std::string &expr)
void set_sf_list(ServerFunctionsList *sf_list)
virtual ~D4FunctionEvaluator()=default
void set_arg_length_hint(unsigned long long alh)
D4FunctionEvaluator(DMR *dmr, ServerFunctionsList *sf_list)
D4RValueList * result() const
top level DAP object to house generic methods
Definition AISConnect.cc:30