RWDBCritFuncDef{n} RWDBCritFormDefinition
Member Functions | |
operator()() |
#include <rw/db/func.h> RWDBCritFuncDef0 myFunc0("myFunc0"); RWDBCritFuncDef1 myFunc1("myFunc1"); RWDBCritFuncDef2 myFunc2("myFunc2"); RWDBCritFuncDef3 myFunc3("myFunc3"); RWDBCritFuncDef4 myFunc4("myFunc4");
RWDBCritFuncDef{n}, where n is replaced by 0, ..., 4, represents the five possible specializations of the base class RWDBCritFormDefinition. These specializations are: RWDBCritFuncDef0, RWDBCritFuncDef1, RWDBCritFuncDef2, RWDBCritFuncDef3, and RWDBCritFuncDef4. These classes provide a simplified mechanism for defining SQL functions of 0-4 arguments, respectively. Unlike the base class, these classes do not require positional placeholders in their function definitions. Also, since the number of required arguments is fixed, compile-time checking can be done on the number of arguments actually passed.
Imagine that a database vendor's SQL variant provides the boolean function VALID_NAME(string), which can be used in a WHERE clause. DBTools.h++ has no direct support for this function, yet we would like to use it without losing the benefits of the DBTools.h++ high-level constructs for data manipulation. To do so, we can use a function that we define ourselves:
RWDBCritFuncDef1 validName("VALID_NAME"); RWDBTable potentialNames = myDbase.table("potentialNames"); RWDBColumn name = potentialNames["name"]; RWDBSelector usableNames = myDbase.selector(); usableNames << name; usableNames.where(validName(name));
Notice that the number of actual arguments passed to validName is checked at compile time. Compare this with the example for RWDBCritFormDefinition.
RWDBExprFuncDef0, RWDBExprFuncDef1, RWDBExprFuncDef2, RWDBExprFuncDef3, and RWDBExprFuncDef4 provide a parallel mechanism for defining an RWDBExpr, rather than an RWDBCriterion.
The RWDBCritFormDefinition base class may be used directly to gain additional flexibility. See RWDBCriterion for details on SQL WHERE clauses in DBTools.h++ .
RWDBCritFuncDef0(const RWCString& functionName);
Creates an RWDBCritFuncDef for a functional expression that takes no arguments.
RWDBCritFuncDef1(const RWCString& functionName);
Creates an RWDBCritFuncDef for a functional expression that takes 1 argument.
RWDBCritFuncDef2(const RWCString& functionName);
Creates an RWDBCritFuncDef for a functional expression that takes 2 arguments.
RWDBCritFuncDef3(const RWCString& functionName);
Creates an RWDBCritFuncDef for a functional expression that takes 3 arguments.
RWDBCritFuncDef4(const RWCString& functionName);
Creates an RWDBCritFuncDef for a functional expression that takes 4 arguments. After such an RWDBCritFuncDef is instantiated, functionName may be used as though it were a predefined function.
virtual RWDBExpr operator()(); virtual RWDBExpr operator()(const RWDBExpr& x1); virtual RWDBExpr operator()(const RWDBExpr& x1,
const RWDBExpr& x2); virtual RWDBExpr operator()(const RWDBExpr& x1,
const RWDBExpr& x2,
const RWDBExpr& x3); virtual RWDBExpr operator()(const RWDBExpr& x1,
const RWDBExpr& x2,
const RWDBExpr& x3,
const RWDBExpr& x4);
Redefined from RWDBCritFormDefinition. Returns an RWDBCriterion in the form of a function with 0 arguments whose name is the name that was passed to self's constructor. Defined for RWDBCritFuncDef0 only.
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.