- Timestamp:
- 03/07/12 18:47:04 (13 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Configuration.cc
r12826 r13005 989 989 //! - proper handling and error messages if files not available 990 990 // 991 const po::variables_map &Configuration::Parse(int argc, const char **argv )991 const po::variables_map &Configuration::Parse(int argc, const char **argv, const std::function<void()> &PrintHelp) 992 992 { 993 993 const po::positional_options_description &opt_positional = fArgumentPositions; 994 994 995 995 // ------------------------ (0) -------------------------- 996 #ifdef DEBUG 997 cout << "--0--" << endl; 998 #endif 996 999 997 1000 po::options_description opt_commandline; … … 1009 1012 1010 1013 // ------------------------ (1) -------------------------- 1014 #ifdef DEBUG 1015 cout << "--1--" << endl; 1016 #endif 1011 1017 1012 1018 fPriorityFile = ""; … … 1015 1021 1016 1022 // ------------------------ (2) -------------------------- 1023 #ifdef DEBUG 1024 cout << "--2--" << endl; 1025 #endif 1017 1026 1018 1027 po::command_line_parser parser(argc, const_cast<char**>(argv)); … … 1025 1034 1026 1035 // ------------------------ (3) -------------------------- 1036 #ifdef DEBUG 1037 cout << "--3--" << endl; 1038 #endif 1027 1039 1028 1040 po::variables_map getfiles; … … 1049 1061 cout << fOptionsDatabase[kVisible] << endl; 1050 1062 1063 1064 1051 1065 // ------------------------ (4) -------------------------- 1066 #ifdef DEBUG 1067 cout << "--4--" << endl; 1068 #endif 1052 1069 1053 1070 if (getfiles.count("print") || getfiles.count("print-all")) … … 1058 1075 } 1059 1076 1077 if (getfiles.count("help") || getfiles.count("help-config") || 1078 getfiles.count("help-env") || getfiles.count("help-database")) 1079 { 1080 if (PrintHelp) 1081 PrintHelp(); 1082 } 1083 1060 1084 // ------------------------ (5) -------------------------- 1085 #ifdef DEBUG 1086 cout << "--5--" << endl; 1087 #endif 1061 1088 1062 1089 const boost::filesystem::path path(GetName()); … … 1073 1100 1074 1101 // ------------------------ (6) -------------------------- 1102 #ifdef DEBUG 1103 cout << "--6--" << endl; 1104 #endif 1075 1105 1076 1106 // Get default file from command line … … 1093 1123 1094 1124 // ------------------------ (7) -------------------------- 1125 #ifdef DEBUG 1126 cout << "--7--" << endl; 1127 #endif 1095 1128 1096 1129 if (getfiles.count("print-default") || getfiles.count("print-all")) … … 1109 1142 1110 1143 // ------------------------ (8) -------------------------- 1144 #ifdef DEBUG 1145 cout << "--8--" << endl; 1146 #endif 1111 1147 1112 1148 // Get priority from commandline(1), defaultfile(2) … … 1124 1160 1125 1161 // ------------------------ (9) -------------------------- 1162 #ifdef DEBUG 1163 cout << "--9--" << endl; 1164 #endif 1126 1165 1127 1166 if (getfiles.count("print-config") || getfiles.count("print-all")) … … 1138 1177 1139 1178 // ------------------------ (10) ------------------------- 1179 #ifdef DEBUG 1180 cout << "--10--" << endl; 1181 #endif 1140 1182 1141 1183 po::variables_map getdatabase; … … 1161 1203 #endif 1162 1204 // ------------------------ (11) ------------------------- 1205 #ifdef DEBUG 1206 cout << "--11--" << endl; 1207 #endif 1163 1208 1164 1209 if (getfiles.count("print-database") || getfiles.count("print-all")) … … 1175 1220 1176 1221 // ------------------------ (12) ------------------------- 1222 #ifdef DEBUG 1223 cout << "--12--" << endl; 1224 #endif 1177 1225 1178 1226 const po::parsed_options parsed_environment = po::parse_environment(opt_environment, fNameMapper); 1179 1227 1180 1228 // ------------------------ (13) ------------------------- 1229 #ifdef DEBUG 1230 cout << "--13--" << endl; 1231 #endif 1181 1232 1182 1233 if (getfiles.count("print-environment")) … … 1188 1239 1189 1240 // ------------------------ (14) ------------------------- 1241 #ifdef DEBUG 1242 cout << "--14--" << endl; 1243 #endif 1244 1190 1245 po::variables_map result; 1191 1246 po::store(parsed_commandline, result); … … 1200 1255 1201 1256 // ------------------------ (15) ------------------------- 1257 #ifdef DEBUG 1258 cout << "--15--" << endl; 1259 #endif 1202 1260 1203 1261 const vector<string> unknown0 = collect_unrecognized(parsed_globalfile.options, po::exclude_positional); … … 1215 1273 1216 1274 // ------------------------ (16) ------------------------- 1275 #ifdef DEBUG 1276 cout << "--16--" << endl; 1277 #endif 1217 1278 1218 1279 CreateWildcardOptions(); 1219 1280 1220 1281 // ------------------------ (17) ------------------------- 1282 #ifdef DEBUG 1283 cout << "--17--" << endl; 1284 #endif 1221 1285 1222 1286 if (result.count("print-options")) … … 1229 1293 PrintUnknown(); 1230 1294 1295 #ifdef DEBUG 1296 cout << "------" << endl; 1297 #endif 1298 1231 1299 return fVariables; 1232 1300 } … … 1236 1304 try 1237 1305 { 1238 Parse(argc, argv );1306 Parse(argc, argv, PrintHelp); 1239 1307 } 1240 1308 #if BOOST_VERSION > 104000 … … 1251 1319 } 1252 1320 1253 if (HasVersion() || HasPrint()) 1254 return false; 1255 1256 if (HasHelp()) 1257 { 1258 if (PrintHelp) 1259 PrintHelp(); 1260 return false; 1261 } 1262 1263 return true; 1321 return !HasVersion() && !HasPrint() && !HasHelp(); 1264 1322 } 1265 1323 -
trunk/FACT++/src/Configuration.h
r12315 r13005 124 124 125 125 // Process command line arguments 126 const po::variables_map &Parse(int argc, const char **argv );126 const po::variables_map &Parse(int argc, const char **argv, const std::function<void()> &func=std::function<void()>()); 127 127 bool DoParse(int argc, const char **argv, const std::function<void()> &func=std::function<void()>()); 128 128
Note:
See TracChangeset
for help on using the changeset viewer.