• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • datahandlers
ksparser.h
Go to the documentation of this file.
1 /***************************************************************************
2  KSParser.h - K Desktop Planetarium
3  -------------------
4  begin : 2012/24/06
5  copyright : (C) 2012 by Rishab Arora
6  email : ra.rishab@gmail.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef KSTARS_KSPARSER_H
19 #define KSTARS_KSPARSER_H
20 #include "kstars/ksfilereader.h"
21 #include <kstandarddirs.h>
22 #include <QList>
23 #include <QFile>
24 #include <QHash>
25 #include <QDebug>
26 #include <QVariant>
27 
49 class KSParser {
50  public:
54  static const double EBROKEN_DOUBLE;
55  static const float EBROKEN_FLOAT;
56  static const int EBROKEN_INT;
57  static const QString EBROKEN_QSTRING;
58 
67  enum DataTypes {
68  D_QSTRING,
69  D_INT,
70  D_FLOAT,
71  D_DOUBLE,
72  D_SKIP
73  };
74 
91  KSParser(const QString &filename, const char comment_char,
92  const QList< QPair<QString, DataTypes> > &sequence,
93  const char delimiter = ',');
94 
121  KSParser(const QString &filename, const char comment_char,
122  const QList< QPair<QString, DataTypes> > &sequence,
123  const QList<int> &widths);
124 
132  QHash<QString, QVariant> ReadNextRow();
133 
139  bool HasNextRow();
140  // Too many warnings when const: datahandlers/ksparser.h:131:27: warning:
141  // type qualifiers ignored on function return type [-Wignored-qualifiers]
142 
151  void SetProgress(QString msg, int total_lines, int step_size);
152 
158  void ShowProgress();
159 
160  private:
167  QHash<QString, QVariant> (KSParser::*readFunctionPtr)();
168 
175  QHash<QString, QVariant> ReadCSVRow();
176 
183  QHash<QString, QVariant> ReadFixedWidthRow();
184 
191  QHash<QString, QVariant> DummyRow();
192 
202  QList<QString> CombineQuoteParts(QList<QString> &separated);
203 
211  QVariant ConvertToQVariant(const QString &input_string,
212  const DataTypes &data_type, bool &ok);
213 
214  static const bool parser_debug_mode_;
215 
216  KSFileReader file_reader_;
217  QString filename_;
218  int current_row_id_;
219  bool more_rows_;
220  char comment_char_;
221 
222  QList< QPair<QString, DataTypes> > name_type_sequence_;
223  QList<int> width_sequence_;
224  char delimiter_;
225 };
226 
227 #endif // KSTARS_KSPARSER_H
KSParser::HasNextRow
bool HasNextRow()
Returns True if there are more rows to be read.
Definition: ksparser.cpp:218
KSParser
Generic class for text file parsers used in KStars.
Definition: ksparser.h:49
KSParser::EBROKEN_DOUBLE
static const double EBROKEN_DOUBLE
These are the values used in case of error in conversion.
Definition: ksparser.h:54
KSParser::EBROKEN_QSTRING
static const QString EBROKEN_QSTRING
Definition: ksparser.h:57
KSParser::D_DOUBLE
Definition: ksparser.h:71
KSParser::DataTypes
DataTypes
DataTypes for building sequence D_QSTRING QString Type D_INT Integer Type D_FLOAT Floating Point Type...
Definition: ksparser.h:67
KSParser::KSParser
KSParser(const QString &filename, const char comment_char, const QList< QPair< QString, DataTypes > > &sequence, const char delimiter= ',')
Returns a CSV parsing instance of a KSParser type object.
Definition: ksparser.cpp:28
KSParser::ShowProgress
void ShowProgress()
Wrapper function for KSFileReader showProgress.
Definition: ksparser.cpp:227
KSParser::EBROKEN_INT
static const int EBROKEN_INT
Definition: ksparser.h:56
KSParser::D_FLOAT
Definition: ksparser.h:70
KSParser::SetProgress
void SetProgress(QString msg, int total_lines, int step_size)
Wrapper function for KSFileReader setProgress.
Definition: ksparser.cpp:222
KSParser::EBROKEN_FLOAT
static const float EBROKEN_FLOAT
Definition: ksparser.h:55
KSParser::D_INT
Definition: ksparser.h:69
ksfilereader.h
KSFileReader
Definition: ksfilereader.h:65
KSParser::ReadNextRow
QHash< QString, QVariant > ReadNextRow()
Generic function used to read the next row of a text file.
Definition: ksparser.cpp:56
KSParser::D_SKIP
Definition: ksparser.h:72
KSParser::D_QSTRING
Definition: ksparser.h:68
QList
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal