#pragma once namespace OTSController { #ifdef UNICODE #define isdigit_t iswdigit #else #define isdigit_t isdigit #endif class CControllerHelper /*: private boost::noncopyable*/ { private: CControllerHelper(void) = delete; ~CControllerHelper(void) = delete; public: /// /// This class is for smart pointer deleter. Because Gdiplus define its own delete. /// template class StandardDelete { public: void operator() (T* d) const { ::delete d; } }; public: /// /// Gets the name of the folder. /// /// The full path. /// the folder name static CString GetFolderName(CString fullPath); static CString GetFileNameWithoutExtension(CString fullPath); /// /// Gets the name of the file. /// /// The full path. /// the file name static CString GetFileName(LPCTSTR fullPath); /// /// Get file extension /// /// The full path. /// /// Return the file extension /// static CString GetFileExtension(LPCTSTR fullPath); /// /// Get system error string /// /// The err. /// /// Return the system error string /// static LPCTSTR GetSystemErrorString(DWORD err); /// /// Strings to double. /// /// The string value. /// The double value. /// /// true if successful; otherwise, false. /// // Strings to double static BOOL StringToDouble(LPCTSTR a_sValue, double& a_nValue); static BOOL IsDoubleString(LPCTSTR a_sValue); static int CharToWChar(const char* a_psSource, wchar_t* a_psDest); static int WCharToChar(const wchar_t* a_psSource, char* a_psDest); static CString CharToString(const char* a_psSource); static DWORD ConvStreamToByteArr(IStream *stream, BYTE **byte); static std::vector SplitSTDString(std::string& a_sSource, char a_cTok); static std::vector SplitString(const CString& a_sSource, LPCTSTR a_sTok); static void EnsureStringLengthNoMoreThan(CString& ioString, int inMaxLength); static void TrimSTDString(std::string& a_sString, char a_cTrimChar = ' '); template static std::vector GenerateReferenceList(const std::vector<_Type>& inValueList) { auto itemCount = inValueList.size(); std::vector referenceList(itemCount); auto* referencePointer = referenceList.data(); for (auto i = 0u; i < itemCount; ++i) { referencePointer[i] = &inValueList[i]; } return referenceList; } }; }