This function returns the address of the syntax element object that is the parent of the specified target element.
CciElement* cpiParent(
int* returnCode,
const CciElement* targetElement);
If successful, the address of the requested syntax element is returned. If there is no parent element, zero is returned. If an error occurs, zero (CCI_NULL_ADDR) is returned and the returnCode parameter indicates the reason for the error.
This example is taken from the sample parser file BipSampPluginParser.c:
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);
}