Mantis App v0.2.8
Loading...
Searching...
No Matches
string_utils.cpp File Reference
#include "../../include/mantis/utils/utils.h"
#include <algorithm>
#include "httplib.h"
Include dependency graph for string_utils.cpp:

Namespaces

namespace  mantis
 router.h
 

Functions

std::optional< jsonmantis::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.
 
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::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.