Raven Engine v0.1
Loading...
Searching...
No Matches
Utility

Utility functions and classes. More...

Files

file  Utility.h
 Common string utility functions.

Functions

std::string Raven::FileDialogs::OpenFile (const char *filter, void *wnd)
 Opens a native Windows file open dialog and returns the selected file path.
std::string Raven::FileDialogs::SaveFile (const char *filter, void *wnd)
 Opens a native Windows file save dialog and returns the selected file path.
std::string Raven::Trim (const std::string &str)
 Removes leading and trailing whitespace from a string.
std::string Raven::ToLower (std::string_view str)
 Converts a string view to lowercase.
bool Raven::Contains (const std::string &str, const std::string &substring)
 Checks if a string contains a substring, case-insensitive.
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

◆ Contains()

bool Raven::Contains ( const std::string & str,
const std::string & substring )
inline

Checks if a string contains a substring, case-insensitive.

Parameters
strThe string to search within.
substringThe substring to search for.
Returns
True if the substring is found (ignoring case), false otherwise.

◆ OpenFile()

std::string Raven::FileDialogs::OpenFile ( const char * filter,
void * wnd )

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").
wndA pointer to the GLFW window; used to retrieve the native Win32 window handle.
Returns
The full path of the selected file, or an empty string if the dialog was canceled.

◆ 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()

std::string Raven::FileDialogs::SaveFile ( const char * filter,
void * wnd )

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").
wndA pointer to the GLFW window; used to retrieve the native Win32 window handle.
Returns
The full path of the selected file to save, or an empty string if the dialog was canceled.

◆ 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()

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

Removes leading and trailing whitespace from a string.

Parameters
strThe input string to trim.
Returns
A new string with whitespace removed from both ends.