From b76db460769d30b5851481880face712b6102d53 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 29 Aug 2023 10:09:35 +0200 Subject: [PATCH] system: simplify and streamline system char and string type names "sys_char" sticks out of "wchar_t", "char32_t", "uint32_t"... Likewise, "sys_string" out of "string", "wstring", "u16string", "u32string"... Signed-off-by: Simon Rozman --- UnitTests/stream.cpp | 8 ++++---- include/stdex/stream.hpp | 14 +++++++------- include/stdex/system.hpp | 18 +++++++++++++++--- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/UnitTests/stream.cpp b/UnitTests/stream.cpp index aa8d6bfd4..53d3a2b78 100644 --- a/UnitTests/stream.cpp +++ b/UnitTests/stream.cpp @@ -46,7 +46,7 @@ namespace UnitTests memory_file f1(mul(total, sizeof(size_t))); - sys_string filename2, filename3; + sstring filename2, filename3; filename2 = filename3 = temp_path(); filename2 += _T("stdex-stream-replicator-2.tmp"); file f2( @@ -105,9 +105,9 @@ namespace UnitTests TEST_METHOD(open_close) { cached_file dat(invalid_handle, state_t::fail, 4096); - const sys_string filepath = temp_path(); + const sstring filepath = temp_path(); constexpr size_t count = 3; - sys_string filename[count]; + sstring filename[count]; stdex::stream::fpos_t start[count]; for (size_t i = 0; i < count; ++i) { filename[i] = filepath + sprintf(_T("stdex-stream-open_close%zu.tmp"), NULL, i); @@ -138,7 +138,7 @@ namespace UnitTests } protected: - static sys_string temp_path() + static sstring temp_path() { #ifdef _WIN32 TCHAR temp_path[MAX_PATH]; diff --git a/include/stdex/stream.hpp b/include/stdex/stream.hpp index 08fafc883..9e4c3da6c 100644 --- a/include/stdex/stream.hpp +++ b/include/stdex/stream.hpp @@ -2440,7 +2440,7 @@ namespace stdex /// \param[in] filename Filename /// \param[in] mode Bitwise combination of mode_t flags /// - file(_In_z_ const sys_char* filename, _In_ int mode) + file(_In_z_ const schar_t* filename, _In_ int mode) { open(filename, mode); } @@ -2451,7 +2451,7 @@ namespace stdex /// \param[in] filename Filename /// \param[in] mode Bitwise combination of mode_t flags /// - void open(_In_z_ const sys_char* filename, _In_ int mode) + void open(_In_z_ const schar_t* filename, _In_ int mode) { if (m_h != invalid_handle) close(); @@ -2756,7 +2756,7 @@ namespace stdex /// \param[in] mode Bitwise combination of mode_t flags /// \param[in] cache_size Size of the cache block /// - cached_file(_In_z_ const sys_char* filename, _In_ int mode, _In_ size_t cache_size = default_cache_size) : + cached_file(_In_z_ const schar_t* filename, _In_ int mode, _In_ size_t cache_size = default_cache_size) : cache(cache_size), m_source(filename, mode & mode_for_writing ? mode | mode_for_reading : mode) { @@ -2775,7 +2775,7 @@ namespace stdex /// \param[in] mode Bitwise combination of mode_t flags /// \param[in] cache_size Size of the cache block /// - void open(_In_z_ const sys_char* filename, _In_ int mode) + void open(_In_z_ const schar_t* filename, _In_ int mode) { invalidate_cache(); if (!ok()) _Unlikely_{ @@ -2881,7 +2881,7 @@ namespace stdex /// \param[in] filename Filename /// \param[in] mode Bitwise combination of mode_t flags /// - memory_file(_In_z_ const sys_char* filename, _In_ int mode) : memory_file() + memory_file(_In_z_ const schar_t* filename, _In_ int mode) : memory_file() { load(filename, mode); } @@ -2927,7 +2927,7 @@ namespace stdex /// \param[in] filename Filename /// \param[in] mode Bitwise combination of mode_t flags /// - void load(_In_z_ const sys_char* filename, _In_ int mode) + void load(_In_z_ const schar_t* filename, _In_ int mode) { file f(filename, (mode & ~hint_random_access) | mode_for_reading | hint_sequential_access); if (!f.ok()) { @@ -2960,7 +2960,7 @@ namespace stdex /// \param[in] filename Filename /// \param[in] mode Bitwise combination of mode_t flags /// - void save(_In_z_ const sys_char* filename, _In_ int mode) + void save(_In_z_ const schar_t* filename, _In_ int mode) { file f(filename, (mode & ~hint_random_access) | mode_for_writing | hint_sequential_access); if (!f.ok()) { diff --git a/include/stdex/system.hpp b/include/stdex/system.hpp index b7ddbef86..5a62fc05e 100644 --- a/include/stdex/system.hpp +++ b/include/stdex/system.hpp @@ -46,16 +46,28 @@ namespace stdex /// Character type for system functions /// #if defined(_WIN32) - using sys_char = TCHAR; + using schar_t = TCHAR; #else - using sys_char = char; + using schar_t = char; #define _T(x) x #endif + /// + /// Character type for system functions for backward compatibility + /// Use stdex::schar_t + /// + using sys_char = schar_t; + /// /// String for system functions /// - using sys_string = std::basic_string; + using sstring = std::basic_string; + + /// + /// String for system functions for backward compatibility + /// Use stdex::sstring + /// + using sys_string = sstring; /// /// Operating system object (file, pipe, anything with an OS handle etc.)