osrm-backend/include/util/ini_file.hpp
Daniel J. Hofmann e20f92bbbb Anonymous namespaces in header files are bad
They duplicate the code across translation units.
2016-01-19 17:42:49 +01:00

29 lines
753 B
C++

#ifndef INI_FILE_HPP
#define INI_FILE_HPP
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <algorithm>
#include <string>
namespace osrm
{
namespace util
{
// support old capitalized option names by down-casing them with a regex replace
inline std::string read_file_lower_content(const boost::filesystem::path &path)
{
boost::filesystem::fstream config_stream(path);
std::string ini_file_content((std::istreambuf_iterator<char>(config_stream)),
std::istreambuf_iterator<char>());
std::transform(std::begin(ini_file_content), std::end(ini_file_content),
std::begin(ini_file_content), ::tolower);
return ini_file_content;
}
}
}
#endif // INI_FILE_HPP