#include "stdafx.h" #include "FilterManager.h" #include "Tokenizer.h" bool cFilterManager::LoadFilter( const cStringW& pathName ) { /// ÆÄÀÏ¿­±â cFileLoaderW loader; if( loader.Open( pathName.Cstr(), true ) == false ) { assert( 0 && "failed to load filter script" ); return false; } cTokenizerW tokenizer( loader.GetBufferPtr(), loader.GetSize(), L"\t\r\n", pathName.Cstr() ); cStringW str; /// Àüü ¸ÅÄ¡ ÇÊÅÍ´Ü¾î ·Îµå while( tokenizer.IsEnd() == false ) { tokenizer.GetNext( &str ); if( str.Compare( L"WholeMatch" ) == 0 ) continue; /// ÀÌ ´Ü¾î°¡³ª¿À¸é ºÎºÐ ÇÊÅÍ ·Îµå·Î ¹Ù²îµµ·Ï ÇÑ´Ù if( str.Compare( L"PartMatch" ) == 0 ) break; str.ToLower(); if( mWholeSet.Insert( str ) == false ) { assert( 0 && "failed to insert filter set" ); return false; } } /// ºÎºÐ ¸ÅÄ¡ ÇÊÅÍ ´Ü¾î ·Îµå while( tokenizer.IsEnd() == false ) { tokenizer.GetNext( &str ); str.ToLower(); /// ۰ª »©³»±â TCHAR key[2] = {0,}; ::_tcsncpy_s( key, str.Cstr(), 1 ); /// cPartMap::cIterator i = mPartMap.Find( key ); if( i == mPartMap.End() ) { /// ±âÁ¸ ۰¡ ¾øÀ¸¸é »ý¼º /// °°Àº ±ÛÀÚ·Î ½ÃÀ۵Ǵ ´Ü¾îµé ¹­À½ ¹è¿­ cSiblingArr* pSiblingArr = new cSiblingArr; pSiblingArr->PushBack( str ); if( mPartMap.Insert( key, pSiblingArr ) == false ) { assert( 0 && "failed to insert partMatch word" ); return false; } } else { /// ±âÁ¸ ۰¡ Á¸ÀçÇÏ¸é ¹è¿­¿¡ »ðÀÔÇϱâ cSiblingArr* pSiblingArr = (cSiblingArr*)(i->mSecond); pSiblingArr->PushBack( str ); } } return true; } bool cFilterManager::FindWholeMatch( const cStringT& str ) { cWholeSet::cIterator i = mWholeSet.Find( str ); if( i == mWholeSet.End() ) return false; else return true; }