|
MantisBase v0.3.4
|
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 <nlohmann/json.hpp>#include "../core/logger/logger.h"#include <spdlog/fmt/bundled/format.h>

Go to the source code of this file.
Namespaces | |
| namespace | std |
| namespace | mb |
| router.h | |
Functions | |
| fs::path | mb::joinPaths (const std::string &path1, const std::string &path2) |
| |
| fs::path | mb::resolvePath (const std::string &input_path) |
| bool | mb::createDirs (const fs::path &path) |
| Create directory, given a path. | |
| std::string | mb::dirFromPath (const std::string &path) |
| Returns a created/existing directory from a path. | |
| void | mb::toLowerCase (std::string &str) |
| Converts a string to its lowercase variant. | |
| void | mb::toUpperCase (std::string &str) |
| Converts a string to its uppercase variant. | |
| std::string | mb::trim (const std::string &s) |
| Trims leading and trailing whitespaces from a string. | |
| std::optional< json > | mb::tryParseJsonStr (const std::string &json_str, std::optional< json > default_value=std::nullopt) |
| Attempt to parse a JSON string. | |
| bool | mb::strToBool (const std::string &value) |
| Convert given string value to boolean type. | |
| std::string | mb::generateTimeBasedId () |
| Generate a time base UUID. | |
| std::string | mb::generateReadableTimeId () |
| Generates a readable time-based UUID. | |
| std::string | mb::generateShortId (size_t length=16) |
| Generates a short UUID. | |
| std::vector< std::string > | mb::splitString (const std::string &input, const std::string &delimiter) |
| Split given string based on given delimiter. | |
| std::string | mb::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. | |
| bool | mb::invalidChar (unsigned char c) |
| Check if a character is invalid in a filename. | |
| void | mb::sanitizeInPlace (std::string &s) |
| Sanitize a string in-place by removing or replacing invalid characters. | |
| std::string | mb::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 | mb::sanitizeFilename_JSWrapper (const std::string &original) |
| std::string | mb::hashPassword (const std::string &password) |
| Digests user password + a generated salt to yield a hashed password. | |
| bool | mb::verifyPassword (const std::string &password, const std::string &stored_hash) |
| Verifies user password if it matches the given hashed password. | |
| std::string | mb::getCurrentTimestampUTC () |
| std::string | mb::tmToStr (const std::tm &t) |
| Convert c++ std::tm date/time value to ISO formatted string. | |
| std::tm | mb::strToTM (const std::string &value) |
| Convert ISO formatted datetime string to std::tm structure. | |
| std::string | mb::dbDateToString (const soci::row &row, int index) |
| Convert database date value from SOCI row to string. | |
| int | mb::safe_stoi (const std::string &s, const int default_val) |
| Safely convert string to integer with default fallback. | |
| bool | mb::isValidIPv4 (const std::string &ip) |
| Validates if a string is a valid IPv4 address. | |
| bool | mb::isValidIPv6 (const std::string &ip) |
| Validates if a string is a valid IPv6 address. | |
| bool | mb::isValidIP (const std::string &ip) |
| Validates if a string is a valid IP address (IPv4 or IPv6). | |
Collection of utility functions that are re-used across different files.
Created by allan on 11/05/2025.