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

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • routing
  • instructions
WaypointParser.h
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2010 Dennis Nienhüser <earthwings@gentoo.org>
9 //
10 
11 #ifndef MARBLE_WAYPOINTPARSER_H
12 #define MARBLE_WAYPOINTPARSER_H
13 
14 #include "RoutingWaypoint.h"
15 #include "marble_export.h"
16 
17 #include <QTextStream>
18 #include <QMap>
19 #include <QVariant>
20 #include <QStringList>
21 
22 namespace Marble
23 {
24 
25 class MARBLE_EXPORT WaypointParser
26 {
27 public:
29  enum Field {
30  Longitude,
31  Latitude,
32  JunctionType,
33  RoadName,
34  TotalSecondsRemaining,
35  RoadType
36  };
37 
39  WaypointParser();
40 
42  RoutingWaypoints parse( QTextStream &stream ) const;
43 
45  void setFieldIndex( Field field, int index );
46 
48  void setLineSeparator( const QString &separator );
49 
51  void setFieldSeparator( const QChar &separator );
52 
54  void addJunctionTypeMapping( const QString &key, RoutingWaypoint::JunctionType value );
55 
56 private:
57  template<class T>
58  T readField( Field field, const QStringList &fields, const T &defaultValue = T() ) const {
59  int index = m_fieldIndices[field];
60  if ( index >= 0 && index < fields.size() ) {
61  return QVariant( fields[index] ).value<T>();
62  }
63 
64  return defaultValue;
65  }
66 
67  QString m_lineSeparator;
68 
69  QChar m_fieldSeparator;
70 
71  QMap<Field, int> m_fieldIndices;
72 
73  QMap<QString, RoutingWaypoint::JunctionType> m_junctionTypeMapping;
74 
75  Q_DISABLE_COPY( WaypointParser )
76 };
77 
78 } // namespace Marble
79 
80 #endif // MARBLE_WAYPOINTPARSER_H
Marble::WaypointParser::RoadName
Definition: WaypointParser.h:33
RoutingWaypoint.h
Marble::WaypointParser::TotalSecondsRemaining
Definition: WaypointParser.h:34
QChar
QMap< Field, int >
QVariant::value
T value() const
Marble::WaypointParser::Field
Field
Fields which can be parsed.
Definition: WaypointParser.h:29
QTextStream
QList::size
int size() const
Marble::WaypointParser::Latitude
Definition: WaypointParser.h:31
Marble::WaypointParser::JunctionType
Definition: WaypointParser.h:32
MARBLE_EXPORT
#define MARBLE_EXPORT
Definition: marble_export.h:20
QString
QStringList
Marble::WaypointParser::Longitude
Definition: WaypointParser.h:30
QVector
marble_export.h
Marble::WaypointParser
Definition: WaypointParser.h:25
Marble::RoutingWaypoint::JunctionType
JunctionType
Junction types that affect instructions.
Definition: RoutingWaypoint.h:29
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • 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
  • 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