source: ntrip/trunk/GnssCenter/src/inpedit/inpfile.cpp@ 5000

Last change on this file since 5000 was 5000, checked in by mervart, 9 years ago
File size: 2.0 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * RTNet GUI
4 * -------------------------------------------------------------------------
5 *
6 * Class: t_inpFile
7 *
8 * Purpose: RTNet Input File
9 *
10 * Author: L. Mervart
11 *
12 * Created: 05-Jan-2013
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include "inpfile.h"
19#include "keyword.h"
20#include "panel.h"
21
22using namespace std;
23using namespace GnssCenter;
24
25// Constructor
26////////////////////////////////////////////////////////////////////////////
27t_inpFile::t_inpFile(const QString& fileName) : QTabWidget(0) {
28 _fileName = fileName;
29 readFile();
30}
31
32// Destructor
33////////////////////////////////////////////////////////////////////////////
34t_inpFile::~t_inpFile() {
35 QMapIterator<QString, t_keyword*> it(_keywords);
36 while (it.hasNext()) {
37 it.next();
38 delete it.value();
39 }
40}
41
42//
43////////////////////////////////////////////////////////////////////////////
44void t_inpFile::readFile() {
45
46 QFile file(_fileName);
47 file.open(QIODevice::ReadOnly | QIODevice::Text);
48 QTextStream inStream(&file);
49
50 int iPanel = 0;
51
52 while (inStream.status() == QTextStream::Ok && !inStream.atEnd()) {
53 QString line = inStream.readLine().trimmed();
54
55 // Skip Comments and empty Lines
56 // -----------------------------
57 if (line.isEmpty() || line[0] == '!') {
58 continue;
59 }
60
61 // Read Panels
62 // -----------
63 else if (line[0] == '#' && line.indexOf("BEGIN_PANEL") != -1) {
64 t_panel* panel = new t_panel(line, inStream, &_keywords);
65 if (panel->ok()) {
66 ++iPanel;
67 addTab(panel, QString("Panel %1").arg(iPanel));
68 }
69 else {
70 delete panel;
71 }
72 }
73
74 // Read Keywords
75 // -------------
76 else {
77 t_keyword* keyword = new t_keyword(line, inStream);
78 if (keyword->ok()) {
79 _keywords[keyword->name()] = keyword;
80 }
81 else {
82 delete keyword;
83 }
84 }
85 }
86}
Note: See TracBrowser for help on using the repository browser.