cpiCreateAndInitializeElement

用途

创建语法元素,它由指定解析器拥有,未连接到语法树。该元素使用 typenamefirstChildCompletelastChildComplete 参数的值部分初始化。

语法

CciElement* cpiCreateAndInitializeElement(
    int*                returnCode,
    CciParser*  parser,
    CciElementType  type,
  	const CciChar* name,
    CciBool         firstChildComplete,
    CciBool         lastChildComplete);

参数

returnCode
接收来自函数(输出)的返回码。
可能的返回码是:
  • CCI_SUCCESS
  • CCI_EXCEPTION
  • CCI_FAILURE
  • CCI_INV_PARSER_OBJECT
parser
指定解析器对象的地址(输入)。此地址会作为 cpiCreateContext 实施函数的参数传递到解析器。
type
指定正在创建的元素类型(输入)。
name
指定元素的描述性名称(输入)。
firstChildComplete
指定语法元素的 firstChildComplete 标志的值(输入)。
lastChildComplete
指定语法元素的 lastChildComplete 标志的值(输入)。

返回值

如果成功,返回新元素对象的地址。否则,返回零值(CCI_NULL_ADDR),并且 returnCode 参数表明错误的原因。

样本

/* Advance to the end of the value */
          while (pc->iCurrentCharacter != quoteChar) {
                        advance( (PARSER_CONTEXT_ST *)context, parser );
          }

                  /* Get a pointer to the end of the tag */
          endMarker = (char*)pc->iBuffer+(int)pc->iIndex;

                  /* Compute the size of the tag */
                  markedSize = (size_t)endMarker-(int)startMarker;

                    /* Convert the attribute value into broker form */
          data = CciNString((char *)startMarker, markedSize, pc->iCcsid);

                    /* Create a new name-value element for the attribute */
                    newElement = cpiCreateAndInitializeElement(&rc, parser, type, name);
                    cpiSetElementType(&rc, newElement, CCI_ELEMENT_TYPE_NAME_VALUE);
                  cpiSetElementName(&rc, newElement, data);
          if (pc->trace) {
            const char * mbData = mbString(data, pc->iCcsid);
            fprintf(pc->tracefile, "PLUGIN: Created new NAMEVALUE element; 
                                      object=0x%x type=0x%x name=",
                                        newElement, CCI_ELEMENT_TYPE_NAME_VALUE);
            fprintf(pc->tracefile, "%s\n", mbData);
            fflush(pc->tracefile);
                      free((void *)mbData);
          }
                    /* Free the memory created in CciNString() */
                    free((void *)data);
相关概念
用户定义的解析器
用户定义的扩展
相关任务
使用 C 创建解析器
相关参考
cpiCreateElement
C 解析器实用程序函数
声明 | 商标 | 下载 | 书库 | 支持 | 反馈
Copyright IBM Corporation 1999, 2006 最后一次更新时间:2006/08/14
as08390_