⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datastorewriter.cpp

📁 GPS Manager is a GUI for downloading, organizing, maintaining, and uploading GPS data (i.e. tracks,
💻 CPP
字号:
/*gpsmgr: A program for managing GPS informationCopyright (C) 2003 Austin BinghamThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.You can reach the author at:    abingham@spamcop.net*/#include "datastorewriter.h"#include "datastore.h"#include <fstream>#include <iostream>#include <sstream>#include "xmlPrinter.h"using namespace std;namespace gpsmgr { namespace io {    class DataStoreWriter : public XMLPrinter    {    public:	DataStoreWriter(ostream& os) :	    XMLPrinter (os)	    {}		void print(const gpsmgr::DataStore& ds) const	    {		writeLn(open("gpsmgr:datastore"));		for (DataStore::Waypoints::const_iterator itr = ds.waypoints().begin();		     itr != ds.waypoints().end();		     ++itr)		{		    printWaypoint(itr->second);		}		for (DataStore::Tracks::const_iterator itr = ds.tracks().begin();		     itr != ds.tracks().end();		     ++itr)		{		    printTrack(itr->second);		}				writeLn(close("gpsmgr:datastore"));	    }	void printWaypoint(const DataStore::WaypointType& wp) const	    {		writeLn(open("gpsmgr:waypoint"));		// Name		writeLn(simpleTag("name", wp.name()));		// Position		writeLn(open("position"));		ostringstream latoss;		latoss << wp.position().lat();		writeLn(simpleTag("lat", latoss.str()));		ostringstream lonoss;		lonoss << wp.position().lon();		writeLn(simpleTag("lon", lonoss.str()));		writeLn(close("position"));		// altitude		ostringstream altoss;		altoss << wp.altitude();		writeLn(simpleTag("altitude", altoss.str()));		// symbol		writeLn(simpleTag("symbol", wp.symbol()));		// comment		writeLn(simpleTag("comment", wp.comment()));		// displayoption		writeLn(simpleTag("displayoption", wp.displayOption()));		// Groups		for (GroupObject::Groups::const_iterator itr = wp.groupsBegin();		     itr != wp.groupsEnd();		     ++itr)		{		    writeLn(simpleTag("group", *itr));		}				writeLn(close("gpsmgr:waypoint"));	    }	void printTrack(const DataStore::TrackType& trk) const	    {		writeLn(open("gpsmgr:track"));		// Name		writeLn(simpleTag("name", trk.name()));		// comment		writeLn(simpleTag("comment", trk.comment()));		// Groups		for (GroupObject::Groups::const_iterator itr = trk.groupsBegin();		     itr != trk.groupsEnd();		     ++itr)		{		    writeLn(simpleTag("group", *itr));		}				for (Track::PointList::const_iterator itr = trk.points().begin();		     itr != trk.points().end();		     ++itr)		{		    writeLn(open("gpsmgr:track_point"));		    // Position		    writeLn(open("position"));		    		    ostringstream oss;		    oss << itr->position().lat();		    writeLn(simpleTag("lat", oss.str()));		    		    oss.str("");		    oss << itr->position().lon();		    writeLn(simpleTag("lon", oss.str()));		    		    writeLn(close("position"));		    // altitude		    oss.str("");		    oss << itr->altitude();		    writeLn(simpleTag("altitude", oss.str()));		    // time		    oss.str("");		    oss << itr->time();		    writeLn(simpleTag("time", oss.str()));		    		    writeLn(close("gpsmgr:track_point"));		}		writeLn(close("gpsmgr:track"));	    }    };    void writeDataStore(ostream& os, const gpsmgr::DataStore& ds)    {	DataStoreWriter p(os);	p.print(ds);    }        void writeDataStore(const string& filename, const gpsmgr::DataStore& ds)    {	ofstream ofs(filename.c_str());	writeDataStore(ofs, ds);    }    } }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -