Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
inputreader.h
Go to the documentation of this file.
1 #ifndef INPUTREADER_H
2 #define INPUTREADER_H
3 
4 
5 #include <QAbstractMessageHandler>
6 #include <QXmlItem>
7 #include <QTransform>
8 
9 #include <types.h>
10 #include <datapath.h>
11 #include <path.h>
12 
13 namespace frechet { namespace input {
14 
32 class InputReader {
33 // Q_OBJECT ?
34 private:
36  QVector<Path> results;
38  QString error_message;
39  bool is_svg;
40  bool is_ipe;
41  bool is_kml;
42  bool is_script;
43 
44 public:
46  QVector<Path>& getResults() { return results; }
47 
49  void clear();
52  void readAll(const DataPath& path);
53 
55  bool isSvg() const { return is_svg; }
57  bool isIpe() const { return is_ipe; }
59  bool isScript() const { return is_script; }
60 
62  QString errorMessage() { return error_message; }
63 
64 private:
69  void readAll(QIODevice* device, QString fileSuffix, QString queryString);
74  void readXml(QIODevice* device, QString fileSuffix, QString xmlPath);
79  Path readSvgPath(QString text, QTransform tf = QTransform());
84  Path readIpePath(QString text, QTransform tf = QTransform());
88  bool readScript(QString program);
89 
92  static bool isZipFile(QString suffix);
95  static bool isGzipFile(QString suffix);
98  static bool isXmlFile(QString suffix);
101  static bool isCsvFile(QString suffix);
104  static bool isSvgFile(QString suffix);
107  static bool isIpeFile(QString suffix);
110  static bool isScriptFile(QString suffix);
111 
113  class XmlMessageHandler: public QAbstractMessageHandler {
114  void handleMessage(QtMsgType type,
115  const QString &description,
116  const QUrl &identifier,
117  const QSourceLocation &sourceLocation);
118  };
125  QTransform readTransformationMatrix(QXmlItem item, QXmlNamePool namepool);
126 };
127 
128 
129 } } // namespace frechet::input
130 #endif // INPUTREADER_H
The InputReader class reads input data from a file.
Definition: inputreader.h:32
handles XML parse errors; used for debugging only
Definition: inputreader.h:113
static bool isXmlFile(QString suffix)
location of input data in an XML file
Definition: datapath.h:24
Path readSvgPath(QString text, QTransform tf=QTransform())
read a polygonal curve from an SVG string
global definitions for all algorithms.
void readAll(const DataPath &path)
read polygonal curves from a file
Definition: inputreader.cpp:26
bool readScript(QString program)
read a JavaScript file
Definition: scriptinput.cpp:12
bool is_svg
is it an SVG file?
Definition: inputreader.h:39
QTransform readTransformationMatrix(QXmlItem item, QXmlNamePool namepool)
read a transformation matrix from XML
static bool isSvgFile(QString suffix)
static bool isGzipFile(QString suffix)
static bool isZipFile(QString suffix)
static bool isScriptFile(QString suffix)
bool is_kml
not implemented
Definition: inputreader.h:41
Represents a polygonal curve.
Definition: path.h:30
void handleMessage(QtMsgType type, const QString &description, const QUrl &identifier, const QSourceLocation &sourceLocation)
QVector< Path > results
result values; expected to contain 2 result
Definition: inputreader.h:36
QVector< Path > & getResults()
Definition: inputreader.h:46
bool is_ipe
is it an IPE file?
Definition: inputreader.h:40
QString error_message
parse error
Definition: inputreader.h:38
bool is_script
is it a JavaScript file
Definition: inputreader.h:42
Path readIpePath(QString text, QTransform tf=QTransform())
read a polygonal curve from an IPE string
static bool isIpeFile(QString suffix)
void clear()
clear results
Definition: inputreader.cpp:20
void readXml(QIODevice *device, QString fileSuffix, QString xmlPath)
read polygonal curves from an XML file
Definition: inputreader.cpp:78
static bool isCsvFile(QString suffix)