1 #ifndef UTILS_COMMON_H_INCLUDED
2 #define UTILS_COMMON_H_INCLUDED
10 extern bool starts_with(
const std::string& str,
const std::string& prefix);
12 extern bool ends_with(
const std::string& str,
const std::string& suffix);
14 extern std::string
replace_all(
const std::string& str,
const std::string& o,
15 const std::string& n);
17 extern std::string
replace_all(
const std::string& str,
18 const std::vector<std::vector<std::string>>& os,
19 const std::vector<std::string>& ns);
21 extern std::string
trim(
const std::string& str,
22 const std::string& back_trash =
" \t\n\v\f\r\0",
23 const std::string& front_trash =
" \t\n\v\f\r\0");
25 extern std::vector<std::string>
split(
const std::string& str,
char delim);
27 extern std::string
read_file(
const std::string_view path);
29 extern std::size_t
hash_combine(std::size_t lhs, std::size_t rhs);
33 std::string
to_string(
const T& input, std::size_t precision = 0) {
34 std::ostringstream os;
36 os.precision(precision);
43 #endif // UTILS_COMMON_H_INCLUDED
std::size_t hash_combine(std::size_t lhs, std::size_t rhs)
Stolen from Boost.
std::string read_file(const std::string_view path)
Reads the contents of a file into a string.
std::string trim(crstring str, crstring back_trash=" \t\n\v\f\r\0", crstring front_trash=" \t\n\v\f\r\0")
Removes leading and trailing whitespace.
std::vector< std::string > split(crstring str, char delim)
Splits a string into substrings separated by delim.
std::string to_string(const T &input, std::size_t precision=0)
converts input to a std::string
std::string replace_all(crstring str, crstring o, crstring n)
Replaces all occurences of o in str with n.
bool starts_with(crstring str, crstring prefix)
Checks if str starts with prefix.
bool ends_with(crstring str, crstring suffix)
Checks if str ends with suffix.