File: main.cpp

package info (click to toggle)
dlt-viewer 2.23.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,432 kB
  • sloc: cpp: 27,832; ansic: 4,454; xml: 491; sh: 154; makefile: 75
file content (142 lines) | stat: -rw-r--r-- 3,322 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/**
 * @licence app begin@
 * Copyright (C) 2014  BMW AG
 *
 * This file is part of COVESA Project Dlt Viewer.
 *
 * Contributions are licensed to the COVESA Alliance under one or more
 * Contribution License Agreements.
 *
 * \copyright
 * This Source Code Form is subject to the terms of the
 * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with
 * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * \author
 * Alexander Wenzel <alexander.aw.wenzel@bmw.de>
 *
 * \file main.cpp
 * For further information see http://www.covesa.global/.
 * @licence end@
 */

#include <QApplication>

#include <iostream>

#include "mainwindow.h"

int main(int argc, char *argv[])
{
    bool noGui = false;

    QApplication a(argc, argv);

    /* parse arguments */
    QStringList args = a.arguments();
    for(int num=1;num<args.size();num++)
    {
        if(args[num]=="--no-gui")
        {
            noGui=true;
        }
        else if(args[num]=="--help")
        {
            std::cout << commandLineOptions << std::endl;
            return 0;
        }
    }

    MainWindow w(noGui);
    w.noGui = noGui;

    /* parse further arguments */
    for(int num=1;num<args.size();num++)
    {
        if(args[num]=="--no-gui")
        {
        }
        else if(args[num]=="--parse-file")
        {
            w.argParseFile = args[++num];
        }
        else if(args[num]=="--parse-dir")
        {
            w.argParseDir = args[++num];
        }
        else if(args[num]=="--parse-cfg")
        {
            w.argParseCfg = args[++num];
        }
        else if(args[num]=="--converte-file")
        {
            w.argConverteFile = args[++num];
        }
        else if(args[num]=="--converte-dir")
        {
            w.argConverteDir = args[++num];
        }
        else if(args[num]=="--read-fibex")
        {
            w.argReadFibex = args[++num];
        }
        else if(args[num]=="--write-fibex")
        {
            w.argWriteFibex = args[++num];
        }
        else if(args[num]=="--write-csv")
        {
            w.argWriteCsv = args[++num];
        }
        else if(args[num]=="--write-id")
        {
            w.argWriteId = args[++num];
        }
        else if(args[num]=="--write-id-app")
        {
            w.argWriteIdApp = args[++num];
        }
        else if(args[num]=="--update-id")
        {
            w.argUpdateIdStart = args[++num];
            w.argUpdateIdEnd = args[++num];
        }
        else if(args[num]=="--update-id-app")
        {
            w.argUpdateIdAppStart = args[++num];
            w.argUpdateIdAppEnd = args[++num];
        }
        else if(args[num]=="--check-double")
        {
            w.checkDouble = true;
        }
        else if(args[num]=="--check-double-app")
        {
            w.checkDoubleApp = true;
        }
        else
        {
            std::cout <<  "Unknown option: " << (const char*)(args[num].toLatin1()) << std::endl;
            return -1;
        }
    }

    if(!w.noGui)
    {
        /* show main window */
        w.show();
    }

    /* execute arguments if they exist */
    int errorCode = w.argsParser();

    if(w.noGui)
    {
        return errorCode;
    }
    else
    {
        /* run main loop of main window */
        return a.exec();
    }
}