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 "git_sha.hpp"
|
||||
#include "IniFileUtil.h"
|
||||
#include "ini_file.hpp"
|
||||
#include "osrm_exception.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
|
||||
boost::program_options::options_description generic_options("Options");
|
||||
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")
|
||||
("springclean,s", "Remove all regions in shared memory")("config,c",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["config"])
|
||||
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")(
|
||||
"springclean,s", "Remove all regions in shared memory")(
|
||||
"config,c", boost::program_options::value<boost::filesystem::path>(&paths["config"])
|
||||
->default_value("server.ini"),
|
||||
"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
|
||||
boost::program_options::options_description config_options("Configuration");
|
||||
config_options.add_options()(
|
||||
"hsgrdata",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["hsgrdata"]),
|
||||
"hsgrdata", boost::program_options::value<boost::filesystem::path>(&paths["hsgrdata"]),
|
||||
".hsgr file")("nodesdata",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["nodesdata"]),
|
||||
".nodes file")(
|
||||
"edgesdata",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["edgesdata"]),
|
||||
"edgesdata", boost::program_options::value<boost::filesystem::path>(&paths["edgesdata"]),
|
||||
".edges file")("geometry",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["geometry"]),
|
||||
".geometry file")(
|
||||
"ramindex",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["ramindex"]),
|
||||
"ramindex", boost::program_options::value<boost::filesystem::path>(&paths["ramindex"]),
|
||||
".ramIndex file")(
|
||||
"fileindex",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["fileindex"]),
|
||||
"fileindex", boost::program_options::value<boost::filesystem::path>(&paths["fileindex"]),
|
||||
".fileIndex file")(
|
||||
"namesdata",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["namesdata"]),
|
||||
"namesdata", boost::program_options::value<boost::filesystem::path>(&paths["namesdata"]),
|
||||
".names file")("timestamp",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["timestamp"]),
|
||||
".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
|
||||
boost::program_options::options_description hidden_options("Hidden options");
|
||||
hidden_options.add_options()(
|
||||
"base,b",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["base"]),
|
||||
"base,b", boost::program_options::value<boost::filesystem::path>(&paths["base"]),
|
||||
"base path to .osrm file");
|
||||
|
||||
// positional option
|
||||
@ -157,7 +151,7 @@ bool GenerateDataStoreOptions(const int argc, const char *argv[], ServerPaths &p
|
||||
!option_variables.count("base"))
|
||||
{
|
||||
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);
|
||||
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
||||
option_variables);
|
||||
|
@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define PROGAM_OPTIONS_H
|
||||
|
||||
#include "git_sha.hpp"
|
||||
#include "IniFileUtil.h"
|
||||
#include "ini_file.hpp"
|
||||
#include "osrm_exception.hpp"
|
||||
#include "simple_logger.hpp"
|
||||
|
||||
@ -244,7 +244,7 @@ inline unsigned GenerateServerProgramOptions(const int argc,
|
||||
!option_variables.count("base"))
|
||||
{
|
||||
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);
|
||||
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
||||
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.
|
||||
|
||||
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
|
||||
#define INI_FILE_UTIL_H
|
||||
#ifndef INI_FILE_HPP
|
||||
#define INI_FILE_HPP
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <regex>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// 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);
|
||||
std::string ini_file_content((std::istreambuf_iterator<char>(config_stream)),
|
||||
std::istreambuf_iterator<char>());
|
||||
boost::regex regex( "^([^=]*)" ); //match from start of line to '='
|
||||
std::string format( "\\L$1\\E" ); //replace with downcased substring
|
||||
return boost::regex_replace( ini_file_content, regex, format );
|
||||
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_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 "../Util/git_sha.hpp"
|
||||
#include "../Util/IniFileUtil.h"
|
||||
#include "../Util/make_unique.hpp"
|
||||
#include "../Util/simple_logger.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 <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
#include <tbb/parallel_for.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 "../Util/git_sha.hpp"
|
||||
#include "../Util/IniFileUtil.h"
|
||||
#include "../Util/ini_file.hpp"
|
||||
#include "../Util/simple_logger.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
@ -108,7 +108,7 @@ ExtractorOptions::ParseArguments(int argc, char *argv[], ExtractorConfig &extrac
|
||||
SimpleLogger().Write()
|
||||
<< "Reading options from: " << extractor_config.config_file_path.string();
|
||||
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);
|
||||
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
||||
option_variables);
|
||||
|
Loading…
Reference in New Issue
Block a user