Implements generic functionality.
More...
#include <Utility.h>
|
static int | safeStoi (std::string str) |
| Safely attempts to convert a string to a corresponding int. More...
|
|
static long long | safeStoll (std::string str) |
| Safely attempts to convert a string to a corresponding long long. More...
|
|
static long long | safeStod (std::string str) |
| Safely attempts to convert a string to a corresponding double. More...
|
|
static void | appendBy (std::vector< char > &result, std::string word, char delimiter) |
| Appends a char vector by a string and adds a special character at the end. More...
|
|
static void | appendBy (std::vector< char > &result, std::vector< std::string > words, char wordSeparator, char endChar) |
| Appends a character vector by multiple strings while separating the strings by special characters and adds a character to the end. More...
|
|
static std::vector< std::string > | splitStringOn (std::string str, char delimiter) |
| Splits a string on a special character. More...
|
|
static std::string | hashToUUIDString (std::string hash) |
| Changes a string with the format of a hash to a string with the format of a UUID. More...
|
|
static std::string | uuidStringToHash (std::string uuid) |
| Changes a string with the format of a uuid to a string with the format of a hash. More...
|
|
static long long | getCurrentTimeSeconds () |
| Gets the current time since epoch in seconds, represented as an integer.
|
|
static long long | getCurrentTimeMilliSeconds () |
| Gets the current time since epoch in milliseconds, represented as an integer.
|
|
template<class T > |
static T | queryWithRetry (std::function< T()> query) |
| A general template for a query to be performed with retries. More...
|
|
Implements generic functionality.
◆ appendBy() [1/2]
void Utility::appendBy |
( |
std::vector< char > & |
result, |
|
|
std::string |
word, |
|
|
char |
delimiter |
|
) |
| |
|
static |
Appends a char vector by a string and adds a special character at the end.
- Parameters
-
result | The base char vector. |
word | The string to be appended to the char vector. |
delimiter | The character to be added at the end of the vector. |
◆ appendBy() [2/2]
void Utility::appendBy |
( |
std::vector< char > & |
result, |
|
|
std::vector< std::string > |
words, |
|
|
char |
wordSeparator, |
|
|
char |
endChar |
|
) |
| |
|
static |
Appends a character vector by multiple strings while separating the strings by special characters and adds a character to the end.
- Parameters
-
result | The base char vector. |
words | The strings to be appended to the vector. |
wordSeparator | The separator for different words. |
endChar | The character appended to the vector at the end. |
◆ hashToUUIDString()
std::string Utility::hashToUUIDString |
( |
std::string |
hash | ) |
|
|
static |
Changes a string with the format of a hash to a string with the format of a UUID.
- Parameters
-
hash | The hash to be converted to a UUID string. |
- Returns
- The hash with format of a UUID string.
◆ queryWithRetry()
template<class T >
static T Utility::queryWithRetry |
( |
std::function< T()> |
query | ) |
|
|
inlinestatic |
A general template for a query to be performed with retries.
- Template Parameters
-
T | The output of the query. If no output is given, an empty tuple (std::tuple<>) should be used. |
- Parameters
-
query | The corresponding query to be performed a single time. |
- Returns
- Output of the query, which may be an empty tuple (to replace void).
◆ safeStod()
long long Utility::safeStod |
( |
std::string |
str | ) |
|
|
static |
Safely attempts to convert a string to a corresponding double.
- Parameters
-
str | The string to convert. |
- Returns
- double corresponding to string on success, or 0 when the string cannot be converted. If the string cannot be converted, errno is set to EDOM. If the converted string would fall out of the range of a long long, errno is set to ERANGE. Strings of the form "123AAA" are parsed to 123.
◆ safeStoi()
int Utility::safeStoi |
( |
std::string |
str | ) |
|
|
static |
Safely attempts to convert a string to a corresponding int.
- Parameters
-
str | The string to convert. |
- Returns
- The integer corresponding to string on success, or 0 when the string cannot be converted. If the string cannot be converted, errno is set to EDOM. If the converted string would fall out of the range of an integer, errno is set to ERANGE. Strings of the form "123AAA" are parsed to 123.
◆ safeStoll()
long long Utility::safeStoll |
( |
std::string |
str | ) |
|
|
static |
Safely attempts to convert a string to a corresponding long long.
- Parameters
-
str | The string to convert. |
- Returns
- long long corresponding to string on success, or 0 when the string cannot be converted. If the string cannot be converted, errno is set to EDOM. If the converted string would fall out of the range of a long long, errno is set to ERANGE. Strings of the form "123AAA" are parsed to 123.
◆ splitStringOn()
std::vector< std::string > Utility::splitStringOn |
( |
std::string |
str, |
|
|
char |
delimiter |
|
) |
| |
|
static |
Splits a string on a special character.
- Parameters
-
str | The string to be split. |
delimiter | The character on which the string is split. |
- Returns
- A vector of the substrings obtained by splitting the string.
◆ uuidStringToHash()
std::string Utility::uuidStringToHash |
( |
std::string |
uuid | ) |
|
|
static |
Changes a string with the format of a uuid to a string with the format of a hash.
- Parameters
-
uuid | The string to be converted to a hash. |
- Returns
- The UUID with format of a hash.
The documentation for this class was generated from the following files:
- SearchSECODatabaseAPI/General/Utility.h
- SearchSECODatabaseAPI/General/Utility.cpp