cpiElementValueValue

Purpose

Gets the value object from the specified syntax element. This value object is opaque in that it cannot be interrogated. It can be used to set or derive the value of one element from another, without knowing its type, by using the cpiSetElementValueValue function. This can be used by parsers that override behavior by invoking the implementation functions cpiElementValue and cpiSetElementValue.

Syntax

const CciElementValue* cpiElementValueValue(
  int*         returnCode,
  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

The address of the CciElementValue object stored in the specified target 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 705 to 725):

const CciElementValue* cpiElementValue(
  CciParser*  parser,
  CciElement* element
){
  CciElement* firstChild;
  const CciElementValue* value;
  int         rc;

  if ((cpiElementType(&rc, element) == CCI_ELEMENT_TYPE_VALUE) ||
      (cpiElementType(&rc, element) == CCI_ELEMENT_TYPE_NAME_VALUE)) {
    value = cpiElementValueValue(&rc, element);
  }
  else if (cpiElementType(&rc, element) == CCI_ELEMENT_TYPE_NAME) {
    firstChild = cniFirstChild(&rc, element);
    value = cpiElementValueValue(&rc, firstChild);
  }
  else {
  }

  return(value);
}
Related concepts
User-defined parsers
User-defined extensions
Related tasks
Creating a parser in C
Related reference
cpiElementName
cpiElementType
cpiElementValue group
C parser utility functions