|
SOMHunter Core
|
Functions | |
| template<typename DataType_ > | |
| void | serialize_to_file (DataType_ data, const std::string filepath) |
| Serializes the given data into the file using cereal lib. More... | |
| template<typename DataType_ > | |
| DataType_ | deserialize_from_file (const std::string filepath) |
| Deserializes the data from the provided file using cereal lib. More... | |
| int64_t | timestamp () |
| Returns the actual UNIX timestamp (ms). More... | |
| std::string | get_formated_timestamp (const std::string &fmt, UnixTimestamp ts=timestamp()) |
| Returns string representing current time and date in formated string based on provided format. More... | |
| int | str_to_int (const std::string &str) |
| Tries to parse the integer from the string. More... | |
| template<typename T_ > | |
| T_ | irand (T_ from, T_ to) |
| Returns a pseudorandom integral number sampled from the uniform distribution [from, to]. More... | |
| template<typename T_ > | |
| T_ | frand (T_ from, T_ to) |
| Returns a pseudorandom floating point number sampled from the uniform distribution [from, to). More... | |
| std::vector< std::string > | split (const std::string &str, char delim) |
| Splits the string with the provided character delimiter. More... | |
| template<typename T_ > | |
| bool | is_set (T_ mask, size_t i) |
Tests whether the i-th lowest significant bit is set. More... | |
| template<typename Container_ > | |
| void | print_matrix (const Container_ &mat) |
| Prints out any two-dimensional iterable container. More... | |
| template<typename Container_ > | |
| void | print_vector (const Container_ &row) |
| Prints out any one-dimensional iterable container. More... | |
| std::string | to_lowercase (const std::string &old) |
| Returns a copy of old string but all lowercase. More... | |
| std::string | sha256_sum (const std::string &filepath) |
| Computes the SHA256 hash for the given file and returns it. More... | |
| std::string | read_whole_file (const std::string &filepath) |
| Reads the whole file into string that it will return. More... | |
| std::string | trim_left (const std::string &s) |
| Left trim. More... | |
| std::string | trim_right (const std::string &s) |
| Right trim. More... | |
| std::string | trim (const std::string &s) |
| Trim. More... | |
| template<typename DType_ > | |
| void | to_file (const std::vector< DType_ > &vec, const std::string filepath) |
| Writes the given vector into the given file. More... | |
| template<typename DType_ > | |
| void | to_file (const std::vector< std::vector< DType_ >> &mat, const std::string filepath) |
| Writes the given matrix into the given file. More... | |
| template<typename T_ > | |
| T_ | ipow (T_ b, std::size_t p) |
| Unsigned integer power function. More... | |
| template<typename T_ > | |
| T_ | round_decimal (T_ x, std::size_t places) |
| Rounds the number to the specified number of decimal places. More... | |
| template<class T_ > | |
| constexpr std::string_view | type_name () |
| Returns a string view describing the type T_. More... | |
| DataType_ sh::utils::deserialize_from_file | ( | const std::string | filepath | ) |
Deserializes the data from the provided file using cereal lib.
| T_ sh::utils::frand | ( | T_ | from, |
| T_ | to | ||
| ) |
Returns a pseudorandom floating point number sampled from the uniform distribution [from, to).
| from | Lower distribution bound. |
| to | Upper distribution bound (exclusive). |
|
inline |
Returns string representing current time and date in formated string based on provided format.
"%d-%m-%Y_%H-%M-%S" => e.g. "16-11-2019_13-26-45:
| fmt | Format string using the same rules as put_time method. |
| T_ sh::utils::ipow | ( | T_ | b, |
| std::size_t | p | ||
| ) |
Unsigned integer power function.
| T_ sh::utils::irand | ( | T_ | from, |
| T_ | to | ||
| ) |
Returns a pseudorandom integral number sampled from the uniform distribution [from, to].
| from | Lower distribution bound. |
| to | Upper distribution bound (inclusive). |
| bool sh::utils::is_set | ( | T_ | mask, |
| size_t | i | ||
| ) |
Tests whether the i-th lowest significant bit is set.
| mask | Bitfield to test bit in. |
| i | Index of the LSb in question. |
| void sh::utils::print_matrix | ( | const Container_ & | mat | ) |
Prints out any two-dimensional iterable container.
| mat | Container to be printed. |

| void sh::utils::print_vector | ( | const Container_ & | row | ) |
Prints out any one-dimensional iterable container.
| mat | Container to be printed. |
|
inline |
Reads the whole file into string that it will return.
| filepath | Filepath of the file to be read. |
| T_ sh::utils::round_decimal | ( | T_ | x, |
| std::size_t | places | ||
| ) |
Rounds the number to the specified number of decimal places.

| void sh::utils::serialize_to_file | ( | DataType_ | data, |
| const std::string | filepath | ||
| ) |
Serializes the given data into the file using cereal lib.
|
inline |
Computes the SHA256 hash for the given file and returns it.
| filepath | Filepath of the file to compute hash for. |
|
inline |
Splits the string with the provided character delimiter.
| str | String to be split. |
| delim | Delimiter to split with. |
|
inline |
Tries to parse the integer from the string.
| std::runtime_error | If unable to parse from the string. |
| str | String to be parsed as an int. |
|
inline |
Returns the actual UNIX timestamp (ms).
| void sh::utils::to_file | ( | const std::vector< DType_ > & | vec, |
| const std::string | filepath | ||
| ) |
Writes the given vector into the given file.
| void sh::utils::to_file | ( | const std::vector< std::vector< DType_ >> & | mat, |
| const std::string | filepath | ||
| ) |
Writes the given matrix into the given file.
|
inline |
Returns a copy of old string but all lowercase.
| old | String to be transformed. \raturns New copy of lowercase string. |
|
inline |
Trim.
/param s A reference to the string to be trimmed. /returns A new copy of trimmed string.

|
inline |
Left trim.
/param s A reference to the string to be trimmed. /returns A new copy of trimmed string.
|
inline |
Right trim.
/param s A reference to the string to be trimmed. /returns A new copy of trimmed string.
|
constexpr |
Returns a string view describing the type T_.
Code from: https://stackoverflow.com/a/20170989/5481153