RWDBExprFuncDef{n} RWDBExprFormDefinition
Member Functions | |
operator()() |
#include <rw/db/func.h> RWDBExprFuncDef0 myFunc0("myFunc0"); RWDBExprFuncDef1 myFunc1("myFunc1"); RWDBExprFuncDef2 myFunc2("myFunc2"); RWDBExprFuncDef3 myFunc3("myFunc3"); RWDBExprFuncDef4 myFunc4("myFunc4");
RWDBExprFuncDef{n}, where n is replaced by 0, ..., 4, represents the five possible specializations of the base class RWDBExprFormDefinition. These specializations are: RWDBExprFuncDef0, RWDBExprFuncDef1, RWDBExprFuncDef2, RWDBExprFuncDef3, and RWDBExprFuncDef4. 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 function DECRYPT(string, length, key). 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 which we define ourselves:
RWDBExprFuncDef3 decrypt("DECRYPT"); RWCString key = getMyKey(); RWDBTable users = myDbase.table("users"); RWDBColumn passWord = users["passWord"]; RWDBSelector select = myDbase.selector(); select << decrypt(passWord, rwdbCharLength(passWord), key);
Notice that the number of actual arguments passed to decrypt is checked at compile time. Compare this with the RWDBExprFormDefinition example.
RWDBCritFuncDef0, RWDBCritFuncDef1, RWDBCritFuncDef2, RWDBCritFuncDef3, and RWDBCritFuncDef4 provide a parallel mechanism for defining an RWDBCriterion, rather than an RWDBExpr. The RWDBExprFormDefinition base class may be used directly to gain additional flexibility. See RWDBExpr for details on SQL expressions in DBTools.h++, as well as for a complete listing of predefined SQL functions.
RWDBExprFuncDef0(const RWCString& functionName);
Creates an RWDBExprFuncDef for a functional expression that takes no arguments.
RWDBExprFuncDef1(const RWCString& functionName);
Creates an RWDBExprFuncDef for a functional expression that takes one argument.
RWDBExprFuncDef2(const RWCString& functionName);
Creates an RWDBExprFuncDef for a functional expression that takes two arguments.
RWDBExprFuncDef3(const RWCString& functionName);
Creates an RWDBExprFuncDef for a functional expression that takes three arguments.
RWDBExprFuncDef4(const RWCString& functionName);
Creates an RWDBExprFuncDef for a functional expression that takes four arguments. After such an RWDBExprFuncDef is instantiated, functionName may be used as though it were a predefined function.
virtual RWDBExpr operator() ();
Redefined from RWDBExprFormDefinition. Returns an RWDBExpr in the form of a function with zero arguments whose name is the name which was passed to self's constructor. Defined only for RWDBExprFuncDef0.
virtual RWDBExpr operator() (const RWDBExpr& expr0);
Redefined from RWDBExprFormDefinition. Returns an RWDBExpr in the form of a function with one argument whose name is the name which was passed to self's constructor. Defined only for RWDBExprFuncDef1.
virtual RWDBExpr operator() (const RWDBExpr& expr0, const RWDBExpr& expr1);
Redefined from RWDBExprFormDefinition. Returns an RWDBExpr in the form of a function with two arguments whose name is the name which was passed to self's constructor. Defined only for RWDBExprFuncDef2.
virtual RWDBExpr operator() (const RWDBExpr& expr0, const RWDBExpr& expr1, const RWDBExpr& expr2);
Redefined from RWDBExprFormDefinition. Returns an RWDBExpr in the form of a function with three arguments whose name is the name which was passed to self's constructor. Defined only for RWDBExprFuncDef3.
virtual RWDBExpr operator() (const RWDBExpr& expr0, const RWDBExpr& expr1, const RWDBExpr& expr2, const RWDBExpr& expr3);
Redefined from RWDBExprFormDefinition. Returns an RWDBExpr in the form of a function with four arguments whose name is the name which was passed to self's constructor. Defined only for RWDBExprFuncDef4.
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.