diff options
author | bunnei <bunneidev@gmail.com> | 2014-09-11 06:04:36 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2014-09-11 06:04:36 +0200 |
commit | 532a9e80a0bd242d2937335063b719130405d6bc (patch) | |
tree | 84fe1f054b62edc488a7a9e80eb8f79b2dd05cd0 /src/common | |
parent | Merge pull request #103 from archshift/prune (diff) | |
parent | Moved common_types::Rect from common to Common namespace (diff) | |
download | yuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar yuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar.gz yuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar.bz2 yuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar.lz yuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar.xz yuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar.zst yuzu-532a9e80a0bd242d2937335063b719130405d6bc.zip |
Diffstat (limited to '')
-rw-r--r-- | src/common/common_types.h | 2 | ||||
-rw-r--r-- | src/common/console_listener.cpp | 10 | ||||
-rw-r--r-- | src/common/extended_trace.cpp | 2 | ||||
-rw-r--r-- | src/common/file_search.cpp | 6 | ||||
-rw-r--r-- | src/common/file_util.cpp | 26 | ||||
-rw-r--r-- | src/common/file_util.h | 2 | ||||
-rw-r--r-- | src/common/log_manager.cpp | 2 | ||||
-rw-r--r-- | src/common/mem_arena.cpp | 2 | ||||
-rw-r--r-- | src/common/memory_util.cpp | 2 | ||||
-rw-r--r-- | src/common/msg_handler.cpp | 2 | ||||
-rw-r--r-- | src/common/string_util.cpp | 20 | ||||
-rw-r--r-- | src/common/string_util.h | 8 |
12 files changed, 44 insertions, 40 deletions
diff --git a/src/common/common_types.h b/src/common/common_types.h index 9d41e5971..00fde828d 100644 --- a/src/common/common_types.h +++ b/src/common/common_types.h @@ -100,7 +100,7 @@ union t128 { __m128 a; ///< 128-bit floating point (__m128 maps to the XMM[0-7] registers) }; -namespace common { +namespace Common { /// Rectangle data structure class Rect { public: diff --git a/src/common/console_listener.cpp b/src/common/console_listener.cpp index 6a89edd44..40122224c 100644 --- a/src/common/console_listener.cpp +++ b/src/common/console_listener.cpp @@ -43,7 +43,7 @@ void ConsoleListener::Open(bool Hidden, int Width, int Height, const char *Title // Save the window handle that AllocConsole() created hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // Set the console window title - SetConsoleTitle(UTF8ToTStr(Title).c_str()); + SetConsoleTitle(Common::UTF8ToTStr(Title).c_str()); // Set letter space LetterSpace(80, 4000); //MoveWindow(GetConsoleWindow(), 200,200, 800,800, true); @@ -189,11 +189,11 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool { Str.resize(Str.size() + 1); if (!ReadConsoleOutputCharacter(hConsole, Str.back().data(), ReadBufferSize, coordScreen, &cCharsRead)) - SLog += StringFromFormat("WriteConsoleOutputCharacter error"); + SLog += Common::StringFromFormat("WriteConsoleOutputCharacter error"); Attr.resize(Attr.size() + 1); if (!ReadConsoleOutputAttribute(hConsole, Attr.back().data(), ReadBufferSize, coordScreen, &cAttrRead)) - SLog += StringFromFormat("WriteConsoleOutputAttribute error"); + SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error"); // Break on error if (cAttrRead == 0) break; @@ -219,9 +219,9 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool for (size_t i = 0; i < Attr.size(); i++) { if (!WriteConsoleOutputCharacter(hConsole, Str[i].data(), ReadBufferSize, coordScreen, &cCharsWritten)) - SLog += StringFromFormat("WriteConsoleOutputCharacter error"); + SLog += Common::StringFromFormat("WriteConsoleOutputCharacter error"); if (!WriteConsoleOutputAttribute(hConsole, Attr[i].data(), ReadBufferSize, coordScreen, &cAttrWritten)) - SLog += StringFromFormat("WriteConsoleOutputAttribute error"); + SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error"); BytesWritten += cAttrWritten; coordScreen = GetCoordinates(BytesWritten, LBufWidth); diff --git a/src/common/extended_trace.cpp b/src/common/extended_trace.cpp index 66dae4935..9cd0398ed 100644 --- a/src/common/extended_trace.cpp +++ b/src/common/extended_trace.cpp @@ -278,7 +278,7 @@ void PrintFunctionAndSourceInfo(FILE* file, const STACKFRAME& callstack) GetFunctionInfoFromAddresses((ULONG)callstack.AddrPC.Offset, (ULONG)callstack.AddrFrame.Offset, symInfo); GetSourceInfoFromAddress((ULONG)callstack.AddrPC.Offset, srcInfo); - etfprint(file, " " + TStrToUTF8(srcInfo) + " : " + TStrToUTF8(symInfo) + "\n"); + etfprint(file, " " + Common::TStrToUTF8(srcInfo) + " : " + Common::TStrToUTF8(symInfo) + "\n"); } void StackTrace( HANDLE hThread, const char* lpszMessage, FILE *file ) diff --git a/src/common/file_search.cpp b/src/common/file_search.cpp index cd50ace75..63580f688 100644 --- a/src/common/file_search.cpp +++ b/src/common/file_search.cpp @@ -33,10 +33,10 @@ CFileSearch::CFileSearch(const CFileSearch::XStringVector& _rSearchStrings, cons void CFileSearch::FindFiles(const std::string& _searchString, const std::string& _strPath) { std::string GCMSearchPath; - BuildCompleteFilename(GCMSearchPath, _strPath, _searchString); + Common::BuildCompleteFilename(GCMSearchPath, _strPath, _searchString); #ifdef _WIN32 WIN32_FIND_DATA findData; - HANDLE FindFirst = FindFirstFile(UTF8ToTStr(GCMSearchPath).c_str(), &findData); + HANDLE FindFirst = FindFirstFile(Common::UTF8ToTStr(GCMSearchPath).c_str(), &findData); if (FindFirst != INVALID_HANDLE_VALUE) { @@ -47,7 +47,7 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string& if (findData.cFileName[0] != '.') { std::string strFilename; - BuildCompleteFilename(strFilename, _strPath, TStrToUTF8(findData.cFileName)); + Common::BuildCompleteFilename(strFilename, _strPath, Common::TStrToUTF8(findData.cFileName)); m_FileNames.push_back(strFilename); } diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 04d222ca1..970041007 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -64,7 +64,7 @@ bool Exists(const std::string &filename) StripTailDirSlashes(copy); #ifdef _WIN32 - int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info); + int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); #else int result = stat64(copy.c_str(), &file_info); #endif @@ -81,7 +81,7 @@ bool IsDirectory(const std::string &filename) StripTailDirSlashes(copy); #ifdef _WIN32 - int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info); + int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); #else int result = stat64(copy.c_str(), &file_info); #endif @@ -117,7 +117,7 @@ bool Delete(const std::string &filename) } #ifdef _WIN32 - if (!DeleteFile(UTF8ToTStr(filename).c_str())) + if (!DeleteFile(Common::UTF8ToTStr(filename).c_str())) { WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", filename.c_str(), GetLastErrorMsg()); @@ -139,7 +139,7 @@ bool CreateDir(const std::string &path) { INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); #ifdef _WIN32 - if (::CreateDirectory(UTF8ToTStr(path).c_str(), NULL)) + if (::CreateDirectory(Common::UTF8ToTStr(path).c_str(), NULL)) return true; DWORD error = GetLastError(); if (error == ERROR_ALREADY_EXISTS) @@ -218,7 +218,7 @@ bool DeleteDir(const std::string &filename) } #ifdef _WIN32 - if (::RemoveDirectory(UTF8ToTStr(filename).c_str())) + if (::RemoveDirectory(Common::UTF8ToTStr(filename).c_str())) return true; #else if (rmdir(filename.c_str()) == 0) @@ -247,7 +247,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename) INFO_LOG(COMMON, "Copy: %s --> %s", srcFilename.c_str(), destFilename.c_str()); #ifdef _WIN32 - if (CopyFile(UTF8ToTStr(srcFilename).c_str(), UTF8ToTStr(destFilename).c_str(), FALSE)) + if (CopyFile(Common::UTF8ToTStr(srcFilename).c_str(), Common::UTF8ToTStr(destFilename).c_str(), FALSE)) return true; ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", @@ -335,7 +335,7 @@ u64 GetSize(const std::string &filename) struct stat64 buf; #ifdef _WIN32 - if (_tstat64(UTF8ToTStr(filename).c_str(), &buf) == 0) + if (_tstat64(Common::UTF8ToTStr(filename).c_str(), &buf) == 0) #else if (stat64(filename.c_str(), &buf) == 0) #endif @@ -408,7 +408,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) // Find the first file in the directory. WIN32_FIND_DATA ffd; - HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd); + HANDLE hFind = FindFirstFile(Common::UTF8ToTStr(directory + "\\*").c_str(), &ffd); if (hFind == INVALID_HANDLE_VALUE) { FindClose(hFind); @@ -418,7 +418,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) do { FSTEntry entry; - const std::string virtualName(TStrToUTF8(ffd.cFileName)); + const std::string virtualName(Common::TStrToUTF8(ffd.cFileName)); #else struct dirent dirent, *result = NULL; @@ -475,7 +475,7 @@ bool DeleteDirRecursively(const std::string &directory) #ifdef _WIN32 // Find the first file in the directory. WIN32_FIND_DATA ffd; - HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd); + HANDLE hFind = FindFirstFile(Common::UTF8ToTStr(directory + "\\*").c_str(), &ffd); if (hFind == INVALID_HANDLE_VALUE) { @@ -486,7 +486,7 @@ bool DeleteDirRecursively(const std::string &directory) // windows loop do { - const std::string virtualName(TStrToUTF8(ffd.cFileName)); + const std::string virtualName(Common::TStrToUTF8(ffd.cFileName)); #else struct dirent dirent, *result = NULL; DIR *dirp = opendir(directory.c_str()); @@ -624,7 +624,7 @@ std::string& GetExeDirectory() { TCHAR Dolphin_exe_Path[2048]; GetModuleFileName(NULL, Dolphin_exe_Path, 2048); - DolphinPath = TStrToUTF8(Dolphin_exe_Path); + DolphinPath = Common::TStrToUTF8(Dolphin_exe_Path); DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\')); } return DolphinPath; @@ -819,7 +819,7 @@ bool IOFile::Open(const std::string& filename, const char openmode[]) { Close(); #ifdef _WIN32 - _tfopen_s(&m_file, UTF8ToTStr(filename).c_str(), UTF8ToTStr(openmode).c_str()); + _tfopen_s(&m_file, Common::UTF8ToTStr(filename).c_str(), Common::UTF8ToTStr(openmode).c_str()); #else m_file = fopen(filename.c_str(), openmode); #endif diff --git a/src/common/file_util.h b/src/common/file_util.h index 0871734d4..fdae5c9c8 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -213,7 +213,7 @@ template <typename T> void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) { #ifdef _WIN32 - fstream.open(UTF8ToTStr(filename).c_str(), openmode); + fstream.open(Common::UTF8ToTStr(filename).c_str(), openmode); #else fstream.open(filename.c_str(), openmode); #endif diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp index c2b5d0e2c..43346f279 100644 --- a/src/common/log_manager.cpp +++ b/src/common/log_manager.cpp @@ -120,7 +120,7 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners()) return; - CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args); + Common::CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args); static const char level_to_char[7] = "ONEWID"; sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line, diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp index a456beb28..40d9c03a2 100644 --- a/src/common/mem_arena.cpp +++ b/src/common/mem_arena.cpp @@ -139,7 +139,7 @@ void MemArena::GrabLowMemSpace(size_t size) // a bit more. for (int i = 0; i < 10000; i++) { - std::string file_name = StringFromFormat("/citramem.%d", i); + std::string file_name = Common::StringFromFormat("/citramem.%d", i); fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); if (fd != -1) { diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index 45bf5a496..bab7d9f7a 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp @@ -187,7 +187,7 @@ std::string MemUsage() if (NULL == hProcess) return "MemUsage Error"; if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) - Ret = StringFromFormat("%s K", ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str()); + Ret = Common::StringFromFormat("%s K", Common::ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str()); CloseHandle(hProcess); return Ret; diff --git a/src/common/msg_handler.cpp b/src/common/msg_handler.cpp index 3e02ec4d7..b3556aaa8 100644 --- a/src/common/msg_handler.cpp +++ b/src/common/msg_handler.cpp @@ -72,7 +72,7 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...) va_list args; va_start(args, format); - CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args); + Common::CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args); va_end(args); ERROR_LOG(MASTER_LOG, "%s: %s", caption.c_str(), buffer); diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index b0c65d47d..9199e30bc 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -13,20 +13,18 @@ #include <iconv.h> #endif +namespace Common { + /// Make a string lowercase -void LowerStr(char* str) { - for (int i = 0; str[i]; i++) { - str[i] = tolower(str[ i ]); - } +std::string ToLower(std::string str) { + std::transform(str.begin(), str.end(), str.begin(), ::tolower); + return str; } /// Make a string uppercase -void UpperStr(char* str) { - for (int i=0; i < strlen(str); i++) { - if(str[i] >= 'a' && str[i] <= 'z') { - str[i] &= 0xDF; - } - } +std::string ToUpper(std::string str) { + std::transform(str.begin(), str.end(), str.begin(), ::toupper); + return str; } // faster than sscanf @@ -546,3 +544,5 @@ std::string UTF16ToUTF8(const std::wstring& input) } #endif + +} diff --git a/src/common/string_util.h b/src/common/string_util.h index ba4cd363e..16ce39bc1 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -12,11 +12,13 @@ #include "common/common.h" +namespace Common { + /// Make a string lowercase -void LowerStr(char* str); +std::string ToLower(std::string str); /// Make a string uppercase -void UpperStr(char* str); +std::string ToUpper(std::string str); std::string StringFromFormat(const char* format, ...); // Cheap! @@ -111,3 +113,5 @@ inline std::string UTF8ToTStr(const std::string& str) #endif #endif + +} |