cpiParent
This function returns the address of the syntax element object that is the parent of the specified target element.
Syntax
CciElement* cpiParent(
int* returnCode,
const CciElement* targetElement);
Parameters
- returnCode
- Receives the return code from the function (output). Possible return codes are:
- CCI_SUCCESS
- CCI_EXCEPTION
- CCI_INV_ELEMENT_OBJECT
- targetElement
- Specifies the address of the target syntax element object (input).
Return values
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.
Sample
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);
}