Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
83 lines (71 sloc) 2.47 KB
//==============================================================================
//
// gpxls - the gpxls example
//
// Copyright (C) 2013 Dick van Oudheusden
//--
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this library; if not, write to the Free
// Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//==============================================================================
//-
// $Date: 2013-03-10 12:02:27 +0100 (Sun, 10 Mar 2013) $ $Revision: 5 $
//
//==============================================================================
//
#include <fstream>
#include <iostream>
#include "gpx/Parser.h"
#include "gpx/ReportCerr.h"
using namespace std;
int main(int argc, char *argv[])
{
if (argc < 2)
{
cerr << "Usage: gpxls FILE ..." << endl;
cerr << " List the contents of a gpx file." << endl;
exit(1);
}
for (int i = 1; i < argc; i++)
{
ifstream stream(argv[i]);
if (stream.is_open())
{
gpx::ReportCerr report;
gpx::Parser parser(&report);
gpx::GPX *root = parser.parse(stream);
if (root == nullptr)
{
cerr << "Parsing of " << argv[i] << " failed due to " << parser.errorText() << " on line " << parser.errorLineNumber() << " and column " << parser.errorColumnNumber() << endl;
}
else
{
cout << argv[i] << ":" << endl;
cout << " Version : " << root->version().getValue() << endl;
cout << " Creator : " << root->creator().getValue() << endl;
cout << " Name : " << root->metadata().author().name().getValue() << endl;
cout << " Waypoints: " << root->wpts().list().size() << endl;
cout << " Routes : " << root->rtes().list().size() << endl;
cout << " Tracks : " << root->trks().list().size() << endl;
cout << endl;
}
stream.close();
}
else
{
cerr << "File: " << argv[i] << " not found." << endl;
}
}
exit(0);
}