cpiDefineParserClass

This function defines the name of a parser class that is supported by a parser factory.

functbl is a pointer to a virtual function table that contains pointers to the C implementation functions; that is, those functions that provide the function of the parser itself.

Syntax

void cpiDefineParserClass(
  int*         returnCode,
  CciFactory*  factoryObject,
  CciChar*     name,
  CPI_VFT*     functbl);

Parameters

returnCode
Receives the return code from the function (output).
Possible return codes are:
  • CCI_SUCCESS
  • CCI_EXCEPTION
  • CCI_INV_FACTORY_OBJECT
  • CCI_INV_PARSER_NAME
  • CCI_PARSER_NAME_TOO_LONG
  • CCI_INV_OBJECT_NAME
  • CCI_INV_VFTP
  • CCI_MISSING_IMPL_FUNCTION
  • CCI_INV_IMPL_FUNCTION
  • CCI_NAME_EXISTS
factoryObject
Specifies the address of the factory object that supports the named parser (input). The address is returned from cpiCreateParserFactory.
name
The name of the parser class to be defined (input). The maximum length of a parser class name is 8 characters.
functbl
The address of the CPI_VFT structure that contains pointers to the implementation functions (input).

Return values

None. If an error occurs, returnCode indicates the reason for the error.

Sample

This example is taken from the sample parser file BipSampPluginParser.c:

void LilFactoryExportPrefix * LilFactoryExportSuffix bipGetParserFactory()
{
  /* Declare variables */
  CciFactory*     factoryObject;
  int             rc;
  static CPI_VFT  vftable = {CPI_VFT_DEFAULT};

  /* Before we proceed we need to initialise all the static constants */
  /* that may be used by the plug-in.                                 */
  initParserConstants();

  /* Setup function table with pointers to parser implementation functions */
  vftable.iFpCreateContext            = cpiCreateContext;
  vftable.iFpParseBufferEncoded       = cpiParseBufferEncoded;
  vftable.iFpParseFirstChild          = cpiParseFirstChild;
  vftable.iFpParseLastChild           = cpiParseLastChild;
  vftable.iFpParsePreviousSibling     = cpiParsePreviousSibling;
  vftable.iFpParseNextSibling         = cpiParseNextSibling;
  vftable.iFpWriteBufferEncoded       = cpiWriteBufferEncoded;
  vftable.iFpDeleteContext            = cpiDeleteContext;
  vftable.iFpSetElementValue          = cpiSetElementValue;
  vftable.iFpElementValue             = cpiElementValue;
  vftable.iFpNextParserClassName      = cpiNextParserClassName;
  vftable.iFpSetNextParserClassName   = cpiSetNextParserClassName;
  vftable.iFpNextParserEncoding       = cpiNextParserEncoding;
  vftable.iFpNextParserCodedCharSetId = cpiNextParserCodedCharSetId;

  /* Create the parser factory for this plugin */
  factoryObject = cpiCreateParserFactory(&rc, constParserFactory);
  if (factoryObject) {
    /* Define the classes of message supported by the factory */
    cpiDefineParserClass(&rc, factoryObject, constPXML, &vftable);
  }
  else {
    /* Error: Unable to create parser factory */
  }

  /* Return address of this factory object to the integration node */
  return(factoryObject);
}