osrm-backend/include/util/ini_file.hpp

29 lines
753 B
C++
Raw Normal View History

2015-01-27 11:44:46 -05:00
#ifndef INI_FILE_HPP
#define INI_FILE_HPP
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <algorithm>
#include <string>
2016-01-05 10:51:13 -05:00
namespace osrm
{
namespace util
{
2015-01-27 11:44:46 -05:00
// 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)
2015-01-27 11:44:46 -05:00
{
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;
}
}
2016-01-05 10:51:13 -05:00
}
2015-01-27 11:44:46 -05:00
#endif // INI_FILE_HPP