#pragma once #include #include "AssertX.h" #include "SmartPtr.h" #include "StringUtil.h" #ifndef SAFE_DELETE #define SAFE_DELETE(x) if(x) { delete x; x=NULL; } #endif // SAFE_DELETE #ifndef SAFE_DELETEA #define SAFE_DELETEA(x) if(x) { delete []x; x=NULL; } #endif // SAFE_DELETEA #ifndef SAFE_DELETE_VEC template void SAFE_DELETE_VEC( T &vecDel, bool bClearly = true ) { vecDel.clear(); if( bClearly ) { vecDel.swap( T() ); // ÀÌ·¸°Ô ÇØ¾ß capacity °¡ 0 À̵ȴÙ.. x.swap(x) ´Â ¾Æ¹« µ¿ÀÛ¾ÈÇÔ. } } #endif // SAFE_DELETE_VEC //#ifndef SAFE_DELETE_VEC //#define SAFE_DELETE_VEC(x) { x.clear(); x.swap(x); } //#endif // SAFE_DELETE_VEC #ifndef SAFE_DELETE_VECF #define SAFE_DELETE_VECF(x, f) \ for( DWORD MACRO_0 = 0; MACRO_0second ); \ } \ SAFE_DELETE_MAP(x) #endif //SAFE_DELETE_PMAP #ifndef SAFE_DELETEA_PMAP #define SAFE_DELETEA_PMAP(t, x) \ for( t::iterator t##_iter=x.begin(); t##_iter != x.end(); t##_iter++ ) { \ SAFE_DELETEA( t##_iter->second ); \ } \ SAFE_DELETE_MAP(x) #endif //SAFE_DELETE_PMAP ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef SAFE_DELETE_PMAPF #define SAFE_DELETE_PMAPF(t, x, f) \ for( t::iterator t##_iter=x.begin(); t##_iter != x.end(); t##_iter++ ) { \ f; \ SAFE_DELETE( t##_iter->second ); \ } \ SAFE_DELETE_MAP(x) #endif //SAFE_DELETE_PMAPF #ifndef SAFE_DELETE_AVEC #define SAFE_DELETE_AVEC(x) \ for( DWORD MACRO_0 = 0; MACRO_0Release(); \ x = NULL; \ } #else #define SAFE_RELEASE(x) if(x) { x->Release(); x=NULL; } #define ADD_D3D_RES(x) __noop #endif #else #define ADD_D3D_RES(x) __noop #endif #ifndef SAFE_RELEASE_PVEC #define SAFE_RELEASE_PVEC(x) \ for( DWORD MACRO_0 = 0; MACRO_0Release(); x.Identity(); } #endif //SAFE_RELEASE_SPTR #ifndef SAFE_RELEASE_SPTRVEC #define SAFE_RELEASE_SPTRVEC(x) \ for( DWORD MACRO_0 = 0; MACRO_0 &szVecResult, bool bIncludeFolder = false, bool bSearchSubDir = false, bool bIncludeFolderName = false ); void FindFileListInDirectory( const char *szFolderName, const char *szExt, std::vector &szVecResult, bool bIncludeFolder = false, bool bSearchSubDir = false, bool bIncludeFolderName = false ); void GetFullPath( const char *pSource, char *pTarget ); void _FindFolder( const char *szFolderName, std::vector &szVecResult, bool bSearchSubDir = false, char *szRootPathName = NULL ); void _FindFolder( const char *szFolderName, std::vector &szVecResult, bool bSearchSubDir = false, char *szRootPathName = NULL ); const char *FindFileName( const char *pFullName ); bool IsFullName( const char *pFileName ); // File Function bool _CopyFile( const char *pSource, const char *pTarget, bool bExistOverwrite = true, bool bMoveFile = false ); void DeleteFolder( const char *pFolder ); void CreateFolder( const char *pFolder ); // Registry Function LONG GetRegistryNumber(HKEY hKey, char *pSubKey, char *pValueName, DWORD &dwValue); LONG SetRegistryNumber(HKEY hKey, char *pSubKey, char *pValueName, DWORD dwValue); LONG GetRegistryString(HKEY hKey, char *pSubKey, char *pValueName, char *pValue, int nMaxLength = 0 ); LONG SetRegistryString(HKEY hKey, char *pSubKey, char *pValueName, char *pValue ); LONG GetRegistryBinary(HKEY hKey, char *pSubKey, char *pValueName, void *pValue, int &nSize ); LONG SetRegistryBinary(HKEY hKey, char *pSubKey, char *pValueName, void *pValue, int nSize ); LONG DeleteRegistry( HKEY hKey, char *pSubKey ); LONG AddRegistryKey( HKEY hKey, char *pSubKey, char *pValueName ); // Simple Function template void _Swap( X &A, X &B ) { X Temp = A; A = B; B = Temp; } void SSE_memcpy(void *pDest,void *pSrc,long nCnt); // std::string class CStream; void ReadStdString( std::string &szStr, CStream *pStream ); void WriteStdString( std::string &szStr, CStream *pStream ); void SetBitFlag( char *pBuffer, int nArrayIndex, bool bFlag ); bool GetBitFlag( char *pBuffer, int nArrayIndex ); int GetDateValue( int nYear, int nMonth, int nDay ); // Note : À©µµ¿ì ŸÀÔ ¾ò±â // ¾Æ·¡¿Í °°Àº ¸®ÅϰªÀ» °¡Áý´Ï´Ù. // -1: Failed // 1 : Windows 95 // 2 : Windows 98, 98SE // 3 : Windows ME // 4 : Windows NT // 5 : Windows 2000 // 6 : Windows XP // 7 : Windows Server 2003 // 8 : Windows Vista int GetOSVersionType(); unsigned long GetHashCode( const char* String ); INT64 GetHashCode64( const char* String ); bool ExecCommand( char *pCommand, std::string *pszOutput ); // °Á ³ÖÀº¼ýÀÚ ¸®ÅÏÇÔ¼öÀε¥.. µÚ¿¡ À妽º¸¦ 2°³¾¿ ¦Áö¾î¼­ ³ÖÀ¸¸é ÇØ´ç À妽ºÀÏ °æ¿ì¿¡ ¹Ù²ã¼­ ¸®ÅÏ int GetValue2ExceptionSwap( int nValue, int nSwapValueCount, ... ); #ifdef _FINAL_BUILD #define OutputDebug( fmt, ... ) do { } while( false ) #else #define OutputDebug( fmt, ... ) OutputDebugFunc( fmt, __VA_ARGS__ ) #endif bool DnLocalTime_s( struct tm * _Tm, const time_t * _Time ); #define ThreadDelay() Sleep(0); DWORD CalcDecreaseColor( DWORD OrigColor, DWORD DescColor );