Changeset 10796 for trunk/FACT++
- Timestamp:
- 05/24/11 17:36:00 (14 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Configuration.cc
r10707 r10796 290 290 #include <boost/bind.hpp> 291 291 #include <boost/regex.hpp> 292 //#include <boost/filesystem.hpp>292 #include <boost/filesystem.hpp> 293 293 #include <boost/program_options.hpp> 294 294 … … 473 473 po::options_description generic("Generic options"); 474 474 generic.add_options() 475 ("version,V", "Print version information.") 475 476 ("help", "Print available commandline options.") 476 477 ("help-environment", "Print available environment variables.") 477 478 ("help-database", "Print available options retreived from the database.") 478 479 ("help-config", "Print available configuration file options.") 479 ("version,V", "Print version information.")480 480 ("print-all", "Print all options as parsed from all the different sources.") 481 481 ("print", "Print options as parsed from the commandline.") … … 732 732 { 733 733 fPrintUsage = boost::bind(&Configuration::PrintUsage, this); 734 } 735 736 void Configuration::SetPrintVersion(const boost::function<void(const string&)> &func) 737 { 738 fPrintVersion = func; 739 } 740 741 void Configuration::SetPrintVersion() 742 { 743 fPrintVersion = boost::function<void(const string&)>(); 734 744 } 735 745 … … 848 858 po::store(parsed_commandline, getfiles); 849 859 860 if (getfiles.count("version")) 861 PrintVersion(); 850 862 if (getfiles.count("help")) 851 863 { … … 987 999 988 1000 // ------------------------ (13) ------------------------- 989 990 1001 po::variables_map result; 991 1002 po::store(parsed_commandline, result); … … 1021 1032 return fVariables; 1022 1033 } 1034 1035 // -------------------------------------------------------------------------- 1036 // 1037 //! Print version information about the program and package. 1038 //! 1039 //! The program name is taken from fName. If a leading "lt-" is found, 1040 //! it is removed. This is useful if the program was build and run 1041 //! using libtool. 1042 //! 1043 //! The package name is taken from the define PACKAGE_STRING. If it is 1044 //! not defined (like automatically done by autoconf) no package information 1045 //! is printed. The same is true for PACKAGE_URL and PACKAGE_BUGREPORT. 1046 //! 1047 //! From help2man: 1048 //! 1049 //! The first line of the --version information is assumed to be in one 1050 //! of the following formats: 1051 //! 1052 //! \verbatim 1053 //! - <version> 1054 //! - <program> <version> 1055 //! - {GNU,Free} <program> <version> 1056 //! - <program> ({GNU,Free} <package>) <version> 1057 //! - <program> - {GNU,Free} <package> <version> 1058 //! \endverbatim 1059 //! 1060 //! and separated from any copyright/author details by a blank line. 1061 //! 1062 //! Handle multi-line bug reporting sections of the form: 1063 //! 1064 //! \verbatim 1065 //! - Report <program> bugs to <addr> 1066 //! - GNU <package> home page: <url> 1067 //! - ... 1068 //! \endverbatim 1069 //! 1070 //! @param name 1071 //! name of the program (usually argv[0]). A possible leading "lt-" 1072 //! is removed. 1073 //! 1074 void Configuration::PrintVersion() const 1075 { 1076 #ifndef PACKAGE_STRING 1077 #define PACKAGE_STRING "" 1078 #endif 1079 1080 #ifndef PACKAGE_URL 1081 #define PACKAGE_URL "" 1082 #endif 1083 1084 #ifndef PACKAGE_BUGREPORT 1085 #define PACKAGE_BUGREPORT "" 1086 #endif 1087 1088 if (!fPrintVersion.empty()) 1089 { 1090 fPrintVersion(fName); 1091 return; 1092 } 1093 1094 std::string n = boost::filesystem::basename(fName); 1095 if (n.substr(0, 3)=="lt-") 1096 n = n.substr(3); 1097 1098 const string name = PACKAGE_STRING; 1099 const string bugs = PACKAGE_BUGREPORT; 1100 const string url = PACKAGE_URL; 1101 1102 cout << n; 1103 if (!name.empty()) 1104 cout << " - " << name; 1105 cout << 1106 "\n\n" 1107 "Written by Thomas Bretz et al.\n" 1108 "\n"; 1109 if (!bugs.empty()) 1110 cout << "Report bugs to <" << bugs << ">\n"; 1111 if (!url.empty()) 1112 cout << "Home page: " << url << "\n"; 1113 cout << 1114 "\n" 1115 "Copyright (C) 2011 by the FACT Collaboration.\n" 1116 "This is free software; see the source for copying conditions.\n" 1117 << std::endl; 1118 } -
trunk/FACT++/src/Configuration.h
r10707 r10796 47 47 boost::function<std::string(std::string)> fNameMapper; 48 48 boost::function<void()> fPrintUsage; 49 boost::function<void(const std::string&)> fPrintVersion; 49 50 50 51 /// Helper function which return the max of the two arguments in the first argument … … 61 62 62 63 virtual void PrintUsage() const { } 64 virtual void PrintVersion() const; 63 65 64 66 public: … … 89 91 void SetPrintUsage(const boost::function<void(void)> &func); 90 92 void SetPrintUsage(); 93 94 void SetPrintVersion(const boost::function<void(const std::string &)> &func); 95 void SetPrintVersion(); 91 96 92 97 void AddEnv(const std::string &conf, const std::string &env)
Note:
See TracChangeset
for help on using the changeset viewer.