Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
DB Interface Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWDBCritFormDefinition

Module:  DB Interface Module   Group:  Expression Classes


Does not inherit

Local Index

Members

Synopsis

#include <rw/db/func.h>

RWDBCritFormDefinition myFunc("myFormat");

Description

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

An RWDBCritFormDefinition 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 in this way may subsequently be referenced in the same way that predefined functions like rwdbMax and rwdbAvg are referenced.

When an RWDBCritFormDefinition object is expanded by the asString() method of an RWDBCriterion, 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 RWDBCritFuncDef{n} classes.

Example

Imagine that a database vendor's SQL variant provides the boolean function VALID_NAME(string), which can be used in a WHERE clause. The DB Interface Module has no direct support for this function, yet we would like to use it without losing the benefits of 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 validName is not checked. Compare this example with the RWDBCritFuncDef{n} example to see how such checking can be enabled.

Related Classes

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

RWDBCritFuncDef0, RWDBCritFuncDef1, RWDBCritFuncDef2, RWDBCritFuncDef3, and RWDBCritFuncDef4 are derived from RWDBCritFormDefinition. They provide a simplified interface for functions requiring 0-4 arguments, respectively, and do not require positional placeholders.

See RWDBCriterion for details on SQL WHERE clauses in the DB Interface Module.

Public Constructors

RWDBCritFormDefinition();
RWDBCritFormDefinition(const RWCString& formatString);

Public Member Operators

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


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.