15#include <unordered_map>
24 double Struct::*
const mem {};
25 const char*
const key {};
28static const std::vector<SettingDescription<CompressorSettings>>
43const std::vector<SettingDescription<LimiterSettings>>
56template <
typename Struct>
58 const std::string&
str,
63 const std::regex pattern(R
"((\w+)=\"(-?\d+\.?\d*)\")");
66 std::unordered_map<std::string, std::string>
values;
68 const auto begin = std::sregex_iterator(
str.begin(),
str.end(), pattern);
69 const auto end = std::sregex_iterator();
71 for (
auto it =
begin; it !=
end; ++it)
73 const std::smatch match = *it;
74 values[match[1].str()] = match[2].str();
79 return values.find(setting.key) == values.end();
86 settingStruct.*(setting.mem) = std::stod(
values.at(setting.key));
96template <
typename Struct>
99 const std::vector<Detail::SerializedPreset>& serializedPresets)
101 std::vector<Preset<Struct>> presets;
102 for (
const auto& serialized : serializedPresets)
105 Deserialize<Struct>(serialized.settings, settingDescriptions))
106 presets.push_back({ serialized.name, *
preset });
113std::vector<DynamicRangeProcessorUtils::CompressorPreset>
116 return GetPresets<CompressorSettings>(
120std::vector<DynamicRangeProcessorUtils::LimiterPreset>
123 return GetPresets<LimiterSettings>(
static Settings & settings()
const std::vector< SerializedPreset > serializedLimiterPresets
const std::vector< SerializedPreset > serializedCompressorPresets
std::optional< Struct > Deserialize(const std::string &str, const std::vector< SettingDescription< Struct > > &settings)
std::vector< Preset< Struct > > GetPresets(const std::vector< SettingDescription< Struct > > &settingDescriptions, const std::vector< Detail::SerializedPreset > &serializedPresets)
const std::vector< SettingDescription< LimiterSettings > > limiterSettingDescriptions
static const std::vector< SettingDescription< CompressorSettings > > compressorSettingDescriptions
DYNAMIC_RANGE_PROCESSOR_API std::vector< CompressorPreset > GetCompressorPresets()
DYNAMIC_RANGE_PROCESSOR_API std::vector< LimiterPreset > GetLimiterPresets()
const char * end(const char *str) noexcept
const char * begin(const char *str) noexcept