File indexing completed on 2024-11-10 04:40:46

0001 /*
0002     SPDX-FileCopyrightText: 2017 Daniel Vrátil <dvratil@kde.og>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include <QCommandLineParser>
0008 #include <QCoreApplication>
0009 
0010 #include "cppgenerator.h"
0011 #include "xmlparser.h"
0012 
0013 #include <iostream>
0014 
0015 int main(int argc, char **argv)
0016 {
0017     QCoreApplication app(argc, argv);
0018 
0019     QCommandLineParser parser;
0020     parser.addPositionalArgument(QStringLiteral("file"), QStringLiteral("File"));
0021     parser.addHelpOption();
0022     parser.process(app);
0023 
0024     const auto args = parser.positionalArguments();
0025     if (args.isEmpty()) {
0026         std::cerr << "No file specified" << std::endl;
0027         return 1;
0028     }
0029 
0030     XmlParser xmlParser;
0031     if (!xmlParser.parse(args[0])) {
0032         return -1;
0033     }
0034 
0035     CppGenerator cppGenerator;
0036     if (!cppGenerator.generate(xmlParser.tree())) {
0037         return -2;
0038     } else {
0039         return 0;
0040     }
0041 }