TariffParser.cpp

Go to the documentation of this file.
00001 #include "StdAfx.h"
00002 
00003 TariffParser::TariffParser(void)
00004 {
00005 }
00006 
00007 TariffParser::~TariffParser(void)
00008 {
00009 }
00010 
00011 void TariffParser::parse(std::string filename) {
00012         std::ifstream tariffData(filename.c_str());
00013         std::string currentTariff;
00014 
00015         while (getline(tariffData, currentTariff)) {
00016                 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
00017                 boost::char_separator<char> sep("|");
00018                 tokenizer tokens(currentTariff, sep);
00019 
00020                 Tariff* tariff = new Tariff();
00021                 tokenizer::iterator tok_iter = tokens.begin();
00022                 tariff->setCountry(*tok_iter++);
00023                 tariff->setDayTariff(boost::lexical_cast<float>(*tok_iter++));
00024                 tariff->setEveningTariff(boost::lexical_cast<float>(*tok_iter++));
00025                 tariff->setWeekendTariff(boost::lexical_cast<float>(*tok_iter));
00026 
00027                 tariffs.push_back(*tariff);
00028         }
00029 }
00030 
00034 const std::vector<Tariff> TariffParser::getTariffs(void) const {
00035         return tariffs;
00036 }

Generated on Tue Sep 12 10:54:49 2006 for Skype Call Cost Estimator by  doxygen 1.4.6