cpiDefineParserClass

目的

定义由解析器工厂支持的解析器类的名称。functbl 是指向虚函数表的指针,此指针表包含指向 C 实施函数的指针,即,那些函数提供解析器本身的函数。

语法

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

参数

returnCode
接收来自函数(输出)的返回码。可能的返回码是:
  • 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
指定支持命名解析器(输入)的工厂对象的地址。从 cpiCreateParserFactory 返回地址。
name
要定义(输入)的解析器类的名称。解析器类名的最大长度为 8 个字符。
functbl
CPI_VFT 结构的地址,它包含指向实施函数的指针(输入)。

返回值

无。 如果发生错误,则 returnCode 表明错误原因。

样本

此示例取自样本解析器文件 BipSampPluginParser.c(862 行到 901 行):

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 broker */
	return(factoryObject);
}
相关概念
用户定义的解析器
用户定义的扩展
相关任务
使用 C 创建解析器
相关参考
cpiCreateParserFactory
C 解析器实用程序函数
声明 | 商标 | 下载 | | 支持 | 反馈
Copyright IBM Corporation 1999, 2006 最后更新:2006/05/19
as08250_