fn:sum
.
More...
#include <aggregatefunctsumexpression.h>
Public Member Functions | |
AggregateFunctSumExpression (VarExpression *_var) | |
Constructor. | |
AggregateFunctSumExpression (VarStepExpression *_varstep) | |
Constructor. | |
virtual | ~AggregateFunctSumExpression () |
virtual void | eval (OutputStream &eos, Environment *env, unsigned modus) |
Private Member Functions | |
virtual long double | calculateValue (OutputStream &eos, Environment *env, unsigned modus, bool &empty_sequence) |
fn:sum
.
Represents XQuery standard function fn:sum
, which takes either a VarExpression, e.g. fn:sum($x)
, or a VarStepExpression, e.g. fn:sum($x/bib/book)
or fn:sum(/bib//book)
respectively, as argument and returns the sum of all items of the sequence located through the entered VarExpression or the entered VarStepExpression respectively.
Definition at line 60 of file aggregatefunctsumexpression.h.
AggregateFunctSumExpression::AggregateFunctSumExpression | ( | VarExpression * | _var | ) |
Constructor.
Constructor - creating object for a VarExpression.
[in] | _var | Pointer to a VarExpression object. |
Definition at line 37 of file aggregatefunctsumexpression.cpp.
AggregateFunctSumExpression::AggregateFunctSumExpression | ( | VarStepExpression * | _varstep | ) |
Constructor.
Constructor - creating object for a VarStepExpression.
[in] | _varstep | Pointer to a VarStepExpression object. |
Definition at line 41 of file aggregatefunctsumexpression.cpp.
AggregateFunctSumExpression::~AggregateFunctSumExpression | ( | ) | [virtual] |
Destructor.
Definition at line 45 of file aggregatefunctsumexpression.cpp.
long double AggregateFunctSumExpression::calculateValue | ( | OutputStream & | eos, | |
Environment * | env, | |||
unsigned | modus, | |||
bool & | empty_sequence | |||
) | [private, virtual] |
Result calculation of the corresponding aggregate function.
Result calculation of the corresponding aggregate function.
[in] | eos | Pointer to a OutputStream object. |
[in] | env | Pointer to a Environment object. |
[in] | modus | Evaluation modus. |
[in] | empty_sequence | Indicator if aggreagte function is called on an empty sequence. |
long | double Result of the corresponding aggregate function. |
Implements AggregateFunctExpression.
Definition at line 99 of file aggregatefunctsumexpression.cpp.
References AggregateFunctExpression::bit, BufferIterator::clear(), ForExpression::evalSignOffForBinding(), AggregateFunctExpression::forexp, VarExpression::getId(), BufferIterator::getNext(), Environment::getNodeBinding(), MiscFunctions::getRoundFrom(), MiscFunctions::getSummationFrom(), BufferIterator::init(), LOCK_CONTEXT_ALWAYS_CLEAR, READ_UP_TO_CLOSE_CONTEXT, AggregateFunctExpression::var, and AggregateFunctExpression::varstep.
Referenced by eval().
void AggregateFunctSumExpression::eval | ( | OutputStream & | eos, | |
Environment * | env, | |||
unsigned | modus | |||
) | [virtual] |
Evaluates the expression in the given environment.
Evaluates the expression in the given environment. The evaluation takes place in the environment that is passed to this method. In addition, the parameter modus is one of the following: EVAL_QUERY, EVAL_QUERY_SILENT or EVAL_SIGNOFF (see also the corresponding defines for more information). This method implements the XQuery semantics for the standard expression types, but also the GCX specific extensions like signOff-statements.
[in] | eos | Pointer to a OutputStream object. |
[in] | env | Pointer to an Environment object. |
[in] | modus | The query evaluation mode. |
RuntimeException | If illegal evaluation mode. |
InvalidCastException | If it is not possible to cast all affected PCDATA values of an XML document to numeric values or some value calculation will cause an (internal) error. |
Implements AggregateFunctExpression.
Definition at line 48 of file aggregatefunctsumexpression.cpp.
References calculateValue(), OperandExpression::cur_val, ForExpression::eval(), EVAL_QUERY, EVAL_QUERY_SILENT, EVAL_SIGNOFF, AggregateFunctExpression::forexp, MiscFunctions::getStringFromNumerical(), OUTPUT_SUM_ON_EMPTY_SEQUENCE, and Value::setNumVal().