메시지 브로커에 지정된 구문 분석기 팩토리의 인스턴스를 하나 작성합니다. 초기화 함수 bipGetParserFactory에서만 호출될 수 있습니다. 이 함수는 메시지 브로커가 'lil'를 로드할 때 호출됩니다. cpiCreateParserFactory가 다른 때 호출될 경우 결과를 예측할 수 없습니다.
CciFactory* cpiCreateParserFactory( int* returnCode, CciChar* name);
함수가 정상적으로 실행되면, 구문 분석기 팩토리 오브젝트의 주소가 리턴됩니다. 정상적으로 실행되지 않으면, 0 값(CCI_NULL_ADDR)이 리턴되고 returnCode는 오류의 이유를 표시합니다.
다음 예는 샘플 구문 분석기 파일 BipSampPluginParser.c에서 발췌한 것입니다(862 - 901행).
void LilFactoryExportPrefix * LilFactoryExportSuffix bipGetParserFactory() { /* Declare variables */ CciFactory* factoryObject; int rc; static CPI_VFT vftable = {CPI_VFT_DEFAULT}; /* Before we proceed we need to initialise all the static constants */ /* that may be used by the plug-in. */ initParserConstants(); /* Setup function table with pointers to parser implementation functions */ vftable.iFpCreateContext = cpiCreateContext; vftable.iFpParseBufferEncoded = cpiParseBufferEncoded; vftable.iFpParseFirstChild = cpiParseFirstChild; vftable.iFpParseLastChild = cpiParseLastChild; vftable.iFpParsePreviousSibling = cpiParsePreviousSibling; vftable.iFpParseNextSibling = cpiParseNextSibling; vftable.iFpWriteBufferEncoded = cpiWriteBufferEncoded; vftable.iFpDeleteContext = cpiDeleteContext; vftable.iFpSetElementValue = cpiSetElementValue; vftable.iFpElementValue = cpiElementValue; vftable.iFpNextParserClassName = cpiNextParserClassName; vftable.iFpSetNextParserClassName = cpiSetNextParserClassName; vftable.iFpNextParserEncoding = cpiNextParserEncoding; vftable.iFpNextParserCodedCharSetId = cpiNextParserCodedCharSetId; /* Create the parser factory for this plugin */ factoryObject = cpiCreateParserFactory(&rc, constParserFactory); if (factoryObject) { /* Define the classes of message supported by the factory */ cpiDefineParserClass(&rc, factoryObject, constPXML, &vftable); } else { /* Error: Unable to create parser factory */ } /* Return address of this factory object to the broker */ return(factoryObject); }