Changeset 11483 for trunk/FACT++/src/Configuration.cc
- Timestamp:
- 07/20/11 10:27:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Configuration.cc
r11481 r11483 528 528 ("print-unknown", "Print unrecognized options.") 529 529 ("print-options", "Print options as passed to program.") 530 ("print-wildcards", "Print all options registered with wildcards.") 530 531 ("dont-check", "Do not check validity of options from files and database.") 531 532 ("dont-check-files", "Do not check validity of options from files.") … … 591 592 //for (int j=0; j<options[i].value.size(); j++) 592 593 // cout << "\t = " << options[i].value[j]; 593 594 //cout << "/" << options[i].position_key;595 594 //cout << "/" << options[i].original_tokens[0]; 596 //cout << "/" << options[i].unregistered << endl; 595 596 ostringstream com; 597 598 if (opt.position_key>=0) 599 com << " [position=" << opt.position_key << "]"; 597 600 if (opt.unregistered) 598 cout << " # option unknown"; 601 com << " [unregistered]"; 602 603 if (!com.str().empty()) 604 cout << " # " << com.str(); 605 599 606 cout << endl; 600 607 } … … 963 970 //! options from the default configuration-file and options 964 971 //! from the environment. 965 //! - (15) Fin allyall options which were found and flagged as unrecognized,972 //! - (15) Find all options which were found and flagged as unrecognized, 966 973 //! because they are not in the user-defined list of described 967 974 //! options, are collected and stored in the corresponding 968 975 //! data-members. 969 //! - (16) Before the function returns it check for \b --print-options 976 //! - (16) Find all options which where registered with wildcards and 977 //! store the list in fWildcardOptions. 978 //! - (17) Before the function returns it check for \b --print-options 970 979 //! and \b --print-unknown and performs the corresponding actions. 971 980 //! … … 1058 1067 const string globalfile = path.parent_path().string()+"/fact++.rc"; 1059 1068 1060 cerr << "Reading options from '" << globalfile << "'." << endl;1069 cerr << "Reading global options from '" << globalfile << "'." << endl; 1061 1070 1062 1071 ifstream gfile(globalfile.c_str()); … … 1073 1082 { 1074 1083 fDefaultFile = getfiles["default"].as<string>(); 1075 cerr << "Reading options from '" << fDefaultFile << "'." << endl;1084 cerr << "Reading default options from '" << fDefaultFile << "'." << endl; 1076 1085 } 1077 1086 … … 1109 1118 { 1110 1119 fPriorityFile = getfiles["config"].as<string>(); 1111 cerr << "Reading options from '" << fPriorityFile << "'." << endl;1120 cerr << "Reading config options from '" << fPriorityFile << "'." << endl; 1112 1121 } 1113 1122 … … 1208 1217 // ------------------------ (16) ------------------------- 1209 1218 1219 CreateWildcardOptions(); 1220 1221 // ------------------------ (17) ------------------------- 1222 1210 1223 if (result.count("print-options")) 1211 1224 PrintOptions(); 1212 1225 1226 if (result.count("print-wildcards")) 1227 PrintWildcardOptions(); 1228 1213 1229 if (result.count("print-unknown")) 1214 1230 PrintUnknown(); 1215 1231 1216 1232 return fVariables; 1233 } 1234 1235 // -------------------------------------------------------------------------- 1236 // 1237 //! Create a list of all options which were registered using wildcards 1238 //! 1239 void Configuration::CreateWildcardOptions() 1240 { 1241 po::options_description opts; 1242 1243 for (int i=0; i<2; i++) 1244 { 1245 opts.add(fOptionsCommandline[i]); 1246 opts.add(fOptionsConfigfile[i]); 1247 opts.add(fOptionsEnvironment[i]); 1248 opts.add(fOptionsDatabase[i]); 1249 } 1250 1251 fWildcardOptions.clear(); 1252 1253 typedef map<string,po::variable_value> Vars; 1254 typedef vector<boost::shared_ptr<po::option_description>> Descs; 1255 1256 const Descs &desc = opts.options(); 1257 1258 for (Vars::const_iterator io=fVariables.begin(); io!=fVariables.end(); io++) 1259 { 1260 for (Descs::const_iterator id=desc.begin(); id!=desc.end(); id++) 1261 if ((*id)->match(io->first, false, false, false)==po::option_description::approximate_match) 1262 fWildcardOptions[io->first] = (*id)->long_name(); 1263 } 1264 } 1265 1266 // -------------------------------------------------------------------------- 1267 // 1268 //! Print a list of all options which were registered using wildcards and 1269 //! have not be registered subsequently by access. 1270 //! 1271 void Configuration::PrintWildcardOptions() const 1272 { 1273 cout << "Options registered with wildcards and not yet accessed:" << endl; 1274 1275 size_t max = 0; 1276 for (map<string,string>::const_iterator it=fWildcardOptions.begin(); it!=fWildcardOptions.end(); it++) 1277 if (it->second.length()>max) 1278 max = it->second.length(); 1279 1280 cout.setf(ios_base::left); 1281 for (map<string,string>::const_iterator it=fWildcardOptions.begin(); it!=fWildcardOptions.end(); it++) 1282 cout << setw(max+1) << it->second << " : " << it->first <<endl; 1217 1283 } 1218 1284
Note:
See TracChangeset
for help on using the changeset viewer.