2 #include "common/common.hpp"
3 #include "nlohmann/json_fwd.hpp"
13 std::ifstream make_ifstream(
const std::string &filename_utf8, std::ios_base::openmode mode = std::ios_base::in);
14 std::ofstream make_ofstream(
const std::string &filename_utf8, std::ios_base::openmode mode = std::ios_base::out);
16 void save_json_to_file(
const std::string &filename,
const json &j);
17 json load_json_from_file(
const std::string &filename);
18 int orientation_to_angle(Orientation o);
19 std::string get_exe_dir();
20 void allow_set_foreground_window(
int pid);
21 std::string coord_to_string(
const Coordf &c,
bool delta =
false);
22 std::string dim_to_string(
int64_t x,
bool with_sign =
true);
23 std::string angle_to_string(
int angle,
bool pos_only =
true);
25 const std::locale &get_locale();
29 template <
typename T,
typename U> std::vector<T> dynamic_cast_vector(
const std::vector<U> &cin)
32 out.reserve(cin.size());
33 std::transform(cin.begin(), cin.end(), std::back_inserter(out), [](
auto x) {
return dynamic_cast<T>(x); });
37 template <
typename Map,
typename F>
static void map_erase_if(Map &m, F pred)
39 for (
typename Map::iterator i = m.begin(); (i = std::find_if(i, m.end(), pred)) != m.end(); m.erase(i++))
43 bool endswith(
const std::string &haystack,
const std::string &needle);
45 template <
typename T>
int sgn(T val)
47 return (T(0) < val) - (val < T(0));
50 int strcmp_natural(
const std::string &a,
const std::string &b);
51 int strcmp_natural(
const char *a,
const char *b);
52 void create_config_dir();
53 std::string get_config_dir();
55 void replace_backslash(std::string &path);
56 json json_from_resource(
const std::string &rsrc);
57 bool compare_files(
const std::string &filename_a,
const std::string &filename_b);
58 void find_files_recursive(
const std::string &base_path, std::function<
void(
const std::string &)> cb,
59 const std::string &path =
"");
61 Color color_from_json(
const json &j);
62 json color_to_json(
const Color &c);
64 std::string format_m_of_n(
unsigned int m,
unsigned int n);
65 std::string format_digits(
unsigned int m,
unsigned int digits_max);
66 double parse_si(
const std::string &inps);