From d9e1caa37e53c7dbc42b1fc652efc23a40c47c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sun, 31 Jul 2022 19:56:53 +0200 Subject: Limit use of Hungarian notation. I don't hate Hungarian notation. It has some very nice qualities. But it also adds a lot of typing. That said, not using it feels a bit... unsafe. I might go back on this decision. We'll see. --- c/common.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'c/common.h') diff --git a/c/common.h b/c/common.h index e63095b..39fa9b8 100644 --- a/c/common.h +++ b/c/common.h @@ -14,30 +14,30 @@ struct wstring_owner { wstring_owner(); - wstring_owner(wchar_t* wsz); - wstring_owner& operator=(wchar_t* wsz); - wstring_owner(wstring_owner& wso) = delete; - wstring_owner& operator=(wstring_owner& wso) = delete; - wstring_owner(wstring_owner&& wso) noexcept; - wstring_owner& operator=(wstring_owner&& wso) noexcept; + wstring_owner(wchar_t* s); + wstring_owner& operator=(wchar_t* s); + wstring_owner(wstring_owner& other) = delete; + wstring_owner& operator=(wstring_owner& other) = delete; + wstring_owner(wstring_owner&& other) noexcept; + wstring_owner& operator=(wstring_owner&& other) noexcept; wchar_t *release(); operator bool() const; ~wstring_owner(); wchar_t* p = nullptr; }; -wstring_owner WsoFromSz(const char* sz, int iCp = CP_UTF8); +wstring_owner WsoFromSz(const char* buf, int cp = CP_UTF8); int EBMessageBox(const wchar_t* wszText, const wchar_t* wszCaption, unsigned uType); -wstring_owner WsoCopy(const wchar_t* wsz); +wstring_owner WsoCopy(const wchar_t* s); struct Win32Error : public std::exception { Win32Error(); - Win32Error(DWORD dwErr); + Win32Error(DWORD code); ~Win32Error(); const char* what() const noexcept; const wchar_t* WhatW() const noexcept; - DWORD dwErr; + DWORD code; private: char* m_szMsg = NULL; wchar_t* m_wszMsg = NULL; @@ -45,7 +45,7 @@ private: struct Library { - Library(const wchar_t* wszLibrary); + Library(const wchar_t* lib); ~Library(); template T* GetProcAddress(const char* szProc); private: @@ -59,9 +59,9 @@ T* Library::GetProcAddress(const char* const szProc) } template -inline int wszf(wchar_t (&wsz)[N], const wchar_t* const wszFmt, T... xs) +inline int wszf(wchar_t (&buf)[N], const wchar_t* const fmt, T... xs) { - return _snwprintf_s(wsz, N, _TRUNCATE, wszFmt, xs...); + return _snwprintf_s(buf, N, _TRUNCATE, fmt, xs...); } /* Create and return an object of type C. If construction fails, @@ -103,8 +103,8 @@ inline T prefer(const T x) /* Return integer scaled for current DPI. */ inline int Dpi(const int i) { - extern int g_iDPI; - return MulDiv(i, g_iDPI, 96); + extern int g_dpi; + return MulDiv(i, g_dpi, 96); } inline int Cmp(const int a, const int b) @@ -115,10 +115,10 @@ inline int Cmp(const int a, const int b) } /* Get window rectangle relative to parent. */ -inline BOOL GetRelativeRect(const HWND hWnd, RECT* const pRr) +inline BOOL GetRelativeRect(const HWND hWnd, RECT* const rr) { - if (!GetClientRect(hWnd, pRr)) return 0; - return MapWindowPoints(hWnd, GetParent(hWnd), (POINT*)pRr, 2); + if (!GetClientRect(hWnd, rr)) return 0; + return MapWindowPoints(hWnd, GetParent(hWnd), (POINT*)rr, 2); } inline BOOL SetWindowRect(const HWND hWnd, -- cgit v1.2.3