123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- #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:
- /// <summary>
- /// This class is for smart pointer deleter. Because Gdiplus define its own delete.
- /// </summary>
- template <class T>
- class StandardDelete
- {
- public:
- void operator() (T* d) const
- {
- ::delete d;
- }
- };
- public:
- /// <summary>
- /// Gets the name of the folder.
- /// </summary>
- /// <param name="fullPath">The full path.</param>
- /// <returns>the folder name</returns>
- static CString GetFolderName(CString fullPath);
- static CString GetFileNameWithoutExtension(CString fullPath);
- /// <summary>
- /// Gets the name of the file.
- /// </summary>
- /// <param name="fullPath">The full path.</param>
- /// <returns>the file name</returns>
- static CString GetFileName(LPCTSTR fullPath);
- /// <summary>
- /// Get file extension
- /// </summary>
- /// <param name="fullPath">The full path.</param>
- /// <returns>
- /// Return the file extension
- /// </returns>
- static CString GetFileExtension(LPCTSTR fullPath);
- /// <summary>
- /// Get system error string
- /// </summary>
- /// <param name="err">The err.</param>
- /// <returns>
- /// Return the system error string
- /// </returns>
- static LPCTSTR GetSystemErrorString(DWORD err);
- /// <summary>
- /// Strings to double.
- /// </summary>
- /// <param name="a_sValue">The string value.</param>
- /// <param name="a_nValue">The double value.</param>
- /// <returns>
- /// true if successful; otherwise, false.
- /// </returns>
- // 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<std::string> SplitSTDString(std::string& a_sSource, char a_cTok);
- static std::vector<CString> 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<typename _Type>
- static std::vector<const _Type*> GenerateReferenceList(const std::vector<_Type>& inValueList)
- {
- auto itemCount = inValueList.size();
- std::vector<const _Type*> referenceList(itemCount);
- auto* referencePointer = referenceList.data();
- for (auto i = 0u; i < itemCount; ++i)
- {
- referencePointer[i] = &inValueList[i];
- }
- return referenceList;
- }
- };
- }
|