MChattingFilter.h
00001 #ifndef _MCHATTINGFILTER_H 00002 #define _MCHATTINGFILTER_H 00003 00004 #include <vector> 00005 #include <string> 00006 #include <utility> 00007 00008 00009 class MZFileSystem; 00010 00011 00012 using std::pair; 00013 using std::string; 00014 using std::vector; 00015 00016 typedef vector< pair<string, string> > AbsVec; 00017 typedef AbsVec::iterator AbsVecIter; 00018 typedef pair< string, string > AbsPair; 00019 00020 00021 00022 class MChattingFilter 00023 { 00024 public : 00025 MChattingFilter(); 00026 ~MChattingFilter(); 00027 00028 static MChattingFilter* GetInstance() 00029 { 00030 static MChattingFilter ChattingFilter; 00031 return &ChattingFilter; 00032 } 00033 00034 string AbuseWordPasser( const string& strAbuseWord ); 00035 00036 bool Create( MZFileSystem* pfs, const char* pszAbuseFile ); 00037 bool ExistAbuse( const char* pszMsg, char* pszConvertMsg = 0, const unsigned int nLength = 0 ); 00038 00039 bool LoadAbuseFile( MZFileSystem* pfs, const char* pszAbuseFile ); 00040 00041 void Release(); 00042 00043 void SkipBlock( char*& prfBuf ); 00044 00045 #ifdef _DEBUG 00046 void TestOutput( const char* pszReadFile ); 00047 #endif 00048 00049 private : 00050 bool m_bCreated; 00051 AbsVec m_AbsVec; 00052 00053 bool FindWord(const char* szWord, const char* szText); 00054 bool CheckMultiByte(string& str, string::size_type nIndex); 00055 void RemoveAscii(string& str); // 욕설검색에 아스키문자는 제거해서 검색한다. 00056 }; 00057 00058 00059 00060 00061 class VectorPairCompare 00062 { 00063 public : 00064 VectorPairCompare( const char* pszWord ) : m_CmpWord( pszWord ) {} 00065 VectorPairCompare( const string& strWord ) : m_CmpWord( strWord ) {} 00066 ~VectorPairCompare() {} 00067 00068 bool operator () ( AbsPair& ap ) const 00069 { 00070 if( m_CmpWord == ap.first ) 00071 return true; 00072 00073 return false; 00074 } 00075 00076 private : 00077 VectorPairCompare() {} 00078 00079 string m_CmpWord; 00080 }; 00081 00082 00083 00084 inline MChattingFilter* MGetChattingFilter() { return MChattingFilter::GetInstance(); } 00085 00086 00087 #endif
MAIET entertainment