| 235 | } |
| 236 | |
| 237 | Options extractOptions(NL::json& node) |
| 238 | { |
| 239 | Options options; |
| 240 | |
| 241 | for (auto& it : node.items()) |
| 242 | { |
| 243 | NL::json& subnode = it.value(); |
| 244 | const std::string& name = it.key(); |
| 245 | |
| 246 | if (name == "plugin") |
| 247 | { |
| 248 | PluginManager<Stage>::loadPlugin(subnode.get<std::string>()); |
| 249 | |
| 250 | // Don't actually put a "plugin" option on |
| 251 | // any stage |
| 252 | continue; |
| 253 | } |
| 254 | |
| 255 | if (subnode.is_array()) |
| 256 | { |
| 257 | for (const NL::json& val : subnode) |
| 258 | if (val.is_object()) |
| 259 | options.add(name, val); |
| 260 | else if (!extractOption(options, name, val)) |
| 261 | throw pdal_error("JSON pipeline: Invalid value type for " |
| 262 | "option list '" + name + "'."); |
| 263 | } |
| 264 | else if (subnode.is_object()) |
| 265 | options.add(name, subnode); |
| 266 | else if (!extractOption(options, name, subnode)) |
| 267 | throw pdal_error("JSON pipeline: Value of stage option '" + |
| 268 | name + "' cannot be converted."); |
| 269 | } |
| 270 | node.clear(); |
| 271 | return options; |
| 272 | } |
| 273 | |
| 274 | std::string extractType(NL::json& node) |
| 275 | { |
no test coverage detected