OMW
0.1.0
|
Contains wraping and helper functions for the Windows API. More...
Classes | |
class | envVar_not_found |
An exception, indicating that the specified environment variable could not be found. More... | |
class | ErrorCode |
class | invalid_unicode |
An exception, indicating the presence of an invalid unicode codepoint. More... | |
class | resource_not_found |
An exception, indicating that the specified resource could not be found. More... | |
Enumerations | |
enum | ERRORCODE { EC_OK = 0, EC_ERROR, EC_INV_ARG, EC_INV_UNICODE, EC_INTERNAL, EC_UNKNOWN_WIN, EC_ENVVAR_NOT_FOUND, EC_RESOURCE_NOT_FOUND, EC_RESOURCE_NOT_LOADED, EC_STRCONV_DEST_BUFFER_SIZE } |
Functions | |
std::string | getEnvironmentVariable (const std::string &varName) |
Gets the value of an environment variable. More... | |
std::string | getEnvironmentVariable (const std::string &varName, omw::windows::ErrorCode &ec) |
Gets the value of an environment variable. More... | |
const uint8_t * | getResource (int idr, int type, size_t *size) |
const uint8_t * | getResource (int idr, int type, size_t *size, omw::windows::ErrorCode &ec) |
std::vector< uint8_t > | getResource (int idr, int type) |
std::vector< uint8_t > | getResource (int idr, int type, omw::windows::ErrorCode &ec) |
std::vector< uint8_t > | getBinaryResource (int idr) |
std::vector< uint8_t > | getBinaryResource (int idr, omw::windows::ErrorCode &ec) |
std::string | getTextResource (int idr) |
std::string | getTextResource (int idr, omw::windows::ErrorCode &ec) |
size_t | utf8_to_wstr (const std::string &src, LPWSTR dest, size_t destSize) |
Converts an UTF-8 string to a Windows API compatible wide string. More... | |
size_t | utf8_to_wstr (const std::string &src, LPWSTR dest, size_t destSize, omw::windows::ErrorCode &ec) |
Converts an UTF-8 string to a Windows API compatible wide string. More... | |
size_t | wstr_to_utf8 (LPCWCH src, char *dest, size_t destSize) |
Converts a Windows API compatible wide string to an UTF-8 string. More... | |
size_t | wstr_to_utf8 (LPCWCH src, char *dest, size_t destSize, omw::windows::ErrorCode &ec) |
Converts a Windows API compatible wide string to an UTF-8 string. More... | |
void | wstr_to_utf8 (LPCWCH src, std::string &dest) |
Converts a Windows API compatible wide string to an UTF-8 string. More... | |
void | wstr_to_utf8 (LPCWCH src, std::string &dest, omw::windows::ErrorCode &ec) |
Converts a Windows API compatible wide string to an UTF-8 string. More... | |
Variables | |
constexpr size_t | envVarValueMaxSize = 32767 |
Max buffer size (including terminating null) of an environment variables value. More... | |
Contains wraping and helper functions for the Windows API.
This namespace is only present on Windows platforms.
Also read the Strings section on the Main Page.
The overloads of getResource()
with the ErrorCode& ec
out parameter has only sucessfully performed if ec.good()
returns true
. Possible code values:
The other overloads can throw
omw::windows::resource_not_found
if the resource could not be foundstd::runtime_error
if the resource could not be loaded or on C++ standard runtime errorsThe functions utf8_to_wstr()
and wstr_to_utf8()
are used to convert between UTF-8 char
strings used by this library and WCHAR
strings used in the Windows API. Both do have several overloads.
The overloads with the ErrorCode& ec
out parameter has only sucessfully performed if ec.good()
returns true
. Possible code values:
omw::windows::EC_OK
omw::windows::EC_INV_ARG
omw::windows::EC_INV_UNICODE
omw::windows::EC_INTERNAL
omw::windows::EC_UNKNOWN_WIN
omw::windows::EC_STRCONV_DEST_BUFFER_SIZE
The other overloads can throw
std::range_error
if dest
buffer is too smallstd::invalid_argument
when invalid arguments are passed to the function (such as null pointers)omw::windows::invalid_unicode
when src contains invalid unicode codepointsstd::runtime_error
on unexpected behaviour of underlaying function std::vector< uint8_t > omw::windows::getBinaryResource | ( | int | idr | ) |
idr | Resource ID (16bit) |
Throwing function, see Get Resources.
std::vector< uint8_t > omw::windows::getBinaryResource | ( | int | idr, |
omw::windows::ErrorCode & | ec | ||
) |
idr | Resource ID (16bit) | |
[out] | ec | See Get Resources |
std::string omw::windows::getEnvironmentVariable | ( | const std::string & | varName | ) |
Gets the value of an environment variable.
varName | Name of the environment variable |
Can throw
std::string omw::windows::getEnvironmentVariable | ( | const std::string & | varName, |
omw::windows::ErrorCode & | ec | ||
) |
Gets the value of an environment variable.
varName | Name of the environment variable | |
[out] | ec | Error code |
Possible ec.code()
values:
std::vector< uint8_t > omw::windows::getResource | ( | int | idr, |
int | type | ||
) |
idr | Resource ID (16bit) |
type | Resource type (16bit) |
Throwing function, see Get Resources.
std::vector< uint8_t > omw::windows::getResource | ( | int | idr, |
int | type, | ||
omw::windows::ErrorCode & | ec | ||
) |
idr | Resource ID (16bit) | |
type | Resource type (16bit) | |
[out] | ec | See Get Resources |
const uint8_t * omw::windows::getResource | ( | int | idr, |
int | type, | ||
size_t * | size | ||
) |
idr | Resource ID (16bit) | |
type | Resource type (16bit) | |
[out] | size | Number of bytes |
Throwing function, see Get Resources.
const uint8_t * omw::windows::getResource | ( | int | idr, |
int | type, | ||
size_t * | size, | ||
omw::windows::ErrorCode & | ec | ||
) |
idr | Resource ID (16bit) | |
type | Resource type (16bit) | |
[out] | size | Number of bytes |
[out] | ec | See Get Resources |
std::string omw::windows::getTextResource | ( | int | idr | ) |
idr | Resource ID (16bit) |
Throwing function, see Get Resources.
std::string omw::windows::getTextResource | ( | int | idr, |
omw::windows::ErrorCode & | ec | ||
) |
idr | Resource ID (16bit) | |
[out] | ec | See Get Resources |
size_t omw::windows::utf8_to_wstr | ( | const std::string & | src, |
LPWSTR | dest, | ||
size_t | destSize | ||
) |
Converts an UTF-8 string to a Windows API compatible wide string.
src | The input string | |
[out] | dest | Pointer to the output buffer |
destSize | Size of the destination buffer (number of WCHAR ) |
The src argument can also be of type const char*
(implicit std::string()
constructor).
Throwing function, see String Conversion Functions.
size_t omw::windows::utf8_to_wstr | ( | const std::string & | src, |
LPWSTR | dest, | ||
size_t | destSize, | ||
omw::windows::ErrorCode & | ec | ||
) |
Converts an UTF-8 string to a Windows API compatible wide string.
src | The input string | |
[out] | dest | Pointer to the output buffer |
destSize | Size of the destination buffer (number of WCHAR ) | |
[out] | ec | See String Conversion Functions |
The src argument can also be of type const char*
(implicit std::string()
constructor).
size_t omw::windows::wstr_to_utf8 | ( | LPCWCH | src, |
char * | dest, | ||
size_t | destSize | ||
) |
Converts a Windows API compatible wide string to an UTF-8 string.
src | The input string | |
[out] | dest | Pointer to the output buffer |
destSize | Size of the destination buffer |
Throwing function, see String Conversion Functions.
size_t omw::windows::wstr_to_utf8 | ( | LPCWCH | src, |
char * | dest, | ||
size_t | destSize, | ||
omw::windows::ErrorCode & | ec | ||
) |
Converts a Windows API compatible wide string to an UTF-8 string.
src | The input string | |
[out] | dest | Pointer to the output buffer |
destSize | Size of the destination buffer | |
[out] | ec | See String Conversion Functions |
void omw::windows::wstr_to_utf8 | ( | LPCWCH | src, |
std::string & | dest | ||
) |
Converts a Windows API compatible wide string to an UTF-8 string.
src | The input string | |
[out] | dest | Reference to the output string |
Throwing function, see String Conversion Functions.
void omw::windows::wstr_to_utf8 | ( | LPCWCH | src, |
std::string & | dest, | ||
omw::windows::ErrorCode & | ec | ||
) |
Converts a Windows API compatible wide string to an UTF-8 string.
src | The input string | |
[out] | dest | Reference to the output string |
[out] | ec | See String Conversion Functions |
|
constexpr |
Max buffer size (including terminating null) of an environment variables value.