#include #include #include #include namespace hex::plugin::builtin { ConstantGroup::ConstantGroup(const std::fs::path &path) { if (!wolv::io::fs::exists(path)) throw std::runtime_error("Path does not exist"); if (path.extension() != ".json") throw std::runtime_error("Invalid constants file extension"); try { auto fileData = wolv::io::File(path, wolv::io::File::Mode::Read).readString(); auto content = nlohmann::json::parse(fileData); m_name = content.at("name").get(); const auto values = content.at("values"); for (const auto &value : values) { Constant constant = {}; constant.name = value.at("name").get(); if (value.contains("desc")) constant.description = value.at("desc").get(); constant.value = BinaryPattern(value.at("value").get()); m_constants.push_back(constant); } } catch (...) { throw std::runtime_error("Failed to parse constants file " + wolv::util::toUTF8String(path)); } } }