20#include "../core/logging.h"
24 namespace fs = std::filesystem;
36 fs::path
joinPaths(
const std::string& path1,
const std::string& path2);
48 fs::path
resolvePath(
const std::string& input_path);
103 std::string
trim(
const std::string& s);
128 bool strToBool(
const std::string& value);
188 std::vector<std::string>
splitString(
const std::string& input,
const std::string& delimiter);
196 std::string
getEnvOrDefault(
const std::string& key,
const std::string& defaultValue);
209 static bool invalidChar(
unsigned char c);
219 static void sanitizeInPlace(std::string& s);
239 std::size_t maxLen = 50,
240 std::size_t idLen = 12,
241 std::string_view idSep =
"_");
291 std::string
tmToStr(
const std::tm& t);
292 std::tm
strToTM(
const std::string& value);
293 std::string
dbDateToString(
const std::string& dbType,
const soci::row& row,
int index);
nlohmann::json json
Definition mantis.h:35
router.h
Definition app.h:31
json hashPassword(const std::string &password)
Digests user password + a generated salt to yield a hashed password.
Definition auth_utils.cpp:49
std::string generateTimeBasedId()
Generate a time base UUID.
Definition string_utils.cpp:51
std::string generateReadableTimeId()
Generates a readable time-based UUID.
Definition string_utils.cpp:68
fs::path joinPaths(const std::string &path1, const std::string &path2)
< Use shorthand fs to refer to the std::filesystem
Definition path_utils.cpp:8
std::string 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.
Definition string_utils.cpp:122
std::string dbDateToString(const std::string &dbType, const soci::row &row, int index)
Definition type_utils.cpp:29
std::tm strToTM(const std::string &value)
Definition type_utils.cpp:17
bool createDirs(const fs::path &path)
Create directory, given a path.
Definition path_utils.cpp:27
std::string 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.
Definition string_utils.cpp:177
std::string generateSalt(int cost=12)
Generates a salt to be used in hashing user passwords.
Definition auth_utils.cpp:35
std::string trim(const std::string &s)
Trims leading and trailing whitespaces from a string.
Definition string_utils.cpp:44
std::string tmToStr(const std::tm &t)
Convert c++ std::tm date/time value to ISO formatted string.
Definition type_utils.cpp:9
std::optional< json > tryParseJsonStr(const std::string &json_str)
Attempt to parse a JSON string.
Definition string_utils.cpp:11
std::string generateShortId(size_t length=16)
Generates a short UUID.
Definition string_utils.cpp:90
std::string bcryptBase64Encode(const unsigned char *data, size_t len)
Encode a Salt string to bcrypt base64 format.
Definition auth_utils.cpp:14
void toUpperCase(std::string &str)
Converts a string to its uppercase variant.
Definition string_utils.cpp:38
std::string dirFromPath(const std::string &path)
Returns a created/existing directory from a path.
Definition path_utils.cpp:46
fs::path resolvePath(const std::string &input_path)
Definition path_utils.cpp:14
json verifyPassword(const std::string &password, const std::string &stored_hash)
Verifies user password if it matches the given hashed password.
Definition auth_utils.cpp:85
bool strToBool(const std::string &value)
Convert given string value to boolean type.
Definition string_utils.cpp:25
void toLowerCase(std::string &str)
Converts a string to its lowercase variant.
Definition string_utils.cpp:32
std::vector< std::string > splitString(const std::string &input, const std::string &delimiter)
Split given string based on given delimiter.
Definition string_utils.cpp:106