blob: e0e7f504c73f5823d28c6d1b308cd6aa583f2949 [file] [log] [blame]
Alexander Hansen0119cd72025-01-14 14:15:39 +01001
2#include "common/include/device_config.hpp"
3
4#include <regex>
5#include <stdexcept>
6
7DeviceConfig::DeviceConfig(uint32_t vendorIANA, const std::string& compatible,
8 const std::string& configType,
9 const std::string& name) :
10 vendorIANA(vendorIANA), compatibleHardware(compatible), configName(name),
11 configType(configType)
12{
13 std::regex reCompatible("([a-zA-Z0-9])+(\\.([a-zA-Z0-9])+)+");
14 std::cmatch m;
15
16 if (name.empty())
17 {
18 throw std::invalid_argument(
19 "invalid EM config 'Name' string: '" + name + "'");
20 }
21
22 // check compatible string with regex
23 if (!std::regex_match(compatible.c_str(), m, reCompatible))
24 {
25 throw std::invalid_argument(
26 "invalid compatible string: '" + compatible + "'");
27 }
28}