Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

RWDBExprFormDefinition



Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <rw/db/func.h>

RWDBExprFormDefinition myFunc("myFormat");

Description

RWDBExprFormDefinition is a base class for a family of classes that provide an extensible mechanism for an application to define functional notation for RWDBExpr. RWDBExprFormDefinition allows a programmer to create an object that will translate into an RWDBExpr and eventually be expanded into an SQL string. The object will allow up to four expressions to be embedded into the resultant string.

An RWDBExprFormDefinition object is instantiated with a format string. The format string may contain placeholders for up to four positional parameters, which are labeled %0 through %3. An object defined this way may subsequently be referenced like predefined functions, such as rwdbMax and rwdbAvg.

When an RWDBExprFormDefinition object is expanded by an asString() method of RWDBExpr, each instance of %0 is replaced with the first actual argument, each instance of %1 is replaced with the second actual argument, and so on. There can be multiple instances of a placeholder in the format string, and the placeholders may occur in any order. This allows great flexibility in defining functions, at the cost of losing compile-time checking on the number of arguments actually passed. To enable compile-time checking on the number of actual arguments, at the cost of some flexibility, use the RWDBExprFuncDef{n} classes.

Example

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:

Note that the number of arguments actually passed to decrypt is not checked. Compare this example with the RWDBExprFuncDef{n} example to see how such checking can be enabled.

Related Classes

RWDBCritFormDefinition provides a parallel mechanism for defining an RWDBCriterion, rather than an RWDBExpr.

RWDBExprFuncDef0, RWDBExprFuncDef1, RWDBExprFuncDef2, RWDBExprFuncDef3, and RWDBExprFuncDef4 are derived from RWDBExprFormDefinition. They provide a simplified interface for functions requiring 0 - 4 arguments, respectively, and do not require positional placeholders.

See RWDBExpr for details on SQL expressions in DBTools.h++, as well as for a complete listing of predefined SQL functions.

Public Constructors

RWDBExprFormDefinition();
RWDBExprFormDefinition(const RWCString& formatString);

Public Member Operators

virtual RWDBExpr 
operator() ();
virtual RWDBExpr 
operator()(const RWDBExpr& expr0);
virtual RWDBExpr 
operator()(const RWDBExpr& expr0, const RWDBExpr& expr1);
virtual RWDBExpr 
operator()(const RWDBExpr& expr0, const RWDBExpr& expr1, 
           const RWDBExpr& expr2);
virtual RWDBExpr 
operator()(const RWDBExpr& expr0, const RWDBExpr& expr1, 
           const RWDBExpr& expr2, const RWDBExpr& expr3);


Previous fileTop of DocumentContentsIndexNext file

©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.