Akonadi

private/protocolgen/main.cpp
1 /*
2  Copyright (c) 2017 Daniel Vrátil <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include <QCoreApplication>
21 #include <QCommandLineParser>
22 
23 #include "cppgenerator.h"
24 #include "xmlparser.h"
25 
26 #include <iostream>
27 
28 
29 int main(int argc, char **argv)
30 {
31  QCoreApplication app(argc, argv);
32 
33  QCommandLineParser parser;
34  parser.addPositionalArgument(QStringLiteral("file"), QStringLiteral("File"));
35  parser.addHelpOption();
36  parser.process(app);
37 
38  const auto args = parser.positionalArguments();
39  if (args.isEmpty()) {
40  std::cerr << "No file specified" << std::endl;
41  return 1;
42  }
43 
44  XmlParser xmlParser;
45  if (!xmlParser.parse(args[0])) {
46  return -1;
47  }
48 
49  CppGenerator cppGenerator;
50  if (!cppGenerator.generate(xmlParser.tree())) {
51  return -2;
52  } else {
53  return 0;
54  }
55 }
QStringList positionalArguments() const const
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax)
QCommandLineOption addHelpOption()
void process(const QStringList &arguments)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon May 25 2020 22:46:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.