Building Extensions in C++  
 
 

Another technology supported for extending ColdFusion is C++. ColdFusion exposes a C++ based API you can employ for encapsulating specific features in a ColdFusion tag, generally known as a CFX tag. The ColdFusion Application Programming Interface (CFAPI) is a C++ based API for creating C++ based tags for use in ColdFusion. These custom tags implemented as DLLs and have the following capabilities:

  • The ability to handle any number of custom attributes.
  • The ability to use and manipulate ColdFusion queries for custom formatting.
  • The ability to generate ColdFusion queries for interfacing with non-ODBC based information sources.
  • The ability to dynamically generate HTML to be returned to the client.
  • The ability to set variables within the ColdFusion application page from which they are called.
  • The ability to throw exceptions which result in standard ColdFusion error messages.

On Windows NT, you can get started quickly by using the ColdFusion Custom Tag Visual C++ AppWizard to generate a tag. The custom tag wizard is automatically installed during setup if Visual C++ 4.0 or higher is present on your system. By modifying the default tag implementation and experimenting, you will quickly learn how to use the API.

Before you can use your C++ compiler to build custom tags, you must enable the compiler to locate the CFAPI header file, cfx.h. On Windows NT, you do this by adding the CFAPI Include directory (\cfusion\cfapi\include) to your list of global include paths. On Solaris, you will need -I <includepath> on your compile line (see the Makefile directory list example).

 
 
  Solaris only  
 

CFX tags built on Solaris must be thread safe and should be compiled with the -mt switch on the Sun compiler.

 
 
  Sample C++ tags  
 
 

Two CFX tags are included to give you additional insight into working with the CFAPI. The two example tags are:

  • CFX_DIRECTORYLIST -- Queries a directory for the list of files it contains.
  • CFX_NTUSERDB (Windows NT only) -- Allows addition and deletion of NT users.

On Windows NT, these tags are located in the \cfusion\cfxapi\examples directory. On Solaris, look in installdirectory/coldfusion/cfx/examples.



 
 
BackUp LevelNext
 
 

allaire     AllaireDoc@allaire.com
    Copyright © 1998, Allaire Corporation. All rights reserved.