namespace {
+#ifdef _WIN32
+const char k_path_delimiter[] = ";";
+#else
+const char k_path_delimiter[] = ":";
+#endif
+
template<typename T>
std::vector<T>
split_into(std::string_view string,
return timestamp;
}
+std::string
+join_path_list(const std::vector<std::filesystem::path>& path_list)
+{
+ return join(path_list, k_path_delimiter);
+}
+
tl::expected<double, std::string>
parse_double(const std::string& value)
{
std::vector<fs::path>
split_path_list(std::string_view path_list)
{
-#ifdef _WIN32
- const char path_delimiter[] = ";";
-#else
- const char path_delimiter[] = ":";
-#endif
- auto strings = split_into_views(path_list, path_delimiter);
+ auto strings = split_into_views(path_list, k_path_delimiter);
std::vector<fs::path> paths;
std::copy(strings.cbegin(), strings.cend(), std::back_inserter(paths));
return paths;
std::string
join(const T& begin, const T& end, const std::string_view delimiter);
+// Join paths into a string with system-dependent delimiter.
+std::string join_path_list(const std::vector<std::filesystem::path>& path_list);
+
// Parse a string into a double.
//
// Returns an error string if `value` cannot be parsed as a double.
}
}
+TEST_CASE("util::join_path_list")
+{
+ CHECK(util::join_path_list({}).empty());
+#ifdef _WIN32
+ CHECK(util::join_path_list({"a", "b"}) == "a;b");
+#else
+ CHECK(util::join_path_list({"a", "b"}) == "a:b");
+#endif
+}
+
TEST_CASE("util::parse_double")
{
CHECK(*util::parse_double("0") == doctest::Approx(0.0));