Raven Engine v0.1
A modern 3D Game Engine
Loading...
Searching...
No Matches
Utility

Utility functions and classes. More...

Files

file  Engine/src/Raven/Utils/Utility.h
 Common string utility functions.

Functions

std::wstring Raven::Win32Helpers::Utf8ToUtf16 (std::string_view in) noexcept
 Converts an UTF-8 String into a Wide UTF-16 string.
std::string Raven::Win32Helpers::Utf16ToUtf8 (std::wstring_view in) noexcept
 Converts an UTF-16 String into a narrow UTF-8 string.
void Raven::Win32Helpers::SetProcessDpiAwareIfPossible ()
 Makes the process DPI aware if possible.
std::string Raven::FileDialogs::OpenFile (const char *filter)
 Opens a native Windows file open dialog and returns the selected file path.
std::string Raven::FileDialogs::SaveFile (const char *filter)
 Opens a native Windows file save dialog and returns the selected file path.
bool Raven::FileDialogs::OpenExplorer (const std::filesystem::path &path)
 Opens the file explorer at the given Path.
std::string Raven::FileDialogs::OpenFolder ()
 Opens a native Windows folder browser dialog and returns the selected folder path.
void Raven::FileDialogs::OpenURL (const std::string &url)
 Opens a the given URL in the default browser.
void Raven::Trim (std::string &str)
 Removes leading and trailing whitespace from a string.
void Raven::Trim (std::wstring &str)
 Removes leading and trailing whitespace from a wstring.
std::string Raven::ToLower (std::string_view str)
 Converts a string view to lowercase.
const char * Raven::strcasestr (const char *haystack, const char *needle) noexcept
 Performs a case-insensitive substring search.
bool Raven::ResolveWorkingDirectory (const std::string &dirPath)
 Resolves the path to the working directory.

Detailed Description

Utility functions and classes.

Function Documentation

◆ OpenExplorer()

CORE_API bool Raven::FileDialogs::OpenExplorer ( const std::filesystem::path & path)

Opens the file explorer at the given Path.

Parameters
pathThe path at which to open the File Explorer
Returns
True if the Explorer was opened, false otherwise

◆ OpenFile()

CORE_API std::string Raven::FileDialogs::OpenFile ( const char * filter)

Opens a native Windows file open dialog and returns the selected file path.

Parameters
filterA Windows-style filter string (e.g. "Text Files\0*.txt\0All Files\0*.*\0").
Returns
The full path of the selected file, or an empty string if the dialog was canceled.

◆ OpenFolder()

CORE_API std::string Raven::FileDialogs::OpenFolder ( )

Opens a native Windows folder browser dialog and returns the selected folder path.

Returns
The full path of the selected folder, or an empty string if the dialog was canceled.

◆ OpenURL()

CORE_API void Raven::FileDialogs::OpenURL ( const std::string & url)

Opens a the given URL in the default browser.

Parameters
urlThe URL which to open in the browser

◆ ResolveWorkingDirectory()

bool Raven::ResolveWorkingDirectory ( const std::string & dirPath)
inline

Resolves the path to the working directory.

Parameters
dirPathThe path to resolve.
Returns
True if the path was successfully resolved, false otherwise.

◆ SaveFile()

CORE_API std::string Raven::FileDialogs::SaveFile ( const char * filter)

Opens a native Windows file save dialog and returns the selected file path.

Parameters
filterA Windows-style filter string (e.g. "Text Files\0*.txt\0All Files\0*.*\0").
Returns
The full path of the selected file to save, or an empty string if the dialog was canceled.

◆ SetProcessDpiAwareIfPossible()

void Raven::Win32Helpers::SetProcessDpiAwareIfPossible ( )
inline

Makes the process DPI aware if possible.

Note
This is called on Window creation and does not need to be called elsewhere.

◆ strcasestr()

const char * Raven::strcasestr ( const char * haystack,
const char * needle )
inlinenoexcept

Performs a case-insensitive substring search.

This function searches for the first occurrence of the substring needle in the string haystack, ignoring the case of both strings. If the substring is found, a pointer to the beginning of the substring in haystack is returned. If the substring is not found, the function returns nullptr.

Parameters
haystackThe string to be searched.
needleThe substring to search for.
Returns
A pointer to the beginning of the located substring, or nullptr if the substring is not found.
Note
This function ensures cross-platform compatibility as strcasestr is not available on all platforms.

◆ ToLower()

std::string Raven::ToLower ( std::string_view str)
inline

Converts a string view to lowercase.

Parameters
strThe input string view.
Returns
A lowercase std::string copy of the input.

◆ Trim() [1/2]

void Raven::Trim ( std::string & str)
inline

Removes leading and trailing whitespace from a string.

Parameters
strThe string to trim.

◆ Trim() [2/2]

void Raven::Trim ( std::wstring & str)
inline

Removes leading and trailing whitespace from a wstring.

Parameters
strThe wstring to trim.

◆ Utf16ToUtf8()

std::string Raven::Win32Helpers::Utf16ToUtf8 ( std::wstring_view in)
inlinenoexcept

Converts an UTF-16 String into a narrow UTF-8 string.

Parameters
inThe UTF-16 string to convert
Returns
The narrowed UTF-8 string

◆ Utf8ToUtf16()

std::wstring Raven::Win32Helpers::Utf8ToUtf16 ( std::string_view in)
inlinenoexcept

Converts an UTF-8 String into a Wide UTF-16 string.

Parameters
inThe UTF-8 string to convert
Returns
The widened UTF-16 string