cn_demo.tar000644 000000 000000 00000007000 14625017676 013163 0ustar00rootroot000000 000000 cn_demo.cpp000644 000000 000000 00000003663 14625017640 013161 0ustar00rootroot000000 000000 int main(void) { int ret = 0; FieldList fieldList; char buffer[1024] = {0}; RsslFieldList rsslFL; RsslEncodeIterator iter; /*A.init rssl field*/ rsslClearFieldList( &rsslFL ); rsslClearEncodeIterator( &iter ); RsslBuffer rsslBuf; rsslBuf.length = sizeof(buffer); rsslBuf.data = (char *)buffer; RsslDataDictionary dictionary; ret = loadDictionaryFromFile( &dictionary ); if (!ret) { printf("load dictionary failed\n"); return -1; } rsslSetEncodeIteratorRWFVersion( &iter, RSSL_RWF_MAJOR_VERSION, RSSL_RWF_MINOR_VERSION ); rsslSetEncodeIteratorBuffer( &iter, &rsslBuf ); rsslFL.flags = RSSL_FLF_HAS_STANDARD_DATA | RSSL_FLF_HAS_FIELD_LIST_INFO; rsslFL.dictionaryId = dictionary.info_DictionaryId; rsslEncodeFieldListInit( &iter, &rsslFL, 0, 0 ); /*B.set cn character to rssl field*/ /* RSSL_DT_BUFFER RSSL_DT_UTF8_STRING RSSL_DT_ASCII_STRING RSSL_DT_RMTES_STRING */ RsslFieldEntry rsslFEntry = {0}; rsslFEntry.fieldId = 1352; rsslFEntry.dataType = RSSL_DT_UTF8_STRING; char *value = "24附息國債07"; RsslBuffer vbuf = {0}; vbuf.data = value; vbuf.length = strlen(value); printf("encode before: data=%s, len=%d\n", vbuf.data, vbuf.length); ret = rsslEncodeFieldEntry( &iter, &rsslFEntry, (void *)&vbuf ); if (0 != ret) { printf("ret=%d\n", ret); return -2; } rsslEncodeFieldListComplete( &iter, RSSL_TRUE ); StaticDecoder::setRsslData( &fieldList, &rsslBuf, RSSL_DT_FIELD_LIST, RSSL_RWF_MAJOR_VERSION, RSSL_RWF_MINOR_VERSION, &dictionary ); /*C.convert to FieldList of EMA*/ fieldList.forth(1352); const FieldEntry& fe = fieldList.getEntry(); if (DataType::RmtesEnum == fe.getLoadType() ){ printf("decode after: fid %d, type %hu, value %s\n", fe.getFieldId(), fe.getLoadType(), fe.getRmtes().toString().c_str()); } return 0; }