2 #include "common/common.hpp"
3 #include "nlohmann/json_fwd.hpp"
13 enum class InToolActionID;
15 std::ifstream make_ifstream(
const std::string &filename_utf8, std::ios_base::openmode mode =
std::ios_base::in);
16 std::ofstream make_ofstream(
const std::string &filename_utf8, std::ios_base::openmode mode = std::ios_base::out);
18 void save_json_to_file(
const std::string &filename,
const json &j);
19 json load_json_from_file(
const std::string &filename);
20 std::string get_exe_dir();
21 void allow_set_foreground_window(
int pid);
23 const std::locale &get_locale();
25 template <
typename T,
typename U> std::vector<T> dynamic_cast_vector(
const std::vector<U> &cin)
28 out.reserve(cin.size());
29 std::transform(cin.begin(), cin.end(), std::back_inserter(out), [](
auto x) { return dynamic_cast<T>(x); });
33 template <
typename Map,
typename F>
static void map_erase_if(Map &m, F pred)
35 for (
typename Map::iterator i = m.begin(); (i =
std::find_if(i, m.end(), pred)) != m.end(); m.erase(i++))
39 template <
typename Set,
typename F>
static void set_erase_if(Set &m, F pred)
41 for (
auto it = m.begin(), last = m.end(); it != last;) {
51 bool endswith(
const std::string &haystack,
const std::string &needle);
53 int strcmp_natural(
const std::string &a,
const std::string &b);
54 int strcmp_natural(
const char *a,
const char *b);
55 void create_config_dir();
56 std::string get_config_dir();
58 void replace_backslash(std::string &path);
59 json json_from_resource(
const std::string &rsrc);
60 bool compare_files(
const std::string &filename_a,
const std::string &filename_b);
61 void find_files_recursive(
const std::string &base_path, std::function<
void(
const std::string &)> cb,
62 const std::string &path =
"");
67 ColorI colori_from_json(
const json &j);
68 json colori_to_json(
const ColorI &c);
70 std::string format_m_of_n(
unsigned int m,
unsigned int n);
71 std::string format_digits(
unsigned int m,
unsigned int digits_max);
72 double parse_si(
const std::string &inps);
74 void rmdir_recursive(
const std::string &dir_name);
75 std::string interpolate_text(
const std::string &str,
76 std::function<std::optional<std::string>(
const std::string &s)> interpolator);
78 std::pair<Coordi, bool> dir_from_action(InToolActionID a);
81 template <
typename T> constexpr
bool any_of(T value, std::initializer_list<T> choices)
83 return std::count(choices.begin(), choices.end(), value);
86 void check_object_type(
const json &j, ObjectType type);
87 void ensure_parent_dir(
const std::string &path);
88 std::string get_existing_path(
const std::string &p);
90 std::string append_dot_json(
const std::string &s);
92 Orientation get_pin_orientation_for_placement(Orientation pin_orientation,
const class Placement &placement);
Definition: common.hpp:278
a class to store JSON values
Definition: json.hpp:177
not_< empty< find_if< L, Fn > >> any_of
A Boolean integral constant wrapper around true if invoke<Fn, A>::value is true for any element A in ...
Definition: meta.hpp:3045
not_< empty< find< L, T > >> in
A Boolean integral constant wrapper around true if there is at least one occurrence of T in L.
Definition: meta.hpp:3081
_t< detail::count_< L, T > > count
Count the number of times a type T appears in the list L.
Definition: meta.hpp:2725
_t< detail::find_if_< L, Fn > > find_if
Return the tail of the list L starting at the first element A such that invoke<Fn,...
Definition: meta.hpp:2506
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62