Debian Codegraph @

example/src/main.cpp

raw symbols SCIP
1
2 // Qt
3 #include <QApplication>
4
5 // Demo
6 #include <MainWindow.hpp>
7
8 const char* codeSample = R"(
9 /****************************************************************************
10 **
11 ** Copyright (C) 2016 The Qt Company Ltd.
12 ** Contact: https://www.qt.io/licensing/
13 **
14 ** This file is part of the examples of the Qt Toolkit.
15 **
16 ** $QT_BEGIN_LICENSE:BSD$
17 ** Commercial License Usage
18 ** Licensees holding valid commercial Qt licenses may use this file in
19 ** accordance with the commercial license agreement provided with the
20 ** Software or, alternatively, in accordance with the terms contained in
21 ** a written agreement between you and The Qt Company. For licensing terms
22 ** and conditions see https://www.qt.io/terms-conditions. For further
23 ** information use the contact form at https://www.qt.io/contact-us.
24 **
25 ** BSD License Usage
26 ** Alternatively, you may use this file under the terms of the BSD license
27 ** as follows:
28 **
29 ** "Redistribution and use in source and binary forms, with or without
30 ** modification, are permitted provided that the following conditions are
31 ** met:
32 ** * Redistributions of source code must retain the above copyright
33 ** notice, this list of conditions and the following disclaimer.
34 ** * Redistributions in binary form must reproduce the above copyright
35 ** notice, this list of conditions and the following disclaimer in
36 ** the documentation and/or other materials provided with the
37 ** distribution.
38 ** * Neither the name of The Qt Company Ltd nor the names of its
39 ** contributors may be used to endorse or promote products derived
40 ** from this software without specific prior written permission.
41 **
42 **
43 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
54 **
55 ** $QT_END_LICENSE$
56 **
57 ****************************************************************************/
58
59 #include <QCoreApplication>
60 #include <QTextStream>
61
62 #include "game.h"
63 //! [0]
64 int main(int argc, char *argv[])
65 {
66 )" "\t" R"(QCoreApplication app(argc, argv);
67 QStringList args = QCoreApplication::arguments();
68 bool newGame = true;
69 if (args.length() > 1)
70 newGame = (args[1].toLower() != QStringLiteral("load"));
71 bool json = true;
72 if (args.length() > 2)
73 json = (args[2].toLower() != QStringLiteral("binary"));
74
75 Game game;
76 if (newGame)
77 game.newGame();
78 else if (!game.loadGame(json ? Game::Json : Game::Binary))
79 return 1;
80 // Game is played; changes are made...
81 //! [0]
82 //! [1]
83 QTextStream(stdout) << "Game ended in the following state:\n";
84 game.print();
85 if (!game.saveGame(json ? Game::Json : Game::Binary))
86 return 1;
87
88 return 0;
89 }
90 //! [1]
91
92 )";
93
94 int main(int argc, char** argv)
95 {
96 // Creating application
97 QApplication a(argc, argv);
98
99 // Creating main window
100 MainWindow w;
101 w.show();
102
103 return QApplication::exec();
104 }