gusucode.com > 通用协议编解码模块C#源码程序 > 通用协议编解码模块/codec_src/codec_test/codec_test/Test/CodecTest/EnumTableTest.cpp

    // EnumTableTest.cpp: implementation of the EnumTableTest class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CodecTest.h"
#include "EnumTableTest.h"

#include "conio.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

using namespace std;


void EnumTableTest()
{
	IEnumTable *pEnumTable = NULL;

//	if (pEnumTable = CodecServ::GetEnumTable("SampleTable"))
	if (pEnumTable = g_GetEnumTable("SampleTable"))
	{
		INT n, nCount = pEnumTable->GetEnumCount();

		cout << "Table Name: " << pEnumTable->GetEnumTableName() << endl;
		cout << "Table Description: " << pEnumTable->GetEnumTableDescription() << endl;
		cout << "Item count: " << nCount << endl;

		cout << endl << "Iteration: " << endl;

		for (n = 0; n < nCount; n++)
		{
			DWORD nValue = 0;
			pEnumTable->GetEnumValue(n, nValue);

			cout << "    Item " << n << ": " << nValue << ", " << 
				pEnumTable->GetEnumName(n) << ", " << pEnumTable->GetEnumDescription(n) << endl;
		}

		cout << endl;

		cout << "Find Name Vn: " << pEnumTable->FindEnum("Vn") << endl;
		cout << "Find Value 1: " << pEnumTable->FindEnum(1) << endl;
	}
	else
	{
		cerr << "Enum Table Not Found!" << endl;
	}
}