/home/martin/workspace/OpenStreetNav/src/xmlparse/XmlParser.cpp
Go to the documentation of this file.
00001 /*
00002  * XmlParser.cpp
00003  *
00004  *  Created on: Nov 12, 2011
00005  *      Author: martin
00006  */
00007 
00008 #include "XmlParser.h"
00009 
00010 namespace osmxml
00011 {
00012 
00013 
00014 void empty_nd_hndl(const osm::Node& )
00015 {
00016 }
00017 
00018 void empty_r_hndl(const osm::Relation& )
00019 {
00020 }
00021 
00022 void empty_w_hndl(const osm::Way& )
00023 {
00024 }
00025 
00026 void empty_prog_hndl()
00027 {
00028 }
00029 
00030 void empty_msg_hndl(const std::string& )
00031 {
00032 }
00033 
00034 XmlParser::XmlParser():
00035     node_handler(empty_nd_hndl),
00036     way_handler(empty_w_hndl),
00037     relation_handler(empty_r_hndl),
00038     progress_handler(empty_prog_hndl),
00039     doc_p(osm_p, "osm")
00040 {
00041     bound_p.parsers(string_p, uri_p);
00042     member_p.parsers(mt_p, long_p, string_p);
00043     nd_p.parsers(long_p);
00044     tag_p.parsers(string_p, string_p);
00045     node_p.parsers(tag_p, long_p, long_p, string_p, date_time_p, int_p, int_p, bool_p, decimal_p, decimal_p, string_p);
00046     rel_p.parsers(tag_p, member_p, long_p, long_p, string_p, date_time_p, int_p, int_p, bool_p);
00047     way_p.parsers(tag_p, nd_p, long_p, long_p, string_p, date_time_p, int_p, int_p, bool_p);
00048     osm_p.parsers(bound_p, node_p, way_p, rel_p, string_p, string_p);
00049     osm_p.node_handler = [&](osm::Node const & n)
00050     {
00051         this->node_handler(n);
00052     };
00053     osm_p.way_handler = [&](osm::Way const & w)
00054     {
00055         this->way_handler(w);
00056     };
00057     osm_p.relation_handler = [&](osm::Relation const & r)
00058     {
00059         this->relation_handler(r);
00060     };
00061     osm_p.progress_handler = [&]()
00062     {
00063         this->progress_handler();
00064     };
00065 }
00066 
00067 XmlParser::~XmlParser()
00068 {
00069 }
00070 
00071 void XmlParser::parse_file(const std::string& filename)
00072 {
00073     osm_p.pre();
00074     doc_p.parse(filename);
00075     osm_p.post_osm();
00076 }
00077 
00078 void XmlParser::parse_memory(const std::string& mem)
00079 {
00080     std::istringstream str(mem);
00081     parse_stream(str);
00082 }
00083 
00084 void XmlParser::parse_stream(std::istream& stream)
00085 {
00086     osm_p.pre();
00087     doc_p.parse(stream);
00088     osm_p.post_osm();
00089 }
00090 
00091 } /* namespace osmxml */
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines