#include "StdAfx.h" #include "UIIDList.h" #include "Lexer.h" #include "Parser.h" #include "FileSystem.h" #include "MemFile.h" cUIIDList::cUIIDList() { } cUIIDList::~cUIIDList() { } bool cUIIDList::Load( const cString& pathName ) { /// ÆÄÀÏ ¿­±â cFileLoader loader; if( loader.Open( pathName, true ) == false ) { return false; } /// ½ºÅ² ÆÄÀÏÀÇ °æ·Î ÃßÃâ cString path; ::GetFilePath( &path, pathName ); /// ·º¼­¿¡ ¹äÁÖ°í ÆÄ½Ì cToken token; cLexer lexer( loader.GetBufferPtr(), loader.GetSize() ); cParser parser( &lexer, pathName ); cString propName; unsigned int propID = 0; /// ±×´ÙÀ½ÅäÅ«À» °è¼Ó °Ë»ç while( lexer.IsEnd() == false ) { lexer.GetNextToken( &token ); switch( token.mType ) { case eTOKEN_ERROR: return false; case eTOKEN_NULL: continue; case eTOKEN_STR: { /// ÇÁ·ÎÆÛƼ À̸§°ú ¾ÆÀ̵𰪠¹Þ¾Æ¿À±â propName = token; propID = parser.ParseInt(); } break; default: assert( 0 && "invalid token" ); return false; } /// ³ëµå ½ºÅ² ¸Ê¿¡ Ãß°¡ if( mIDHashMap.Insert( propName, propID ) == false ) { assert( 0 && "failed to insert prop name, maybe already exist" ); return false; } } return true; } /// ÁÖÀÇ»çÇ× : ¾ÆÀ̵𠸮ÅÏ unsigned int cUIIDList::GetPropID( const cString& propname ) const { cIDHashMap::cConstIterator i = mIDHashMap.Find( propname ); if( i == mIDHashMap.End() ) { return 0; } return i->mSecond; }