| 165 | |
| 166 | template <typename T> |
| 167 | static T read_toml_value(const toml::table& data, std::string_view key, bool required) { |
| 168 | const toml::node* value_node = data.get(key); |
| 169 | |
| 170 | if (value_node == nullptr) { |
| 171 | if (required) { |
| 172 | throw toml::parse_error(("Missing required field \"" + std::string{key} + "\"").c_str(), data.source()); |
| 173 | } |
| 174 | else { |
| 175 | return T{}; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | std::optional<T> opt = value_node->value_exact<T>(); |
| 180 | if (opt.has_value()) { |
| 181 | return opt.value(); |
| 182 | } |
| 183 | else { |
| 184 | throw toml::parse_error(("Incorrect type for field \"" + std::string{key} + "\"").c_str(), data.source()); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | static const toml::array& read_toml_array(const toml::table& data, std::string_view key, bool required) { |
| 189 | static const toml::array empty_array = toml::array{}; |
nothing calls this directly
no outgoing calls
no test coverage detected