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 <simon@rozman.si>
This commit is contained in:
Simon Rozman 2023-08-29 10:09:35 +02:00
parent e1f27662a1
commit b76db46076
3 changed files with 26 additions and 14 deletions

View File

@ -46,7 +46,7 @@ namespace UnitTests
memory_file f1(mul(total, sizeof(size_t))); memory_file f1(mul(total, sizeof(size_t)));
sys_string filename2, filename3; sstring filename2, filename3;
filename2 = filename3 = temp_path(); filename2 = filename3 = temp_path();
filename2 += _T("stdex-stream-replicator-2.tmp"); filename2 += _T("stdex-stream-replicator-2.tmp");
file f2( file f2(
@ -105,9 +105,9 @@ namespace UnitTests
TEST_METHOD(open_close) TEST_METHOD(open_close)
{ {
cached_file dat(invalid_handle, state_t::fail, 4096); 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; constexpr size_t count = 3;
sys_string filename[count]; sstring filename[count];
stdex::stream::fpos_t start[count]; stdex::stream::fpos_t start[count];
for (size_t i = 0; i < count; ++i) { for (size_t i = 0; i < count; ++i) {
filename[i] = filepath + sprintf(_T("stdex-stream-open_close%zu.tmp"), NULL, i); filename[i] = filepath + sprintf(_T("stdex-stream-open_close%zu.tmp"), NULL, i);
@ -138,7 +138,7 @@ namespace UnitTests
} }
protected: protected:
static sys_string temp_path() static sstring temp_path()
{ {
#ifdef _WIN32 #ifdef _WIN32
TCHAR temp_path[MAX_PATH]; TCHAR temp_path[MAX_PATH];

View File

@ -2440,7 +2440,7 @@ namespace stdex
/// \param[in] filename Filename /// \param[in] filename Filename
/// \param[in] mode Bitwise combination of mode_t flags /// \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); open(filename, mode);
} }
@ -2451,7 +2451,7 @@ namespace stdex
/// \param[in] filename Filename /// \param[in] filename Filename
/// \param[in] mode Bitwise combination of mode_t flags /// \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) if (m_h != invalid_handle)
close(); close();
@ -2756,7 +2756,7 @@ namespace stdex
/// \param[in] mode Bitwise combination of mode_t flags /// \param[in] mode Bitwise combination of mode_t flags
/// \param[in] cache_size Size of the cache block /// \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), cache(cache_size),
m_source(filename, mode & mode_for_writing ? mode | mode_for_reading : mode) 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] mode Bitwise combination of mode_t flags
/// \param[in] cache_size Size of the cache block /// \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(); invalidate_cache();
if (!ok()) _Unlikely_{ if (!ok()) _Unlikely_{
@ -2881,7 +2881,7 @@ namespace stdex
/// \param[in] filename Filename /// \param[in] filename Filename
/// \param[in] mode Bitwise combination of mode_t flags /// \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); load(filename, mode);
} }
@ -2927,7 +2927,7 @@ namespace stdex
/// \param[in] filename Filename /// \param[in] filename Filename
/// \param[in] mode Bitwise combination of mode_t flags /// \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); file f(filename, (mode & ~hint_random_access) | mode_for_reading | hint_sequential_access);
if (!f.ok()) { if (!f.ok()) {
@ -2960,7 +2960,7 @@ namespace stdex
/// \param[in] filename Filename /// \param[in] filename Filename
/// \param[in] mode Bitwise combination of mode_t flags /// \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); file f(filename, (mode & ~hint_random_access) | mode_for_writing | hint_sequential_access);
if (!f.ok()) { if (!f.ok()) {

View File

@ -46,16 +46,28 @@ namespace stdex
/// Character type for system functions /// Character type for system functions
/// ///
#if defined(_WIN32) #if defined(_WIN32)
using sys_char = TCHAR; using schar_t = TCHAR;
#else #else
using sys_char = char; using schar_t = char;
#define _T(x) x #define _T(x) x
#endif #endif
///
/// Character type for system functions for backward compatibility
/// Use stdex::schar_t
///
using sys_char = schar_t;
/// ///
/// String for system functions /// String for system functions
/// ///
using sys_string = std::basic_string<stdex::sys_char>; using sstring = std::basic_string<stdex::schar_t>;
///
/// 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.) /// Operating system object (file, pipe, anything with an OS handle etc.)