cpiParent

用途

返回 语法元素对象的地址,它是指定的目标元素的父代。

语法

CciElement* cpiParent(
    int*                returnCode,
    const CciElement*  targetElement);

参数

returnCode
接收来自函数(输出)的返回码。
可能的返回码是:
  • CCI_SUCCESS
  • CCI_EXCEPTION
  • CCI_INV_ELEMENT_OBJECT
targetElement
指定目标语法元素对象(输入)的地址。

返回值

如果成功,则返回所请求的语法元素的地址。如果没有父代元素,则返回零。如果错误发生,则返回零(CCI_NULL_ADDR)并且参数 returnCode 参数表明错误的原因。

样本

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

void* parseNextItem(
    CciParser*  parser,
    CciContext* context,                
    CciElement* element
){
    void*              endMarker;
    void*              startMarker;
    PARSER_CONTEXT_ST* pc = (PARSER_CONTEXT_ST *)context ;
    CciElement*        returnElement = element;
    CciElement*        newElement;
    size_t             markedSize;
    const CciChar*     data;
    int             rc;

  if (pc->trace) 

    /* Skip any white space */
    skipWhiteSpace( (PARSER_CONTEXT_ST *)context );

    /* Are we at the end of the buffer? */
if (pc->iIndex == pc->iSize)
                return(0);
  }

    /* Are we within a tag? */
if (pc->iInTag) {

    if (pc->iCurrentCharacter == chCloseAngle) {

            /* We have reached the end of a tag */
      pc->iInTag = 0;
                  advance( (PARSER_CONTEXT_ST *)context, parser );
    }
    else if (pc->iCurrentCharacter == chForwardSlash) {

            /* We may have reached the end of an empty tag */
                  advance( (PARSER_CONTEXT_ST *)context, parser );

      if (pc->iCurrentCharacter == chCloseAngle) {

        pc->iInTag = 0;
                    advance( (PARSER_CONTEXT_ST *)context, parser );

                cpiSetElementCompleteNext(&rc, element, 1);
        
                returnElement = cpiParent(&rc, element);
      }
相关概念
用户定义的解析器
用户定义的扩展
相关任务
使用 C 创建解析器
相关参考
C 解析器实用程序函数
声明 | 商标 | 下载 | 书库 | 支持 | 反馈
Copyright IBM Corporation 1999, 2006 最后一次更新时间:2006/08/14
as08310_