11#include <spdlog/sinks/basic_file_sink.h>
12#include <spdlog/spdlog.h>
27 template <auto Start, auto End, auto Inc,
class F>
constexpr void constexpr_for(F &&f)
29 if constexpr (Start < End) {
30 f(std::integral_constant<
decltype(Start), Start>());
35 std::shared_ptr<spdlog::logger>
build_logger(
const std::string &name,
const std::string &filename);
58 std::stringstream stream;
59 stream << std::fixed << std::setprecision(precision) << number;
75 if (digits <= 0)
throw std::runtime_error(
"to_string_with_digits: digits must be > 0");
76 const int d = int(std::ceil(std::log10(number < 0 ? -number : number)));
77 std::stringstream stream;
78 stream << std::fixed << std::setprecision(std::max(digits - d, 0)) << number;
102 bool has_suffix(
const std::string &str,
const std::string &suffix);
Definition complex_math.hh:14
std::string make_folder(const std::string &path)
Add a trailing '/' to a string, in order for it to be in standard form of a folder path.
bool create_folder(const std::string &path_)
Creates the directory path, even if its parent directories should not exist.
std::shared_ptr< spdlog::logger > build_logger(const std::string &name, const std::string &filename)
std::string time_format_ms(size_t time_in_miliseconds)
Nice output from seconds to h/min/s style string.
std::string getWithPrecision(uint precision, T number)
Return number with fixed precision after the decimal point.
Definition utils.hh:56
bool has_suffix(const std::string &str, const std::string &suffix)
bool file_exists(const std::string &name)
Checks if a file exists.
constexpr void constexpr_for(F &&f)
A compile-time for loop, which calls the lambda f of signature void(integer) for each index.
Definition utils.hh:27
std::string time_format(size_t time_in_seconds)
Nice output from seconds to h/min/s style string.
unsigned int uint
Definition utils.hh:22
std::string strip_name(const std::string &name)
Strips all special characters from a string, e.g. for use in filenames.
std::string to_string_with_digits(const T number, const int digits)
Return number with fixed significant digits.
Definition utils.hh:73
std::vector< double > string_to_double_array(const std::string &str)
Takes a string of comma-separated numbers and outputs it as a vector.