cpiCreateElement

用途

创建未连接到语法树的缺省语法元素。该元素由指定解析器拥有。由于该元素未设置任何属性(例如类型或名称),所以它是不完整的。

语法

CciElement* cpiCreateElement(
    int*                returnCode,
    CciParser*  parser);

参数

returnCode
接收来自函数(输出)的返回码。
可能的返回码是:
  • CCI_SUCCESS
  • CCI_EXCEPTION
  • CCI_FAILURE
  • CCI_INV_PARSER_OBJECT
parser
指定解析器对象的地址(输入)。

返回值

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

样本

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

/* 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 = cpiCreateElement(&rc, parser);
                    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 创建解析器
相关参考
cpiCreateAndInitializeElement
C 解析器实用程序函数
声明 | 商标 | 下载 | 书库 | 支持 | 反馈
Copyright IBM Corporation 1999, 2006 最后一次更新时间:2006/08/14
as08400_