[Marble-commits] KDE/kdeedu/marble/src/lib/geodata/parser
Thibaut Gridel
tgridel at free.fr
Wed Sep 9 23:15:59 CEST 2009
SVN commit 1021712 by tgridel:
GeoDataParser: provide GeoData_UNKNOWN to defer data source determination at root document tag validation
M +21 -1 GeoDataParser.cpp
M +2 -1 GeoDataParser.h
M +1 -1 GeoOnfParser.cpp
M +1 -1 GeoOnfParser.h
M +1 -1 GeoParser.h
M +1 -1 GeoSceneParser.cpp
M +1 -1 GeoSceneParser.h
--- trunk/KDE/kdeedu/marble/src/lib/geodata/parser/GeoDataParser.cpp #1021711:1021712
@@ -53,8 +53,28 @@
{
}
-bool GeoDataParser::isValidRootElement() const
+bool GeoDataParser::isValidRootElement()
{
+ if (m_source == GeoData_UNKNOWN)
+ {
+ if (GeoParser::isValidElement(gpx::gpxTag_gpx))
+ {
+ m_source = GeoData_GPX;
+ }
+ else if (GeoParser::isValidElement(kml::kmlTag_kml))
+ {
+ m_source = GeoData_KML;
+ }
+ else if (GeoParser::isValidElement("osm"))
+ {
+ m_source = GeoData_OSM;
+ }
+ else
+ {
+ Q_ASSERT(false);
+ return false;
+ }
+ }
switch ((GeoDataSourceType) m_source) {
// TODO: case GeoData_GeoRSS:
case GeoData_GPX:
--- trunk/KDE/kdeedu/marble/src/lib/geodata/parser/GeoDataParser.h #1021711:1021712
@@ -32,6 +32,7 @@
class GeoDataDocument;
enum GeoDataSourceType {
+ GeoData_UNKNOWN = -1,
GeoData_GPX = 0,
GeoData_KML = 1,
GeoData_GeoRSS = 2,
@@ -46,7 +47,7 @@
private:
virtual bool isValidElement(const QString& tagName) const;
- virtual bool isValidRootElement() const;
+ virtual bool isValidRootElement();
virtual void raiseRootElementError();
virtual GeoDocument* createDocument() const;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/parser/GeoOnfParser.cpp #1021711:1021712
@@ -33,7 +33,7 @@
setNamespaceProcessing( false );
}
-bool GeoOnfParser::isValidRootElement() const
+bool GeoOnfParser::isValidRootElement()
{
return isValidElement( OsmNamefinder::tag_searchresults );
}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/parser/GeoOnfParser.h #1021711:1021712
@@ -35,7 +35,7 @@
GeoOnfParser();
private:
- bool isValidRootElement() const;
+ bool isValidRootElement();
GeoDocument* createDocument() const;
bool isValidElement(const QString& tagName) const;
};
--- trunk/KDE/kdeedu/marble/src/lib/geodata/parser/GeoParser.h #1021711:1021712
@@ -82,7 +82,7 @@
* current XML Document type, e.g. KML, GPX etc.
* @return @c true if the element is a valid document root.
*/
- virtual bool isValidRootElement() const = 0;
+ virtual bool isValidRootElement() = 0;
virtual void raiseRootElementError();
--- trunk/KDE/kdeedu/marble/src/lib/geodata/parser/GeoSceneParser.cpp #1021711:1021712
@@ -46,7 +46,7 @@
{
}
-bool GeoSceneParser::isValidRootElement() const
+bool GeoSceneParser::isValidRootElement()
{
switch ((GeoSceneSourceType) m_source) {
case GeoScene_DGML:
--- trunk/KDE/kdeedu/marble/src/lib/geodata/parser/GeoSceneParser.h #1021711:1021712
@@ -43,7 +43,7 @@
private:
virtual bool isValidElement(const QString& tagName) const;
- virtual bool isValidRootElement() const;
+ virtual bool isValidRootElement();
virtual void raiseRootElementError();
virtual GeoDocument* createDocument() const;
More information about the Marble-commits
mailing list