cpiSetElementType

Purpose

Sets the type of the specified syntax element.

Syntax

void cpiSetElementType(
  int*            returnCode,
  CciElement*     targetElement,
  CciElementType  type);

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).
type
The type to be set in the target element (input).

Return values

None. If an error occurs, returnCode indicates the reason for the error.

Sample

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

/* Convert the attribute value into broker form */
          data = CciNString((char *)startMarker, markedSize, pc->iCcsid);

/* Create a new name-value element for the attribute */
          newElement = cpiCreateElement(&rc, parser);
          cpiSetElementType(&rc, newElement, CCI_ELEMENT_TYPE_NAME_VALUE);
          cpiSetElementName(&rc, newElement, data);
          if (pc->trace) {
            const char * mbData = mbString(data, pc->iCcsid);
            fprintf(pc->tracefile, "PLUGIN: Created new NAMEVALUE element; 
                    object=0x%x type=0x%x name=",
                    newElement, CCI_ELEMENT_TYPE_NAME_VALUE);
            fprintf(pc->tracefile, "%s\n", mbData);
            fflush(pc->tracefile);
            free((void *)mbData);
          }
          /* Free the memory created in CciNString() */
          free((void *)data);

          /* Add the element */
          cpiAddAsLastChild(&rc, element, newElement);
Related concepts
User-defined parsers
User-defined extensions
Related tasks
Creating a parser in C
Related reference
cpiSetElementName
cpiSetElementValue group
cpiSetElementValueValue
C parser utility functions