CciElement* cpiParent( int* returnCode, const CciElement* 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); }