![]() |
Mantis App v0.2.8
|
Collection of utility functions that are re-used across different files. More...
#include <string>
#include <filesystem>
#include <random>
#include <chrono>
#include <string_view>
#include <algorithm>
#include <soci/row.h>
#include "../core/logging.h"
Go to the source code of this file.
Namespaces | |
namespace | mantis |
router.h | |
Functions | |
fs::path | mantis::joinPaths (const std::string &path1, const std::string &path2) |
< Use shorthand fs to refer to the std::filesystem | |
fs::path | mantis::resolvePath (const std::string &input_path) |
bool | mantis::createDirs (const fs::path &path) |
Create directory, given a path. | |
std::string | mantis::dirFromPath (const std::string &path) |
Returns a created/existing directory from a path. | |
void | mantis::toLowerCase (std::string &str) |
Converts a string to its lowercase variant. | |
void | mantis::toUpperCase (std::string &str) |
Converts a string to its uppercase variant. | |
std::string | mantis::trim (const std::string &s) |
Trims leading and trailing whitespaces from a string. | |
std::optional< json > | mantis::tryParseJsonStr (const std::string &json_str) |
Attempt to parse a JSON string. | |
bool | mantis::strToBool (const std::string &value) |
Convert given string value to boolean type. | |
std::string | mantis::generateTimeBasedId () |
Generate a time base UUID. | |
std::string | mantis::generateReadableTimeId () |
Generates a readable time-based UUID. | |
std::string | mantis::generateShortId (size_t length=16) |
Generates a short UUID. | |
std::vector< std::string > | mantis::splitString (const std::string &input, const std::string &delimiter) |
Split given string based on given delimiter. | |
std::string | mantis::getEnvOrDefault (const std::string &key, const std::string &defaultValue) |
Retrieves a value from an environment variable or a default value if the env variable was not set. | |
std::string | mantis::sanitizeFilename (std::string_view original, std::size_t maxLen=50, std::size_t idLen=12, std::string_view idSep="_") |
Sanitize a filename and ensure uniqueness. | |
std::string | mantis::bcryptBase64Encode (const unsigned char *data, size_t len) |
Encode a Salt string to bcrypt base64 format. | |
std::string | mantis::generateSalt (int cost=12) |
Generates a salt to be used in hashing user passwords. | |
json | mantis::hashPassword (const std::string &password) |
Digests user password + a generated salt to yield a hashed password. | |
json | mantis::verifyPassword (const std::string &password, const std::string &stored_hash) |
Verifies user password if it matches the given hashed password. | |
std::string | mantis::tmToStr (const std::tm &t) |
Convert c++ std::tm date/time value to ISO formatted string. | |
std::tm | mantis::strToTM (const std::string &value) |
std::string | mantis::dbDateToString (const std::string &dbType, const soci::row &row, int index) |
Collection of utility functions that are re-used across different files.
Created by allan on 11/05/2025.