2019-11-14 09:34:46 +00:00
|
|
|
#include <iostream>
|
2019-11-14 07:18:00 +00:00
|
|
|
#include <cxxopts.hpp>
|
2019-11-14 09:34:46 +00:00
|
|
|
#include <XmlParser.hpp>
|
2019-11-14 07:18:00 +00:00
|
|
|
|
2019-11-14 09:34:46 +00:00
|
|
|
int main(int argc, char** argv){
|
|
|
|
// Create and configure options for the program
|
|
|
|
cxxopts::Options options("svd2cpp", "Parser from svd files to C++ header");
|
|
|
|
options.add_options()
|
|
|
|
("i, input", "File to be parsed", cxxopts::value<std::string>())
|
|
|
|
("o, output", "OutputFile", cxxopts::value<std::string>());
|
|
|
|
std::string inputFile, outputFile;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
auto result = options.parse(argc, argv);
|
|
|
|
if(result.count("input") != 1){
|
|
|
|
std::cout << "Missing input file!" << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if(result.count("output") != 1){
|
|
|
|
std::cout << "Missing output file!" << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
inputFile = result["input"].as<std::string>();
|
|
|
|
outputFile = result["output"].as<std::string>();
|
|
|
|
std::cout << "Input: " << inputFile << "\tOutput: " << outputFile << std::endl;
|
|
|
|
}
|
|
|
|
catch(cxxopts::OptionException& ex){
|
|
|
|
std::cout << ex.what() << std::endl;
|
2019-11-14 12:38:04 +00:00
|
|
|
return 2;
|
2019-11-14 09:34:46 +00:00
|
|
|
}
|
2019-11-14 12:38:04 +00:00
|
|
|
//Try to parse the file
|
2019-11-14 09:34:46 +00:00
|
|
|
XmlParser xmlParser(inputFile);
|
2019-11-14 12:38:04 +00:00
|
|
|
if (auto err = xmlParser.isError()){
|
|
|
|
std::cout << "There was an error while reading " << inputFile << ":" << std::endl << *err << std::endl;
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
xmlParser.parseXml();
|
2019-11-14 06:36:44 +00:00
|
|
|
}
|