cpiCreateParserFactory

目的

在消息代理中创建指定的解析器工厂的单个实例。只有在初始化函数 bipGetParserFactory 中才必须对它进行调用,当消息代理装入“lil”时会调用此初始化函数。如果在任何其他时间调用 cpiCreateParserFactory,则结果是不可预测的。

语法

CciFactory* cpiCreateParserFactory(
  int*                returnCode,
  CciChar*  name);

参数

returnCode
接收来自函数(输出)的返回码。可能的返回码是:
  • CCI_SUCCESS
  • CCI_EXCEPTION
  • CCI_FAILURE
  • CCI_INV_FACTORY_NAME
  • CCI_INV_OBJECT_NAME
name
指定正在创建的工厂名称(输入)。

返回值

如果成功,返回解析器工厂对象的地址。否则,返回零值(CCI_NULL_ADDR),并且 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 创建解析器
相关参考
cpiDefineParserClass
C 解析器实用程序函数
声明 | 商标 | 下载 | | 支持 | 反馈
Copyright IBM Corporation 1999, 2006 最后更新:2006/05/19
as08240_