libdap::Clause Struct Reference

Holds a fragment of a constraint expression. More...

`#include <Clause.h>`

## Public Member Functions

bool | boolean_clause ()
| Return true if the clause returns a boolean value.
| Clause (bool_func func, rvalue_list *rv)
| Clause (btp_func func, rvalue_list *rv)
| Clause (const int oper, rvalue *a1, rvalue_list *rv)
bool | OK ()
| Checks the "representation invariant" of a clause.
bool | value (DDS &dds)
| Evaluate a clause which returns a boolean value This method must only be evaluated for clauses with relational expressions or boolean functions.
bool | value (DDS &dds, BaseType **value)
| Evaluate a clause that returns a value via a BaseType pointer. This method should be called only for those clauses that return values.
bool | value_clause ()
| Return true if the clause returns a value in a BaseType pointer.

## Detailed Description

Holds a fragment of a constraint expression.

The selection part of a a DAP constraint expression may contain one or more clauses, separated by ampersands (&). This is modeled in the DDS class structure as a singly-linked list of Clause objects. In addition, a constraint expression may be a single function call, also represented in the DDS using an instance of Clause.

Each clause object can contain a representation of one of three possible forms:

1. A relational clause, where an operator tests the relation between two operands. This kind of clause evaluates to a boolean value. For example: `a > b`.

2. A boolean function, where some function operates on arguments in the clause to return a boolean value. For example, consider a scalar A and a list L. The clause `find(A,L)` might return TRUE if A is a member of L (if the `find()` function is defined).

3. A clause that returns a pointer to a DAP BaseType value. This is a clause that evaluates to some data value (be it scalar or vector). For example, `sig0()` might be included in the constraint expression parser to calculate density from pressure, temperature, and salinity. In this case, `sig0(p,t,s)` would be a clause that evaluates to a data value.

This might be a bit confusing; in the first, and by far more common, form of constraint expressions (CEs) only the first two types of clauses may appear. In the second form of the CE only the last type of clause may occur. The Clause class, however, can store them all.

The Clause object holds the constraint expression after it has been parsed. The parser renders the relational operator into an integer, and the functions into pointers.

See also
  DDS::parse_constraint

Definition at line 90 of file Clause.h.

## Constructor & Destructor Documentation

## Clause() [1/4]

libdap::Clause::Clause | ( | const int | oper,
|  | rvalue * | a1,
|  | rvalue_list * | rv
| ) |  |

Definition at line 53 of file Clause.cc.

## Clause() [2/4]

libdap::Clause::Clause | ( | bool_func | func,
|  | rvalue_list * | rv
| ) |  |

Definition at line 59 of file Clause.cc.

## Clause() [3/4]

libdap::Clause::Clause | ( | btp_func | func,
|  | rvalue_list * | rv
| ) |  |

Definition at line 70 of file Clause.cc.

## Clause() [4/4]

libdap::Clause::Clause | ( |  | ) |

Definition at line 81 of file Clause.cc.

## ~Clause()

libdap::Clause::~Clause | ( |  | ) |

virtual

Definition at line 90 of file Clause.cc.

## Member Function Documentation

## boolean_clause()

bool libdap::Clause::boolean_clause | ( |  | ) |

Return true if the clause returns a boolean value.

Definition at line 129 of file Clause.cc.

## OK()

bool libdap::Clause::OK | ( |  | ) |

Checks the "representation invariant" of a clause.

Definition at line 106 of file Clause.cc.

## value() [1/2]

bool libdap::Clause::value | ( | DDS & | dds | ) |

Evaluate a clause which returns a boolean value This method must only be evaluated for clauses with relational expressions or boolean functions.

Parameters

  dds | Use variables from this DDS when evaluating the expression

Returns
  True if the clause is true, false otherwise.

Exceptions

  InternalErr | if called for a clause that returns a BaseType pointer.

Definition at line 156 of file Clause.cc.

## value() [2/2]

bool libdap::Clause::value | ( | DDS & | dds,
|  | BaseType ** | value
| ) |  |

Evaluate a clause that returns a value via a BaseType pointer. This method should be called only for those clauses that return values.

Parameters

  dds | Use variables from this DDS when evaluating the expression
  value | A value-result parameter

Returns
  True if the the BaseType pointer is not null, false otherwise.

Exceptions

  InternalErr | if called for a clause that returns a boolean value. Not that this method itself does return a boolean value.

Definition at line 205 of file Clause.cc.

## value_clause()

bool libdap::Clause::value_clause | ( |  | ) |

Return true if the clause returns a value in a BaseType pointer.

Definition at line 138 of file Clause.cc.

The documentation for this struct was generated from the following files:

- Clause.h
- Clause.cc