File: main.cpp

package info (click to toggle)
plotsauce 0~0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 408 kB
  • sloc: ansic: 2,495; cpp: 448; makefile: 44
file content (55 lines) | stat: -rw-r--r-- 1,371 bytes parent folder | download
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
//Qt includes
#include <QtCore/QCoreApplication>
#include <QStringList>
#include <QFileInfo>
#include <QDebug>

//Our includes
#include <psSurvex3DParser.h>
#include <psXMLWriter.h>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QStringList args = a.arguments();
    if(args.isEmpty() || args.size() != 3) {
        qDebug() << "How to run: \n./plotsauce [Input File (survex .3d)] [Output XML file] ";
        return 1;
    }

    QList<psStation*> stations;
    QList<psLine*> lines;

    QString inputFilename = args[1]; //.first();
    QString outputFilename = args[2];

    QFileInfo fileinfo(inputFilename);

    if(fileinfo.exists()) {
        if(fileinfo.suffix().compare("3d", Qt::CaseInsensitive) == 0) {
            //We found a survex file
            psSurvex3DParser survexParser;
            survexParser.parse(inputFilename);

            stations = survexParser.stations();
            lines = survexParser.lines();

        } else {
            qDebug() << "Plot sauces doesn't know how to handle " << fileinfo.suffix() << "files";
            return 1;
        }
    } else {
        qDebug() << inputFilename << "doesn't exist!";
        return 1;
    }

    //Write data to the file
    psXMLWriter writer;
    writer.setLines(lines);
    writer.setStations(stations);
    writer.write(outputFilename);

    return 0;

}