| 246 | } |
| 247 | |
| 248 | int main(int argc, char **argv) |
| 249 | { |
| 250 | |
| 251 | po::options_description desc("Allowed options"); |
| 252 | // These operator() really screw up clang-format |
| 253 | // clang-format off |
| 254 | desc.add_options() |
| 255 | ("help", "Show help message") |
| 256 | ("xml,x", po::value<std::string>(),"Input XML file") |
| 257 | ("output-header,h", po::value<std::string>(), "Path to output generated header file") |
| 258 | ("output-source,o", po::value<std::string>(), "Path to output generated source file") |
| 259 | ; |
| 260 | // clang-format on |
| 261 | |
| 262 | po::variables_map vm; |
| 263 | po::store(po::parse_command_line(argc, argv, desc), vm); |
| 264 | po::notify(vm); |
| 265 | |
| 266 | std::string inputXmlPath; |
| 267 | std::string outputHeaderPath; |
| 268 | std::string outputSourcePath; |
| 269 | |
| 270 | if (vm.count("help")) |
| 271 | { |
| 272 | std::cout << desc << "\n"; |
| 273 | return 1; |
| 274 | } |
| 275 | if (!vm.count("xml")) |
| 276 | { |
| 277 | std::cerr << "Must specify input XML file\n" << desc << "\n"; |
| 278 | return 1; |
| 279 | } |
| 280 | if (!vm.count("output-header")) |
| 281 | { |
| 282 | std::cerr << "Must specify output header file\n" << desc << "\n"; |
| 283 | return 1; |
| 284 | } |
| 285 | if (!vm.count("output-source")) |
| 286 | { |
| 287 | std::cerr << "Must specify output source file\n" << desc << "\n"; |
| 288 | return 1; |
| 289 | } |
| 290 | |
| 291 | inputXmlPath = vm["xml"].as<std::string>(); |
| 292 | outputHeaderPath = vm["output-header"].as<std::string>(); |
| 293 | outputSourcePath = vm["output-source"].as<std::string>(); |
| 294 | |
| 295 | std::ifstream inputXmlFile(inputXmlPath); |
| 296 | if (!inputXmlFile) |
| 297 | { |
| 298 | std::cerr << "Failed to open input XML file \"" << inputXmlPath << "\"\n"; |
| 299 | return 1; |
| 300 | } |
| 301 | |
| 302 | std::ofstream outputSourceFile(outputSourcePath); |
| 303 | if (!outputSourceFile) |
| 304 | { |
| 305 | std::cerr << "Failed to open output source file at \"" << outputSourcePath << "\"\n"; |
nothing calls this directly
no test coverage detected