Revision: 9291 https://osdn.net/projects/ttssh2/scm/svn/commits/9291 Author: zmatsuo Date: 2021-05-28 00:42:08 +0900 (Fri, 28 May 2021) Log Message: ----------- codeconvから TCHAR を削除 Modified Paths: -------------- trunk/teraterm/common/codeconv.cpp trunk/teraterm/common/codeconv.h -------------- next part -------------- Modified: trunk/teraterm/common/codeconv.cpp =================================================================== --- trunk/teraterm/common/codeconv.cpp 2021-05-27 14:15:44 UTC (rev 9290) +++ trunk/teraterm/common/codeconv.cpp 2021-05-27 15:42:08 UTC (rev 9291) @@ -1230,155 +1230,6 @@ ////////////////////////////////////////////////////////////////////////////// -tc::tc() -{ - tstr_ = NULL; -} - -tc::tc(const char *strA) -{ - tstr_ = NULL; - assign(strA, CP_ACP); -} - -tc::tc(const char *strA, int code_page) -{ - tstr_ = NULL; - assign(strA, code_page); -} - -tc::tc(const wchar_t *strW) -{ - tstr_ = NULL; - assign(strW); -} - -tc::tc(const tc &obj) -{ - tstr_ = NULL; - copy(obj); -} - -#if defined(MOVE_CONSTRUCTOR_ENABLE) -tc::tc(tc &&obj) noexcept -{ - tstr_ = NULL; - move(obj); -} -#endif - -tc::~tc() -{ - if (tstr_ != NULL) { - free(tstr_); - } -} - -tc& tc::operator=(const char *strA) -{ - assign(strA, CP_ACP); - return *this; -} - -tc& tc::operator=(const wchar_t *strW) -{ - assign(strW); - return *this; -} - -tc &tc::operator=(const tc &obj) -{ - copy(obj); - return *this; -} - -#if defined(MOVE_CONSTRUCTOR_ENABLE) -tc& tc::operator=(tc &&obj) noexcept -{ - move(obj); - return *this; -} -#endif - -tc tc::fromUtf8(const char *strU8) -{ - wchar_t *strW = _MultiByteToWideChar(strU8, 0, CP_UTF8, NULL); - tc _tc = strW; - free(strW); - return _tc; -} - -// void\x82Ȃ\xB5\x82\xAA\x88\xEA\x94ʓI\x82Ǝv\x82\xED\x82\xEA\x82邪\x81A -// VS2005\x82Ń\x8A\x83\x93\x83N\x83G\x83\x89\x81[\x82\xAA\x8Fo\x82Ă\xB5\x82܂\xA4\x82\xBD\x82\xDF void \x92lj\xC1 -tc::operator const TCHAR *(void) const -{ - return cstr(); -} - -const TCHAR *tc::cstr() const -{ - if (tstr_ == NULL) { - return _T(""); - } - return tstr_; -} - -void tc::assign(const char *strA, int code_page) -{ - if (tstr_ != NULL) { - free(tstr_); - } -#if !defined(UNICODE) - (void)code_page; - tstr_ = _strdup(strA); -#else - wchar_t *strW = _MultiByteToWideChar(strA, 0, code_page, NULL); - if (strW != NULL) { - tstr_ = strW; - } else { - tstr_ = NULL; - } -#endif -} - -void tc::assign(const wchar_t *strW) -{ - if (tstr_ != NULL) { - free(tstr_); - } -#if defined(UNICODE) - tstr_ = _wcsdup(strW); -#else - char *strA = _WideCharToMultiByte(strW, 0, CP_ACP, NULL); - if (strA != NULL) { - tstr_ = strA; - } else { - tstr_ = NULL; - } -#endif -} - -void tc::copy(const tc &obj) -{ - if (tstr_ != NULL) { - free(tstr_); - } - tstr_ = _tcsdup(obj.tstr_); -} - -void tc::move(tc &obj) -{ - if (this != &obj) { - if (tstr_ != NULL) { - free(tstr_); - } - tstr_ = obj.tstr_; - obj.tstr_ = NULL; - } -} - -////////////////////////////////////////////////////////////////////////////// - wc::wc() { tstr_ = NULL; Modified: trunk/teraterm/common/codeconv.h =================================================================== --- trunk/teraterm/common/codeconv.h 2021-05-27 14:15:44 UTC (rev 9290) +++ trunk/teraterm/common/codeconv.h 2021-05-27 15:42:08 UTC (rev 9291) @@ -28,7 +28,6 @@ #pragma once -#include <tchar.h> #include "ttcstd.h" #ifdef __cplusplus @@ -79,20 +78,6 @@ char *ToU8W(const wchar_t *strW); char32_t *ToU32W(const wchar_t *strW); -#if defined(_UNICODE) -#define ToTcharA(s) ToWcharA(s) -#define ToTcharW(s) ToWcharW(s) -#define ToTcharU8(s) ToWcharU8(s) -#define ToCharT(s) ToCharW(s) -#define ToU8T(s) ToU8W(s) -#else -#define ToTcharA(s) ToCharA(s) -#define ToTcharW(s) ToCharW(s) -#define ToTcharU8(s) ToCharU8(s) -#define ToCharT(s) ToCharA(s) -#define ToU8T(s) ToU8A(s) -#endif - #ifdef __cplusplus } #endif @@ -131,35 +116,6 @@ void move(u8 &obj); }; -class tc -{ -public: - tc(); - tc(const char *strA); - tc(const char *strA, int code_page); - tc(const wchar_t *strW); - tc(const tc &obj); -#if defined(MOVE_CONSTRUCTOR_ENABLE) - tc(tc &&obj) noexcept; -#endif - ~tc(); - tc& operator=(const char *strA); - tc& operator=(const wchar_t *strW); - tc& operator=(const tc &obj); -#if defined(MOVE_CONSTRUCTOR_ENABLE) - tc& operator=(tc &&obj) noexcept; -#endif - static tc fromUtf8(const char *strU8); - operator const TCHAR *() const; - const TCHAR *cstr() const; -private: - TCHAR *tstr_; - void assign(const char *strA, int code_page); - void assign(const wchar_t *strW); - void copy(const tc &obj); - void move(tc &obj); -}; - class wc { public: