libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
D4FilterClause.h
Go to the documentation of this file.
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) 2015 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 _d4_filter_clause_h
27#define _d4_filter_clause_h
28
29#include <cassert>
30#include <vector>
31
32#include "D4RValue.h"
33
34#include "ce_expr.tab.hh" // Use the same codes for D4 as we use in DAP2
35
36namespace libdap {
37
38class D4FilterClause;
39
45private:
46 std::vector<D4FilterClause *> d_clauses;
47
48 void m_duplicate(const D4FilterClauseList &src);
49
50public:
51 typedef std::vector<D4FilterClause *>::iterator iter;
52 typedef std::vector<D4FilterClause *>::const_iterator citer;
53
55 D4FilterClauseList(const D4FilterClauseList &src) { m_duplicate(src); }
56
58
59 virtual ~D4FilterClauseList();
60
62 if (this == &rhs)
63 return *this;
64
65 m_duplicate(rhs);
66
67 return *this;
68 }
69
70 void add_clause(D4FilterClause *c) { d_clauses.push_back(c); }
71
72 D4FilterClause *get_clause(unsigned int i) { return d_clauses.at(i); }
73
74 citer cbegin() const { return d_clauses.begin(); }
75 citer cend() const { return d_clauses.end(); }
76
77 unsigned int size() const { return d_clauses.size(); }
78
79 // get the clause value; this version supports functional clauses
80 bool value(DMR &dmr);
81
82 bool value();
83};
84
109class D4FilterClause {
110public:
111 enum ops {
112 // Stock relops
113 null = 0,
114 less = SCAN_LESS,
115 greater = SCAN_GREATER,
116 less_equal = SCAN_LESS_EQL,
117 greater_equal = SCAN_GREATER_EQL,
118 equal = SCAN_EQUAL,
119 not_equal = SCAN_NOT_EQUAL,
120 // Regex match for strings
121 match = SCAN_REGEXP,
122 // The mapping operator; not sure if this will be implemented
124 // No Data 'operator' for array filtering; may not be impl'd
126 };
127
128private:
130 ops d_op;
131
132 D4RValue *d_arg1, *d_arg2;
133
134 D4FilterClause() : d_op(null), d_arg1(0), d_arg2(0) {}
135
136 void m_duplicate(const D4FilterClause &rhs);
137
138 // These methods factor out first the first argument and then the
139 // second. I could write one really large cmp() for all of this...
140 // template<typename T> bool cmp(ops op, BaseType *arg1, T arg2);
141 bool cmp(ops op, BaseType *arg1, BaseType *arg2);
142
143 friend class D4FilterClauseList;
144
145public:
163 D4FilterClause(const ops op, D4RValue *arg1, D4RValue *arg2) : d_op(op), d_arg1(arg1), d_arg2(arg2) {
164 assert(op != null && "null operator");
165 assert(arg1 && "null arg1");
166 assert(arg2 && "null arg2");
167 }
168
169 D4FilterClause(const D4FilterClause &src) { m_duplicate(src); }
170
171 D4FilterClause &operator=(const D4FilterClause &rhs) {
172 if (this == &rhs)
173 return *this;
174
175 m_duplicate(rhs);
176
177 return *this;
178 }
179
180 virtual ~D4FilterClause() {
181 delete d_arg1;
182 delete d_arg2;
183 }
184
185 // get the clause value; this version supports functional clauses
186 bool value(DMR &dmr);
187
188 bool value();
189};
190
191} // namespace libdap
192
193#endif // _clause_h
std::vector< D4FilterClause * >::iterator iter
unsigned int size() const
std::vector< D4FilterClause * >::const_iterator citer
bool value()
Evaluate the list of clauses.
void add_clause(D4FilterClause *c)
D4FilterClauseList(const D4FilterClauseList &src)
D4FilterClauseList(D4FilterClause *c)
D4FilterClauseList & operator=(const D4FilterClauseList &rhs)
D4FilterClause * get_clause(unsigned int i)
DAP4 filter clauses.
friend class D4FilterClauseList
D4FilterClause & operator=(const D4FilterClause &rhs)
bool value()
Get the value of this relational expression. This version of value() will not work for clauses where ...
D4FilterClause(const D4FilterClause &src)
D4FilterClause(const ops op, D4RValue *arg1, D4RValue *arg2)
top level DAP object to house generic methods
Definition AISConnect.cc:30