Fix build with updated hash table

This commit is contained in:
Dennis Luxen 2013-08-06 16:58:31 +02:00
parent 3151197471
commit db7d4f56b3

View File

@ -24,6 +24,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include "OSRMException.h" #include "OSRMException.h"
#include "../DataStructures/HashTable.h" #include "../DataStructures/HashTable.h"
#include <boost/algorithm/string.hpp>
#include <exception> #include <exception>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
@ -44,17 +46,13 @@ public:
std::vector<std::string> tokens; std::vector<std::string> tokens;
Tokenize(line, tokens); Tokenize(line, tokens);
if(2 == tokens.size() ) if(2 == tokens.size() )
parameters.Add(tokens[0], tokens[1]); parameters.insert(std::make_pair(tokens[0], tokens[1]));
} }
config.close(); config.close();
} }
} }
std::string GetParameter(const char * key){ std::string GetParameter(const std::string & key){
return GetParameter(std::string(key));
}
std::string GetParameter(std::string key) {
return parameters.Find(key); return parameters.Find(key);
} }
@ -62,8 +60,8 @@ public:
SetParameter(std::string(key), std::string(value)); SetParameter(std::string(key), std::string(value));
} }
void SetParameter(std::string key, std::string value) { void SetParameter(const std::string key, std::string value) {
parameters.Set(key, value); parameters[key] = value;
} }
private: private:
@ -77,32 +75,13 @@ private:
while (std::string::npos != pos || std::string::npos != lastPos) { while (std::string::npos != pos || std::string::npos != lastPos) {
std::string temp = str.substr(lastPos, pos - lastPos); std::string temp = str.substr(lastPos, pos - lastPos);
TrimStringRight(temp); boost::trim(temp);
TrimStringLeft(temp);
tokens.push_back( temp ); tokens.push_back( temp );
lastPos = str.find_first_not_of(delimiters, pos); lastPos = str.find_first_not_of(delimiters, pos);
pos = str.find_first_of(delimiters, lastPos); pos = str.find_first_of(delimiters, lastPos);
} }
} }
void TrimStringRight(std::string& str) {
std::string::size_type pos = str.find_last_not_of(" ");
if (pos != std::string::npos) {
str.erase(pos+1);
} else {
str.erase( str.begin() , str.end() );
}
}
void TrimStringLeft(std::string& str) {
std::string::size_type pos = str.find_first_not_of(" ");
if (pos != std::string::npos) {
str.erase(0, pos);
} else {
str.erase( str.begin() , str.end() );
}
}
HashTable<std::string, std::string> parameters; HashTable<std::string, std::string> parameters;
}; };