User Guide

Chapter 18: Building Custom CFAPI Tags 301
// Create a query that contains these columns
CCFXQuery* pQuery = pRequest->AddQuery( "People", pColumns ) ;
// Add data to the query
int iRow ;
iRow = pQuery->AddRow() ;
pQuery->SetData( iRow, iFirstName, "John" ) ;
pQuery->SetData( iRow, iLastName, "Smith" ) ;
iRow = pQuery->AddRow() ;
pQuery->SetData( iRow, iFirstName, "Jane" ) ;
pQuery->SetData( iRow, iLastName, "Doe" ) ;
CCFXRequest::AttributeExists
BOOL CCFXRequest::AttributeExists(LPCSTR
lpszName
)
Checks to see whether the attribute was passed to the tag. Returns TRUE if the
attribute is available; otherwise, returns FALSE.
lpszName
Name of the attribute to check (case insensitive).
Example
The following example checks to see if the user passed an attribute named
DESTINATION to the tag and throws an exception if the attribute was not passed:
if ( pRequest->AttributeExists("DESTINATION")==FALSE )
{
pRequest->ThrowException(
"Missing DESTINATION parameter",
"You must pass a DESTINATION parameter in "
"order for this tag to work correctly." ) ;
}
CCFXRequest::CreateStringSet
CCFXStringSet* CCFXRequest::CreateStringSet(void)
Allocates and returns a new instance. Note that string sets should always be created
using this function as opposed to directly using the ’new’ operator.
Returns an object of CCFXStringSet Class. You are not responsible for freeing the
memory allocated for the returned string set (it will be freed automatically by
ColdFusion after the request is completed).
Example
The following example creates a string set and adds 3 strings to it:
CCFXStringSet* pColors = pRequest->CreateStringSet() ;
pColors->AddString( "Red" ) ;
pColors->AddString( "Green" ) ;
pColors->AddString( "Blue" ) ;