support capitalized option names in extract/prepare
This commit is contained in:
@@ -29,6 +29,7 @@ Custom validators for use with boost::program_options.
|
||||
#include <boost/any.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -57,4 +58,14 @@ namespace boost {
|
||||
}
|
||||
}
|
||||
|
||||
//support old capitalized option names by downcasing them with a regex replace
|
||||
//read from file and store in a stringstream that can be passed to boost::program_options
|
||||
inline void PrepareConfigFile(const boost::filesystem::path& path, std::string& output ) {
|
||||
std::ifstream config_stream(path.c_str());
|
||||
std::string input_str( (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
|
||||
output = boost::regex_replace( input_str, regex, format );
|
||||
}
|
||||
|
||||
#endif /* PROGRAM_OPTIONS_H */
|
||||
|
||||
Reference in New Issue
Block a user