libdap
Updated for version 3.20.3
libdap4 is an implementation of OPeNDAP's DAP protocol.
|
29 #include "ServerFunctionsList.h"
30 #include "ConstraintEvaluator.h"
34 #include "ce_parser.h"
39 struct yy_buffer_state;
44 void ce_expr_switch_to_buffer(
void *new_buffer);
45 void ce_expr_delete_buffer(
void * buffer);
46 void *ce_expr_string(
const char *yy_str);
48 extern int ce_exprdebug;
52 ConstraintEvaluator::ConstraintEvaluator()
61 d_functions_list = ServerFunctionsList::TheList();
64 ConstraintEvaluator::~ConstraintEvaluator()
67 for (Constants_iter j = constants.begin(); j != constants.end(); j++) {
73 for (Clause_iter k = expr.begin(); k != expr.end(); k++) {
98 throw InternalErr(__FILE__, __LINE__,
"There are no CE clauses for *this* DDS object.");
100 return (*iter)->value(dds);
119 expr.push_back(clause);
135 expr.push_back(clause);
151 expr.push_back(clause);
163 constants.push_back(btp);
208 if (expr.size() != 1)
209 throw InternalErr(__FILE__, __LINE__,
"The length of the list of CE clauses is not 1.");
213 if (cp->
value(dds, &result))
233 for (
unsigned int i = 0; i < expr.size(); ++i) {
261 throw InternalErr(__FILE__, __LINE__,
"The constraint expression is empty.");
264 for (
unsigned int i = 0; i < expr.size(); ++i) {
267 if (cp->
value(dds, &result)) {
274 throw Error(internal_error,
"A function was called but failed to return a value.");
290 throw InternalErr(__FILE__, __LINE__,
"The constraint expression is empty.");
295 for (
unsigned int i = 0; i < expr.size(); ++i) {
298 if (cp->
value(dds, &result)) {
303 throw Error(internal_error,
"A function was called but failed to return a value.");
317 for (Clause_iter i = expr.begin(); i != expr.end(); i++) {
318 boolean =
boolean && (*i)->boolean_clause();
334 DBG(cerr <<
"No selection recorded" << endl);
338 DBG(cerr <<
"Eval selection" << endl);
345 for (Clause_iter i = expr.begin(); i != expr.end() && result; i++) {
347 if (!((*i)->boolean_clause()))
348 throw InternalErr(__FILE__, __LINE__,
"A selection expression must contain only boolean clauses.");
349 result = result && (*i)->value(dds);
367 void *buffer = ce_expr_string(constraint.c_str());
370 ce_exprdebug =
false;
372 ce_expr_switch_to_buffer(buffer);
379 ce_expr_delete_buffer(buffer);
383 ce_expr_delete_buffer(buffer);
bool find_function(const std::string &name, bool_func *f) const
Find a Boolean function with a given name in the function list.
virtual bool find_function(const std::string &name, bool_func *f) const
Find a boolean function with a given name in the function list.
A class for error processing.
A class for software fault reporting.
BaseType * eval_function(DDS &dds, const std::string &dataset)
Evaluate a function-valued constraint expression.
top level DAP object to house generic methods
void add_var_nocopy(BaseType *bt)
Adds the variable to the DDS.
bool value(DDS &dds)
Evaluate a clause which returns a boolean value This method must only be evaluated for clauses with r...
DDS * eval_function_clauses(DDS &dds)
Evaluate a function-valued constraint expression that contains several function calls.
Clause_iter clause_begin()
Holds a fragment of a constraint expression.
BaseTypeFactory * get_factory() const
bool eval_selection(DDS &dds, const std::string &dataset)
Evaluate a boolean-valued constraint expression. This is main method for the evaluator and is called ...
bool functional_expression()
Does the current constraint expression return a BaseType pointer? This method does not evaluate the c...
string get_dataset_name() const
string get_version() const
Get the server version string, unparsed.
void parse_constraint(const std::string &constraint, DDS &dds)
Parse the constraint expression given the current DDS.
bool function_clauses()
Does the current constraint expression contain function clauses.
void append_constant(BaseType *btp)
The basic data type for the DODS DAP types.
bool value_clause()
Return true if the clause returns a value in a BaseType pointer.
bool clause_value(Clause_iter &i, DDS &dds)
bool boolean_expression()
Does the current constraint expression return a boolean value?
void append_clause(int op, rvalue *arg1, rvalue_list *arg2)
Add a clause to a constraint expression.