cpiCreateAndInitializeElement

목적

구문 트리에 연결되지 않은, 지정된 구문 분석기 소유의 구문 요소를 작성합니다. 요소는 type, name, firstChildCompletelastChildComplete 매개변수 값으로 부분적으로 초기화됩니다.

구문

CciElement* cpiCreateAndInitializeElement(
    int*                   returnCode,
    CciParser*      parser,
    CciElementType  type,
    const CciChar*  name,
    CciBool         firstChildComplete,
    CciBool         lastChildComplete);

매개변수

returnCode
함수의 리턴 코드를 수신합니다(출력).
가능한 리턴 코드는 다음과 같습니다.
  • CCI_SUCCESS
  • CCI_EXCEPTION
  • CCI_FAILURE
  • CCI_INV_PARSER_OBJECT
parser
구문 분석기 오브젝트의 주소를 지정합니다(입력). 이 주소는 cpiCreateContext 구현 함수의 매개변수로 구문 분석기에 전달됩니다.
type
작성 중인 요소의 유형을 지정합니다(입력).
name
요소의 설명식 이름을 지정합니다(입력).
firstChildComplete
구문 요소의 firstChildComplete 플래그 값을 지정합니다(입력).
lastChildComplete
구문 요소의 lastChildComplete 플래그 값을 지정합니다(입력).

리턴 값

함수가 정상적으로 실행되면, 새 요소 오브젝트의 주소가 리턴됩니다. 정상적으로 실행되지 않으면, 0 값(CCI_NULL_ADDR)이 리턴되고 returnCode는 오류의 이유를 표시합니다.

샘플

/* Advance to the end of the value */
          while (pc->iCurrentCharacter != quoteChar) {
                        advance( (PARSER_CONTEXT_ST *)context, parser );
          }

                  /* Get a pointer to the end of the tag */
          endMarker = (char*)pc->iBuffer+(int)pc->iIndex;

                  /* Compute the size of the tag */
                  markedSize = (size_t)endMarker-(int)startMarker;

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

                    /* Create a new name-value element for the attribute */
                    newElement = cpiCreateAndInitializeElement(&rc, parser, type, name);
                    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);
관련 개념
사용자 정의 구문 분석기
사용자 정의 확장 구성요소
관련 태스크
C로 구문 분석기 작성
관련 참조
cpiCreateElement
C 구문 분석기 유틸리티 함수
주의사항 | 등록상표 | 다운로드 | 라이브러리 | 지원 | 피드백
Copyright IBM Corporation 1999, 2006 마지막 갱신 날짜: 2006/08/21
as08390_