| 136 | template<typename T> |
| 137 | requires (!std::is_same_v<fextl::string, T> && !std::is_same_v<DefaultValues::Type::StringArrayType, T>) |
| 138 | std::optional<T> GetConv(ConfigOption Option) { |
| 139 | const auto it = OptionMap.find(Option); |
| 140 | if (it == OptionMap.end()) { |
| 141 | return std::nullopt; |
| 142 | } |
| 143 | |
| 144 | const auto& Value = it->second; |
| 145 | LOGMAN_THROW_A_FMT(!std::holds_alternative<DefaultValues::Type::StringArrayType>(Value), "Tried to get config of invalid type!"); |
| 146 | |
| 147 | if (std::holds_alternative<T>(Value)) [[likely]] { |
| 148 | return std::get<T>(Value); |
| 149 | } |
| 150 | |
| 151 | T ConvertedValue; |
| 152 | if (std::holds_alternative<fextl::string>(Value)) { |
| 153 | const auto& StrVal = std::get<fextl::string>(Value); |
| 154 | if (FEXCore::StrConv::Conv(StrVal, &ConvertedValue)) { |
| 155 | // Convert the value. |
| 156 | OptionMap[Option].emplace<T>(ConvertedValue); |
| 157 | return ConvertedValue; |
| 158 | } else { |
| 159 | LOGMAN_MSG_A_FMT("Couldn't Convert {} to specified type!", StrVal); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | FEX_UNREACHABLE; |
| 164 | } |
| 165 | |
| 166 | private: |
| 167 | void MergeConfigMap(const LayerOptions& Options); |