Permalink
Browse files

parser: do thing where they make sense

  • Loading branch information...
1 parent e4f3d49 commit 02e9ba34bdc6aa66dd2ee1ec160f0d4e1294db10 @MighMoS committed Apr 16, 2009
Showing with 14 additions and 17 deletions.
  1. +9 −15 src/parser.cc
  2. +5 −2 src/parser.hh
View
24 src/parser.cc
@@ -229,8 +229,8 @@ static Track* fill_track (const xmlmapIter& track_iter)
*
* @todo Check to see if filename is a complete path
*/
-static inline std::string find_map_file (const std::string& filename,
- const std::string& additional_path = std::string("./"))
+static inline std::string
+find_map_file (const std::string& filename, const std::string& additional_path)
{
static const std::string data_dir =
Glib::get_user_data_dir () + "/freetrail";
@@ -258,17 +258,20 @@ static inline std::string find_map_file (const std::string& filename,
}
/**
- *@todo Check that all destinations are reachable
- */
-static Map* fill_map (const std::string& filename)
+ @returns a pointer to a newly allocated Map object.
+ @note the caller is responcible for @c deleting the returned map.
+ @todo Check that all destinations are reachable
+*/
+Map* MapParser::parse () const
{
TrackContainer all_tracks;
xmlpp::DomParser parser;
xmlpp::Node::NodeList track_list;
const xmlpp::Element* root_element;
const xmlpp::Attribute* starting_track;
Glib::ustring first_track;
- const std::string complete_file_name = find_map_file (filename);
+ const std::string complete_file_name =
+ find_map_file (_filename, _filepath);
Freetrail::Debug ("Loading file: " + complete_file_name);
@@ -325,12 +328,3 @@ static Map* fill_map (const std::string& filename)
return new Map (first_track, all_tracks);
}
-/**
- @returns a pointer to a newly allocated Map object.
- @note the caller is responcible for @c deleting the returned map.
-*/
-Map* MapParser::parse () const
-{
- return fill_map (_filename);
-}
-
View
7 src/parser.hh
@@ -20,11 +20,14 @@ class MapParsingException : public std::runtime_error
class MapParser
{
const Glib::ustring _filename; ///< name of the file we'll load.
+ const std::string _filepath; ///<Where to look
+
public:
/// Construct a new parser that will parse the map called [filename].
///@param filename name of the file (not the full path) to load.
- MapParser (const Glib::ustring& filename = "example.xml") :
- _filename (filename) {};
+ MapParser (const Glib::ustring& filename,
+ const std::string& filepath = std::string ("./")) :
+ _filename (filename), _filepath (filepath) {};
/// Process the XML into a usable Map object.
Map* parse () const;

0 comments on commit 02e9ba3

Please sign in to comment.