renamed: Util/IniFileUtil.h -> Util/ini_file.hpp
This commit is contained in:
parent
1187f83ffd
commit
c8041bacd6
@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include "BoostFileSystemFix.h"
|
#include "BoostFileSystemFix.h"
|
||||||
#include "git_sha.hpp"
|
#include "git_sha.hpp"
|
||||||
#include "IniFileUtil.h"
|
#include "ini_file.hpp"
|
||||||
#include "osrm_exception.hpp"
|
#include "osrm_exception.hpp"
|
||||||
#include "simple_logger.hpp"
|
#include "simple_logger.hpp"
|
||||||
|
|
||||||
@ -47,9 +47,9 @@ bool GenerateDataStoreOptions(const int argc, const char *argv[], ServerPaths &p
|
|||||||
{
|
{
|
||||||
// declare a group of options that will be allowed only on command line
|
// declare a group of options that will be allowed only on command line
|
||||||
boost::program_options::options_description generic_options("Options");
|
boost::program_options::options_description generic_options("Options");
|
||||||
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")
|
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")(
|
||||||
("springclean,s", "Remove all regions in shared memory")("config,c",
|
"springclean,s", "Remove all regions in shared memory")(
|
||||||
boost::program_options::value<boost::filesystem::path>(&paths["config"])
|
"config,c", boost::program_options::value<boost::filesystem::path>(&paths["config"])
|
||||||
->default_value("server.ini"),
|
->default_value("server.ini"),
|
||||||
"Path to a configuration file");
|
"Path to a configuration file");
|
||||||
|
|
||||||
@ -57,24 +57,19 @@ bool GenerateDataStoreOptions(const int argc, const char *argv[], ServerPaths &p
|
|||||||
// as well as in a config file
|
// as well as in a config file
|
||||||
boost::program_options::options_description config_options("Configuration");
|
boost::program_options::options_description config_options("Configuration");
|
||||||
config_options.add_options()(
|
config_options.add_options()(
|
||||||
"hsgrdata",
|
"hsgrdata", boost::program_options::value<boost::filesystem::path>(&paths["hsgrdata"]),
|
||||||
boost::program_options::value<boost::filesystem::path>(&paths["hsgrdata"]),
|
|
||||||
".hsgr file")("nodesdata",
|
".hsgr file")("nodesdata",
|
||||||
boost::program_options::value<boost::filesystem::path>(&paths["nodesdata"]),
|
boost::program_options::value<boost::filesystem::path>(&paths["nodesdata"]),
|
||||||
".nodes file")(
|
".nodes file")(
|
||||||
"edgesdata",
|
"edgesdata", boost::program_options::value<boost::filesystem::path>(&paths["edgesdata"]),
|
||||||
boost::program_options::value<boost::filesystem::path>(&paths["edgesdata"]),
|
|
||||||
".edges file")("geometry",
|
".edges file")("geometry",
|
||||||
boost::program_options::value<boost::filesystem::path>(&paths["geometry"]),
|
boost::program_options::value<boost::filesystem::path>(&paths["geometry"]),
|
||||||
".geometry file")(
|
".geometry file")(
|
||||||
"ramindex",
|
"ramindex", boost::program_options::value<boost::filesystem::path>(&paths["ramindex"]),
|
||||||
boost::program_options::value<boost::filesystem::path>(&paths["ramindex"]),
|
|
||||||
".ramIndex file")(
|
".ramIndex file")(
|
||||||
"fileindex",
|
"fileindex", boost::program_options::value<boost::filesystem::path>(&paths["fileindex"]),
|
||||||
boost::program_options::value<boost::filesystem::path>(&paths["fileindex"]),
|
|
||||||
".fileIndex file")(
|
".fileIndex file")(
|
||||||
"namesdata",
|
"namesdata", boost::program_options::value<boost::filesystem::path>(&paths["namesdata"]),
|
||||||
boost::program_options::value<boost::filesystem::path>(&paths["namesdata"]),
|
|
||||||
".names file")("timestamp",
|
".names file")("timestamp",
|
||||||
boost::program_options::value<boost::filesystem::path>(&paths["timestamp"]),
|
boost::program_options::value<boost::filesystem::path>(&paths["timestamp"]),
|
||||||
".timestamp file");
|
".timestamp file");
|
||||||
@ -83,8 +78,7 @@ bool GenerateDataStoreOptions(const int argc, const char *argv[], ServerPaths &p
|
|||||||
// file, but will not be shown to the user
|
// file, but will not be shown to the user
|
||||||
boost::program_options::options_description hidden_options("Hidden options");
|
boost::program_options::options_description hidden_options("Hidden options");
|
||||||
hidden_options.add_options()(
|
hidden_options.add_options()(
|
||||||
"base,b",
|
"base,b", boost::program_options::value<boost::filesystem::path>(&paths["base"]),
|
||||||
boost::program_options::value<boost::filesystem::path>(&paths["base"]),
|
|
||||||
"base path to .osrm file");
|
"base path to .osrm file");
|
||||||
|
|
||||||
// positional option
|
// positional option
|
||||||
@ -157,7 +151,7 @@ bool GenerateDataStoreOptions(const int argc, const char *argv[], ServerPaths &p
|
|||||||
!option_variables.count("base"))
|
!option_variables.count("base"))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write() << "Reading options from: " << path_iterator->second.string();
|
SimpleLogger().Write() << "Reading options from: " << path_iterator->second.string();
|
||||||
std::string ini_file_contents = ReadIniFileAndLowerContents(path_iterator->second);
|
std::string ini_file_contents = read_file_lower_content(path_iterator->second);
|
||||||
std::stringstream config_stream(ini_file_contents);
|
std::stringstream config_stream(ini_file_contents);
|
||||||
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
||||||
option_variables);
|
option_variables);
|
||||||
|
@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#define PROGAM_OPTIONS_H
|
#define PROGAM_OPTIONS_H
|
||||||
|
|
||||||
#include "git_sha.hpp"
|
#include "git_sha.hpp"
|
||||||
#include "IniFileUtil.h"
|
#include "ini_file.hpp"
|
||||||
#include "osrm_exception.hpp"
|
#include "osrm_exception.hpp"
|
||||||
#include "simple_logger.hpp"
|
#include "simple_logger.hpp"
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ inline unsigned GenerateServerProgramOptions(const int argc,
|
|||||||
!option_variables.count("base"))
|
!option_variables.count("base"))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write() << "Reading options from: " << path_iterator->second.string();
|
SimpleLogger().Write() << "Reading options from: " << path_iterator->second.string();
|
||||||
std::string ini_file_contents = ReadIniFileAndLowerContents(path_iterator->second);
|
std::string ini_file_contents = read_file_lower_content(path_iterator->second);
|
||||||
std::stringstream config_stream(ini_file_contents);
|
std::stringstream config_stream(ini_file_contents);
|
||||||
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
||||||
option_variables);
|
option_variables);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright (c) 2013, Project OSRM, Dennis Luxen, others
|
Copyright (c) 2015, Project OSRM, Dennis Luxen, others
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
@ -25,25 +25,27 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef INI_FILE_UTIL_H
|
#ifndef INI_FILE_HPP
|
||||||
#define INI_FILE_UTIL_H
|
#define INI_FILE_HPP
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
#include <boost/regex.hpp>
|
|
||||||
|
|
||||||
#include <regex>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
// support old capitalized option names by down-casing them with a regex replace
|
// support old capitalized option names by down-casing them with a regex replace
|
||||||
inline std::string ReadIniFileAndLowerContents(const boost::filesystem::path &path)
|
std::string read_file_lower_content(const boost::filesystem::path &path)
|
||||||
{
|
{
|
||||||
boost::filesystem::fstream config_stream(path);
|
boost::filesystem::fstream config_stream(path);
|
||||||
std::string ini_file_content((std::istreambuf_iterator<char>(config_stream)),
|
std::string ini_file_content((std::istreambuf_iterator<char>(config_stream)),
|
||||||
std::istreambuf_iterator<char>());
|
std::istreambuf_iterator<char>());
|
||||||
boost::regex regex( "^([^=]*)" ); //match from start of line to '='
|
std::transform(std::begin(ini_file_content), std::end(ini_file_content),
|
||||||
std::string format( "\\L$1\\E" ); //replace with downcased substring
|
std::begin(ini_file_content), ::tolower);
|
||||||
return boost::regex_replace( ini_file_content, regex, format );
|
return ini_file_content;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif // INI_FILE_UTIL_H
|
#endif // INI_FILE_HPP
|
@ -35,7 +35,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "scripting_environment.hpp"
|
#include "scripting_environment.hpp"
|
||||||
|
|
||||||
#include "../Util/git_sha.hpp"
|
#include "../Util/git_sha.hpp"
|
||||||
#include "../Util/IniFileUtil.h"
|
|
||||||
#include "../Util/make_unique.hpp"
|
#include "../Util/make_unique.hpp"
|
||||||
#include "../Util/simple_logger.hpp"
|
#include "../Util/simple_logger.hpp"
|
||||||
#include "../Util/timing_util.hpp"
|
#include "../Util/timing_util.hpp"
|
||||||
@ -46,6 +45,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <osmium/io/any_input.hpp>
|
#include <osmium/io/any_input.hpp>
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
#include <tbb/task_scheduler_init.h>
|
#include <tbb/task_scheduler_init.h>
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "extractor_options.hpp"
|
#include "extractor_options.hpp"
|
||||||
|
|
||||||
#include "../Util/git_sha.hpp"
|
#include "../Util/git_sha.hpp"
|
||||||
#include "../Util/IniFileUtil.h"
|
#include "../Util/ini_file.hpp"
|
||||||
#include "../Util/simple_logger.hpp"
|
#include "../Util/simple_logger.hpp"
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
@ -108,7 +108,7 @@ ExtractorOptions::ParseArguments(int argc, char *argv[], ExtractorConfig &extrac
|
|||||||
SimpleLogger().Write()
|
SimpleLogger().Write()
|
||||||
<< "Reading options from: " << extractor_config.config_file_path.string();
|
<< "Reading options from: " << extractor_config.config_file_path.string();
|
||||||
std::string ini_file_contents =
|
std::string ini_file_contents =
|
||||||
ReadIniFileAndLowerContents(extractor_config.config_file_path);
|
read_file_lower_content(extractor_config.config_file_path);
|
||||||
std::stringstream config_stream(ini_file_contents);
|
std::stringstream config_stream(ini_file_contents);
|
||||||
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
||||||
option_variables);
|
option_variables);
|
||||||
|
Loading…
Reference in New Issue
Block a user