Helper to translate Windows registry value type to enum ValueType
| 69 | |
| 70 | // Helper to translate Windows registry value type to enum ValueType |
| 71 | cm::optional<cmWindowsRegistry::ValueType> ToValueType(DWORD type) |
| 72 | { |
| 73 | using ValueType = cmWindowsRegistry::ValueType; |
| 74 | |
| 75 | static std::unordered_map<DWORD, ValueType> ValueTypes{ |
| 76 | { REG_SZ, ValueType::Reg_SZ }, |
| 77 | { REG_EXPAND_SZ, ValueType::Reg_EXPAND_SZ }, |
| 78 | { REG_MULTI_SZ, ValueType::Reg_MULTI_SZ }, |
| 79 | { REG_DWORD, ValueType::Reg_DWORD }, |
| 80 | { REG_QWORD, ValueType::Reg_QWORD } |
| 81 | }; |
| 82 | |
| 83 | auto it = ValueTypes.find(type); |
| 84 | |
| 85 | return it == ValueTypes.end() |
| 86 | ? cm::nullopt |
| 87 | : cm::optional<cmWindowsRegistry::ValueType>{ it->second }; |
| 88 | } |
| 89 | |
| 90 | // class registry_exception |
| 91 | class registry_error : public std::exception |