cpiRootElement

Purpose

Gets the address of the root syntax element of the specified parser object.

Syntax

CciElement* cpiRootElement(
  int*        returnCode,
  CciParser*  parser);

Parameters

returnCode
Receives the return code from the function (output).
parser
Specifies the address of the parser object (input).

Return values

The address of the root syntax element is returned. If an error occurs, zero (CCI_NULL_ADDR) is returned, and returnCode indicates the reason for the error.

Sample

This example is taken from the sample parser file BipSampPluginParser.c (lines 428 to 470):

int cpiParseBufferEncoded(
  CciParser*  parser,
  CciContext* context,
  int         encoding,
  int         ccsid
){
  PARSER_CONTEXT_ST* pc = (PARSER_CONTEXT_ST *)context ;
  int                rc;

  /* Get a pointer to the message buffer and set the offset */
  pc->iBuffer = (void *)cpiBufferPointer(&rc, parser);
  pc->iIndex = 0;

  /* Save the format of the buffer */
  pc->iEncoding = encoding;
  pc->iCcsid = ccsid;

  /* Save size of the buffer */
  pc->iSize = cpiBufferSize(&rc, parser);

  /* Prime the first byte in the stream */
  pc->iCurrentCharacter = cpiBufferByte(&rc, parser, pc->iIndex);

  /* Set the current element to the root element */
  pc->iCurrentElement = cpiRootElement(&rc, parser);

  /* Reset flag to ensure parsing is reset correctly */
  pc->iInTag = 0;

  /* We will assume ownership of the remainder of the buffer */
  return(pc->iSize);
}

Related concepts
User-defined parsers
User-defined extensions

Related tasks
Creating a parser in C

Related reference
Parser utility functions