MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / GetConv

Method GetConv

FEXCore/Source/Interface/Config/Config.cpp:138–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
166private:
167 void MergeConfigMap(const LayerOptions& Options);

Callers

nothing calls this directly

Calls 2

ConvFunction · 0.85
endMethod · 0.45

Tested by

no test coverage detected