953 cout <<
"--0--" << endl;
956 po::options_description opt_commandline;
957 po::options_description opt_configfile;
958 po::options_description opt_environment;
959 po::options_description opt_database;
961 for (
int i=0;
i<2;
i++)
971 cout <<
"--1--" << endl;
980 cout <<
"--2--" << endl;
983 po::command_line_parser parser(argc, const_cast<char**>(argv));
984 parser.options(opt_commandline);
985 parser.positional(opt_positional);
986 parser.style(style::unix_style&~style::allow_guessing);
989 const po::parsed_options parsed_commandline = parser.run();
993 cout <<
"--3--" << endl;
996 po::variables_map getfiles;
997 po::store(parsed_commandline, getfiles);
999 if (getfiles.count(
"version"))
1001 if (getfiles.count(
"help"))
1006 "The following describes the available commandline options. " 1007 "For further details on how command line option are parsed " 1008 "and in which order which configuration sources are accessed " 1009 "please refer to the class reference of the Configuration class." << endl;
1012 if (getfiles.count(
"help-config"))
1014 if (getfiles.count(
"help-env"))
1016 if (getfiles.count(
"help-database"))
1023 cout <<
"--4--" << endl;
1026 if (getfiles.count(
"print") || getfiles.count(
"print-all"))
1028 cout << endl <<
"Parsed commandline options:" << endl;
1033 if (getfiles.count(
"help") || getfiles.count(
"help-config") ||
1034 getfiles.count(
"help-env") || getfiles.count(
"help-database"))
1042 cout <<
"--5--" << endl;
1045 const boost::filesystem::path path(
GetName());
1046 const string globalfile = (path.parent_path()/boost::filesystem::path(
"fact++.rc")).
string();
1048 cerr <<
"Reading global options from '" << globalfile <<
"'." << endl;
1050 ifstream gfile(globalfile.c_str());
1052 const po::parsed_options parsed_globalfile =
1054 po::parsed_options(&opt_configfile) :
1055 po::parse_config_file<char>(gfile, opt_configfile, true);
1059 cout <<
"--6--" << endl;
1063 if (getfiles.count(
"default"))
1066 cerr <<
"Reading default options from '" <<
fDefaultFile <<
"'." << endl;
1069 const bool checkf = !getfiles.count(
"dont-check-files") && !getfiles.count(
"dont-check");
1070 const bool defaulted = getfiles.count(
"default") && getfiles[
"default"].defaulted();
1075 const po::parsed_options parsed_defaultfile =
1076 !indef && defaulted ?
1077 po::parsed_options(&opt_configfile) :
1078 po::parse_config_file<char>(indef, opt_configfile, !checkf);
1082 cout <<
"--7--" << endl;
1085 if (getfiles.count(
"print-default") || getfiles.count(
"print-all"))
1087 if (!indef.is_open() && defaulted)
1088 cout <<
"No configuration file by --default option specified." << endl;
1091 cout << endl <<
"Parsed options from '" <<
fDefaultFile <<
"':" << endl;
1097 po::store(parsed_defaultfile, getfiles);
1101 cout <<
"--8--" << endl;
1105 if (getfiles.count(
"config"))
1108 cerr <<
"Reading config options from '" <<
fPriorityFile <<
"'." << endl;
1113 const po::parsed_options parsed_priorityfile =
1114 fPriorityFile.empty() ? po::parsed_options(&opt_configfile) :
1115 po::parse_config_file<char>(inpri, opt_configfile, !checkf);
1119 cout <<
"--9--" << endl;
1122 if (getfiles.count(
"print-config") || getfiles.count(
"print-all"))
1125 cout <<
"No configuration file by --config option specified." << endl;
1128 cout << endl <<
"Parsed options from '" <<
fPriorityFile <<
"':" << endl;
1136 cout <<
"--10--" << endl;
1139 po::variables_map getdatabase;
1140 po::store(parsed_commandline, getdatabase);
1141 po::store(parsed_priorityfile, getdatabase);
1142 po::store(parsed_defaultfile, getdatabase);
1143 po::store(parsed_globalfile, getdatabase);
1145 if (getdatabase.count(
"database") && !getdatabase.count(
"no-database"))
1147 fDatabase = getdatabase[
"database"].as<
string>();
1148 cerr <<
"Requesting options from database for '" <<
fName <<
"'" << endl;
1151 const bool checkdb = !getdatabase.count(
"dont-check-database") && !getdatabase.count(
"dont-check");
1153 const po::parsed_options parsed_database =
1154 fDatabase.empty() ? po::parsed_options(&opt_database) :
1155 #
if BOOST_VERSION < 104600
1162 cout <<
"--11--" << endl;
1165 if (getfiles.count(
"print-database") || getfiles.count(
"print-all"))
1168 cout <<
"No database access requested." << endl;
1171 cout << endl <<
"Options received from '" <<
fDatabase <<
"':" << endl;
1179 cout <<
"--12--" << endl;
1182 const po::parsed_options parsed_environment = po::parse_environment(opt_environment,
fNameMapper);
1186 cout <<
"--13--" << endl;
1189 if (getfiles.count(
"print-environment"))
1191 cout <<
"Parsed options from environment:" << endl;
1198 cout <<
"--14--" << endl;
1201 po::variables_map result;
1202 po::store(parsed_commandline, result);
1203 po::store(parsed_priorityfile, result);
1204 po::store(parsed_database, result);
1205 po::store(parsed_defaultfile, result);
1206 po::store(parsed_globalfile, result);
1207 po::store(parsed_environment, result);
1214 cout <<
"--15--" << endl;
1217 const vector<string> unknown0 = collect_unrecognized(parsed_globalfile.options, po::exclude_positional);
1218 const vector<string> unknown1 = collect_unrecognized(parsed_defaultfile.options, po::exclude_positional);
1219 const vector<string> unknown2 = collect_unrecognized(parsed_priorityfile.options, po::exclude_positional);
1226 fUnknownCommandline = collect_unrecognized(parsed_commandline.options, po::exclude_positional);
1227 fUnknownEnvironment = collect_unrecognized(parsed_environment.options, po::exclude_positional);
1228 fUnknownDatabase = collect_unrecognized(parsed_database.options, po::exclude_positional);
1232 cout <<
"--16--" << endl;
1239 cout <<
"--17--" << endl;
1242 if (result.count(
"print-options"))
1245 if (result.count(
"print-wildcards"))
1248 if (result.count(
"print-unknown"))
1252 cout <<
"------" << endl;
void PrintWildcardOptions() const
std::string fDatabase
File name of the default configuration file (usually {program}.rc)
std::string fPriorityFile
Options which were registered using wildcards.
std::vector< std::string > fUnknownDatabase
Storage container for unrecognized options from the environment.
po::options_description fOptionsEnvironment[2]
Description of options from the database.
void CreateWildcardOptions()
Helper for Parse to create list of used wildcard options.
std::function< std::string(std::string)> fNameMapper
Pointer to the mapper function for environment variables.
Index for options visible in PrintParsed.
po::positional_options_description fArgumentPositions
Description of options from the environment.
po::options_description fOptionsDatabase[2]
Description of the options in the configuration file.
void PrintParsed(const po::parsed_options &parsed) const
Print all options from a list of already parsed options.
void PrintUnknown() const
void PrintOptions() const
std::string fDefaultFile
File name of the priority configuration file (overwrites option from the databse) ...
po::options_description fOptionsCommandline[2]
po::options_description fOptionsConfigfile[2]
Description of the command-line options.
std::vector< std::string > fUnknownCommandline
Description of positional command-line options (arguments)
std::function< void()> fPrintUsage
static po::basic_parsed_options< char > parse_database(const std::string &prgname, const std::string &database, const po::options_description &desc, bool allow_unregistered=false)
Retrieve data from a database and return them as options.
po::variables_map fVariables
URL for database connection (see Configuration::parse_database)
virtual void PrintVersion() const
std::vector< std::string > fUnknownConfigfile
Storage container for unrecognized commandline options.
std::vector< std::string > fUnknownEnvironment
Storage container for unrecognized options from configuration files.
const std::string & GetName() const