38 struct yy_buffer_state;
66 for (
Constants_iter j = constants.begin(); j != constants.end(); j++) {
72 for (
Clause_iter k = expr.begin(); k != expr.end(); k++) {
97 throw InternalErr(__FILE__, __LINE__,
"There are no CE clauses for *this* DDS object.");
99 return (*iter)->value(dds);
118 expr.push_back(clause);
134 expr.push_back(clause);
150 expr.push_back(clause);
162 constants.push_back(btp);
173 func_name_is(
const string &name) :
177 bool operator()(
const ConstraintEvaluator::function f)
179 return f.name == d_name;
203 void ConstraintEvaluator::add_function(
const string &name, bool_func f)
206 function func(name, f);
207 functions.push_back(func);
211 void ConstraintEvaluator::add_function(
const string &name, btp_func f)
214 function func(name, f);
215 functions.push_back(func);
219 void ConstraintEvaluator::add_function(
const string &name, proj_func f)
222 function func(name, f);
223 functions.push_back(func);
232 if (functions.empty())
235 for (Functions_citer i = functions.begin(); i != functions.end(); i++) {
236 if (name == (*i).name && (*f = (*i).b_func)) {
250 if (functions.empty())
253 for (Functions_citer i = functions.begin(); i != functions.end(); i++) {
254 if (name == (*i).name && (*f = (*i).bt_func)) {
268 if (functions.empty())
271 for (Functions_citer i = functions.begin(); i != functions.end(); i++)
272 if (name == (*i).name && (*f = (*i).p_func)) {
304 if (expr.size() != 1)
305 throw InternalErr(__FILE__, __LINE__,
"The length of the list of CE clauses is not 1.");
309 if (cp->
value(dds, &result))
329 for (
unsigned int i = 0; i < expr.size(); ++i) {
357 throw InternalErr(__FILE__, __LINE__,
"The constraint expression is empty.");
360 for (
unsigned int i = 0; i < expr.size(); ++i) {
363 if (cp->
value(dds, &result)) {
370 throw Error(
"A function was called but failed to return a value.");
395 throw InternalErr(__FILE__, __LINE__,
"The constraint expression is empty.");
400 for (
unsigned int i = 0; i < expr.size(); ++i) {
403 if (cp->
value(dds, &result)) {
408 throw Error(
"A function was called but failed to return a value.");
422 for (
Clause_iter i = expr.begin(); i != expr.end(); i++) {
423 boolean =
boolean && (*i)->boolean_clause();
439 DBG(cerr <<
"No selection recorded" << endl);
443 DBG(cerr <<
"Eval selection" << endl);
450 for (
Clause_iter i = expr.begin(); i != expr.end() && result; i++) {
452 if (!((*i)->boolean_clause()))
453 throw InternalErr(__FILE__, __LINE__,
"A selection expression must contain only boolean clauses.");
454 result = result && (*i)->value(dds);
virtual ~ConstraintEvaluator()
void ce_expr_delete_buffer(void *buffer)
static ServerFunctionsList * TheList()
std::vector< rvalue * > rvalue_list
bool boolean_expression()
Does the current constraint expression return a boolean value?
BaseType * eval_function(DDS &dds, const string &dataset)
Evaluate a function-valued constraint expression.
void parse_constraint(const string &constraint, DDS &dds)
Parse the constraint expression given the current DDS.
void add_var_nocopy(BaseType *bt)
Adds the variable to the DDS.
void * ce_expr_string(const char *yy_str)
A class for software fault reporting.
bool eval_selection(DDS &dds, const string &dataset)
Evaluate a boolean-valued constraint expression. This is main method for the evaluator ans is called ...
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.
void ce_expr_switch_to_buffer(void *new_buffer)
string get_version() const
Get the server version string, unparsed.
std::vector< BaseType * >::iterator Constants_iter
BaseTypeFactory * get_factory() const
friend class func_name_is
bool functional_expression()
Does the current constraint expression return a BaseType pointer? This method does not evaluate the c...
Clause_iter clause_begin()
The basic data type for the DODS DAP types.
void append_constant(BaseType *btp)
bool clause_value(Clause_iter &i, DDS &dds)
string get_protocol() const
Holds a fragment of a constraint expression.
bool function_clauses()
Does the current constraint expression contain function clauses.
A class for error processing.
string get_dataset_name() const
bool value_clause()
Return true if the clause returns a value in a BaseType pointer.
std::vector< Clause * >::iterator Clause_iter
int ce_exprparse(libdap::ce_parser_arg *arg)
void append_clause(int op, rvalue *arg1, rvalue_list *arg2)
Add a clause to a constraint expression.
virtual bool find_function(const std::string &name, libdap::bool_func *f) const
bool find_function(const string &name, bool_func *f) const
Find a Boolean function with a given name in the function list.