GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
Utility.h
Go to the documentation of this file.
1#pragma once
2
3#include "Core.h"
4
5namespace gui_framework
6{
7 namespace utility
8 {
11 GUI_FRAMEWORK_API_FUNCTION void unregisterClass(std::wstring_view className);
12
16 GUI_FRAMEWORK_API_FUNCTION void appendStyle(HWND handle, LONG_PTR newStyle);
17
21 GUI_FRAMEWORK_API_FUNCTION void removeStyle(HWND handle, LONG_PTR styleToRemove);
22
28 GUI_FRAMEWORK_API_FUNCTION std::string to_string(std::wstring_view stringToConvert, uint32_t codepage);
29
35 GUI_FRAMEWORK_API_FUNCTION std::wstring to_wstring(const std::string& stringToConvert, uint32_t codepage);
36
40
44 GUI_FRAMEWORK_API_FUNCTION std::string getStringFromRawPath(const std::filesystem::path& pathFromRawString);
45
51 GUI_FRAMEWORK_API_FUNCTION void loadFunctionFromModule(std::function<void()>& onClick, const std::string& functionName, const std::string& moduleName);
52
58 GUI_FRAMEWORK_API_FUNCTION void loadEventCallbackFromModule(std::function<void(const std::wstring&)>& eventCallback, const std::string& functionName, const std::string& moduleName);
59
64
69
73
78 template<typename T, typename... Args>
80
81 template<typename T>
82 size_t getTypeHash();
83 }
84
85 namespace __utility
86 {
87 GUI_FRAMEWORK_API_FUNCTION void throwNotImplementedException(std::string_view methodName, std::string_view className);
88
89 GUI_FRAMEWORK_API_FUNCTION std::string extendedException(const std::string& exceptionMessage, std::string_view fileName, std::string_view methodName, int line);
90
91 GUI_FRAMEWORK_API_FUNCTION bool useOnClose(std::any topLevelWindow);
92 }
93}
94
95template<typename T, typename... Args>
97{
98 if constexpr (std::is_same_v<std::unique_ptr<T>, smartPointerType<T>>)
99 {
100 return std::make_unique<T>(std::forward<Args>(args)...);
101 }
102 else if constexpr (std::is_same_v<std::shared_ptr<T>, smartPointerType<T>>)
103 {
104 return std::make_shared<T>(std::forward<Args>(args)...);
105 }
106}
107
108template<typename T>
110{
111 return typeid(T).hash_code();
112}
#define GUI_FRAMEWORK_API_FUNCTION
std::unique_ptr< T > smartPointerType
Compatible smart pointer type.
bool useOnClose(any topLevelWindow)
Definition Utility.cpp:218
string extendedException(const string &exceptionMessage, string_view fileName, string_view methodName, int line)
Definition Utility.cpp:201
void throwNotImplementedException(string_view methodName, string_view className)
Definition Utility.cpp:186
wstring to_wstring(const string &stringToConvert, uint32_t codepage)
Definition Utility.cpp:82
HMODULE getCurrentModule()
Get handle to current executable.
Definition Utility.cpp:119
void loadFunctionFromModule(function< void()> &onClick, const string &functionName, const string &moduleName)
Definition Utility.cpp:138
int getCenterY(int height)
Get center Y coordinate.
Definition Utility.cpp:173
string getStringFromRawPath(const filesystem::path &pathFromRawString)
Definition Utility.cpp:124
smartPointerType< T > make_smart_pointer(Args &&... args)
Make function with current build configuration compatibility.
Definition Utility.h:96
int getCenterX(int width)
Get center X coordinate.
Definition Utility.cpp:168
void removeStyle(HWND handle, LONG_PTR styleToRemove)
Remove WinAPI style.
Definition Utility.cpp:31
void unregisterClass(wstring_view className)
Definition Utility.cpp:16
void loadEventCallbackFromModule(function< void(const wstring &)> &eventCallback, const string &functionName, const string &moduleName)
Definition Utility.cpp:153
string getGUIFrameworkVersion()
Get current version of GUIFramework.
Definition Utility.cpp:178
void appendStyle(HWND handle, LONG_PTR newStyle)
Append WinAPI style.
Definition Utility.cpp:21
string to_string(wstring_view stringToConvert, uint32_t codepage)
Definition Utility.cpp:41