aboutsummaryrefslogtreecommitdiff
path: root/c/common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c/common.cpp')
-rw-r--r--c/common.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/c/common.cpp b/c/common.cpp
index 59f0fdc..0a54f69 100644
--- a/c/common.cpp
+++ b/c/common.cpp
@@ -3,13 +3,11 @@
#include "common.h"
-/* wchar_ptr: Simple wrapper for wide C strings. */
+wchar_ptr::wchar_ptr() noexcept {}
-wchar_ptr::wchar_ptr() {}
+wchar_ptr::wchar_ptr(wchar_t* const s) noexcept : m_p(s) {}
-wchar_ptr::wchar_ptr(wchar_t* const s) : m_p(s) {}
-
-wchar_ptr& wchar_ptr::operator=(wchar_t* const s)
+wchar_ptr& wchar_ptr::operator=(wchar_t* const s) noexcept
{
if (m_p != s) {
delete m_p;
@@ -31,15 +29,14 @@ wchar_ptr::operator wchar_t*() noexcept
return m_p;
}
-/* Return pointer, releasing ownership. */
-wchar_t* wchar_ptr::release()
+wchar_t* wchar_ptr::release() noexcept
{
wchar_t* p2 = m_p;
m_p = nullptr;
return p2;
}
-wchar_ptr::~wchar_ptr()
+wchar_ptr::~wchar_ptr() noexcept
{
delete m_p;
}
@@ -64,8 +61,6 @@ wchar_ptr wchar_ptr::copy(const wchar_t* const src)
return dst;
}
-/* Win32Error: Exception for Windows API errors. */
-
Win32Error::Win32Error() : code(GetLastError()) {}
Win32Error::Win32Error(const DWORD code) : code(code) {}
@@ -90,7 +85,7 @@ const char* Win32Error::what() const noexcept
return m_szMsg;
}
-const wchar_t* Win32Error::WhatW() const noexcept
+const wchar_t* Win32Error::What() const noexcept
{
if (!m_wszMsg)
FormatMessage(
@@ -103,8 +98,6 @@ const wchar_t* Win32Error::WhatW() const noexcept
return m_wszMsg;
}
-/* Library: Wrapper for loading and freeing dynamically linked libraries. */
-
std::optional<Library> Library::Maybe(const wchar_t* const lib)
{
HMODULE hModule = LoadLibrary(lib);
@@ -126,7 +119,6 @@ Library::~Library()
FreeLibrary(m_hModule);
}
-/* Show message box owned by and centered in the main window. */
int EBMessageBox(const wchar_t* const wszText, const wchar_t* const wszCaption, const unsigned uType)
{
extern HWND g_hWnd;