libnick 2025.9.1
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
Nickvision::Helpers::CodeHelpers Namespace Reference

Functions

size_t combineHash (size_t a, size_t b) noexcept
 Combines two hash values together.
 
std::vector< std::string > convertUrlMapToVector (const std::unordered_map< std::string, std::string > &urls) noexcept
 Converts a map of URLs to a vector.
 
std::string getLastSystemError () noexcept
 Get the last system api call error message.
 
std::vector< std::byte > readFileBytes (const std::filesystem::path &path) noexcept
 Reads a file as a vector of bytes.
 
template<typename T>
const T & unmove (T &&t) noexcept
 Unmoves a value.
 
bool writeFileBytes (const std::filesystem::path &path, const std::vector< std::byte > &bytes, bool overwrite=true) noexcept
 Writes a vector of bytes to a file.
 

Function Documentation

◆ combineHash()

size_t Nickvision::Helpers::CodeHelpers::combineHash ( size_t a,
size_t b )
noexcept

Combines two hash values together.

Parameters
aThe first hash value
bThe second hash value
Returns
The combined hash value

◆ convertUrlMapToVector()

std::vector< std::string > Nickvision::Helpers::CodeHelpers::convertUrlMapToVector ( const std::unordered_map< std::string, std::string > & urls)
noexcept

Converts a map of URLs to a vector.

Parameters
urlsThe map of URLs
Returns
The vector of URLs

◆ getLastSystemError()

std::string Nickvision::Helpers::CodeHelpers::getLastSystemError ( )
noexcept

Get the last system api call error message.

Returns
The last system error message

◆ readFileBytes()

std::vector< std::byte > Nickvision::Helpers::CodeHelpers::readFileBytes ( const std::filesystem::path & path)
noexcept

Reads a file as a vector of bytes.

Parameters
pathThe path to the file
Returns
The bytes from the file

◆ unmove()

template<typename T>
const T & Nickvision::Helpers::CodeHelpers::unmove ( T && t)
noexcept

Unmoves a value.

Parameters
tAn rvalue of T
Returns
The lvalue of t

◆ writeFileBytes()

bool Nickvision::Helpers::CodeHelpers::writeFileBytes ( const std::filesystem::path & path,
const std::vector< std::byte > & bytes,
bool overwrite = true )
noexcept

Writes a vector of bytes to a file.

Parameters
pathThe path to the file
bytesThe bytes to write
overwriteWhether or not to overwrite the file if it already exists
Returns
True if successful, false otherwise. False is returned if overwrite is false and the file exists.