|
1 | 1 | #include "gucc/bootloader.hpp"
|
2 | 2 | #include "gucc/initcpio.hpp"
|
3 | 3 | #include "gucc/io_utils.hpp"
|
| 4 | +#include "gucc/string_utils.hpp" |
4 | 5 |
|
5 | 6 | #include <fmt/compile.h>
|
6 | 7 | #include <fmt/format.h>
|
@@ -132,20 +133,6 @@ GRUB_DISABLE_RECOVERY=true
|
132 | 133 | #GRUB_DISABLE_OS_PROBER=false
|
133 | 134 | )"sv;
|
134 | 135 |
|
135 |
| -template <typename T, typename npos_type = std::remove_cvref_t<decltype(T::npos)>> |
136 |
| -concept string_findable = requires(T value) { |
137 |
| - // check that type of T::npos is T::size_type |
138 |
| - { npos_type{} } -> std::same_as<typename T::size_type>; |
139 |
| - // check that type of T::find is T::size_type |
140 |
| - { value.find(std::string_view{""}) } -> std::same_as<typename T::size_type>; |
141 |
| -}; |
142 |
| - |
143 |
| -// simple helper function to check if string contains a string |
144 |
| -constexpr auto contains(string_findable auto const& str, std::string_view needle) noexcept -> bool { |
145 |
| - using str_type = std::remove_reference_t<decltype(str)>; |
146 |
| - return str.find(needle) != str_type::npos; |
147 |
| -} |
148 |
| - |
149 | 136 | constexpr auto convert_boolean_val(std::string_view needle, bool value) noexcept -> std::string_view {
|
150 | 137 | if (needle == "GRUB_ENABLE_CRYPTODISK="sv || needle == "GRUB_DISABLE_SUBMENU="sv) {
|
151 | 138 | return value ? "y"sv : "n"sv;
|
@@ -176,7 +163,7 @@ auto parse_grub_line(const gucc::bootloader::GrubConfig& grub_config, std::strin
|
176 | 163 | CONV_OPT_F_S("GRUB_BACKGROUND=", grub_config.background, "/path/to/wallpaper");
|
177 | 164 | CONV_OPT_F_S("GRUB_THEME=", grub_config.theme, "/path/to/gfxtheme");
|
178 | 165 | CONV_OPT_F_S("GRUB_INIT_TUNE=", grub_config.init_tune, "480 440 1");
|
179 |
| - if (contains(line, "=y") || contains(line, "=true") || contains(line, "=false")) { |
| 166 | + if (gucc::utils::contains(line, "=y") || gucc::utils::contains(line, "=true") || gucc::utils::contains(line, "=false")) { |
180 | 167 | // booleans
|
181 | 168 | CONV_OPT_B("GRUB_ENABLE_CRYPTODISK=", grub_config.enable_cryptodisk, "y");
|
182 | 169 | CONV_OPT_B("GRUB_DISABLE_LINUX_UUID=", grub_config.disable_linux_uuid, "true");
|
|
0 commit comments