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); }