#ifndef _OICOMM_OICOMMFUN_H #define _OICOMM_OICOMMFUN_H #include "OIComm_global.h" #include "stdafx.h" #include "OIHighTime.h" namespace OIComm { typedef vector CWStringVector; typedef vector CUIntVector; ///////////////////////////////////////////////////////////////////////////// // COICommFun window class OICOMM_API COICommFun { // Construction public: COICommFun(); virtual ~COICommFun(); // Attributes public: // Operations public: static wstring GetPathName( const wstring &strFilePath ); static wstring GetFileName( const wstring &strFilePath ); static wstring GetFileTitle( const wstring &strFileName ); static wstring GetFileExt( const wstring &strFileName ); static wstring GetCurAppFullPath(); static wstring GetCurAppPath(); static bool IsFolderExist( const wstring &strPathName ); static bool CreateFolder( const wstring &strPathName ); static size_t GetDiskFreeSize( const wstring &strPath ); static size_t GetFileSize( const wstring &strFilePath ); static bool DeleteFile( const wstring &strFilePath ); static bool MoveFile( const wstring &strSourceFile, const wstring &strDestFile ); static bool SetFileModifyTime( const wstring &strFilePath, const COIHighTime &tmModify ); static bool GetStrItem( wstring &strBuffer, wstring &strItem, const wstring &strApart ); static wstring GenArrayStr( CWStringVector &asItems, const wstring &strApart = L"," ); static bool ParseStrToArray( wstring strBuffer, CWStringVector &asItems, const wstring &strApart ); static int FindStrItem( CWStringVector &asItems, const wstring &strItem ); static int FindIntItem( CUIntVector &anItems, int nItem ); static bool IsNumber( wstring strNumber ); static wstring FormatFloat( double fValue ); static wstring& ReplaceStr( wstring &strBuff, const wstring &strToReplaced, const wstring &strNewChars ); static wstring& TrimLeft( wstring &strBuff, const wchar_t &chEraseChar = L' ' ); static wstring& TrimRight( wstring &strBuff, const wchar_t &chEraseChar = L' ' ); static wstring& Trim( wstring &strBuff, const wchar_t &chEraseChar = L' ' ); static wstring& ToLower( wstring &strBuff ); static wstring& ToUpper( wstring &strBuff ); static wstring GenXMLNodeStr( wstring strNodeName, wstring strNodeValue ); static wstring GenJsonNodeStr( wstring strNodeName, wstring strNodeValue ); static wstring FormatXMLNodeValue( wstring strNodeValue ); static wstring FormatJsonNodeValue( wstring strNodeValue ); static COIHighTime GetCurDate(); static wstring GetCurDateStr(); static void GetStartEndDate( int nYear, int nMonth, wstring &strStartDate, wstring &strEndDate ); static void Sleep( int ms ); static UINT GenModValue( wstring strKey, UINT nMod ); static UINT GenModValue( DWORD dwKey, UINT nMod ); static DWORD GenStrAscSum( wstring strKey ); static wstring GenMD5( wstring strBuffer ); static string WideChar2MultiByte( const wchar_t *pszWideChar, bool bIsUTF8 = false ); static wstring MultiByte2WideChar( const char *pszMultiByte, bool bIsUTF8 = false ); static char * Str2Base64( const unsigned char *s, char *t, int n ); static const char * Base642Str( const char *s, char *t, size_t l, int *n ); static bool WriteLogFile( const wstring &strFile, const wstring &strLog ); }; } // End of namespace OIComm #endif // _OICOMM_OICOMMFUN_H