Changeset 10296 for trunk/FACT++/src
- Timestamp:
- 04/07/11 10:10:33 (14 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Configuration.cc
r10230 r10296 267 267 #include <iostream> 268 268 269 #include <boost/bind.hpp> 269 270 #include <boost/regex.hpp> 270 271 //#include <boost/filesystem.hpp> … … 442 443 ("help-database", "Print available options retreived from the database.") 443 444 ("help-config", "Print available configuration file options.") 445 ("version,V", "Print version information.") 444 446 ("print-all", "Print all options as parsed from all the different sources.") 445 447 ("print", "Print options as parsed from the commandline.") … … 678 680 //! 679 681 // 680 void Configuration::SetNameMapper(const boost::function 1<std::string, std::string> &func)682 void Configuration::SetNameMapper(const boost::function<std::string(std::string)> &func) 681 683 { 682 684 fNameMapper = func; … … 686 688 { 687 689 fNameMapper = bind1st(mem_fun(&Configuration::DefaultMapper), this); 690 } 691 692 void Configuration::SetPrintUsage(const boost::function<void(void)> &func) 693 { 694 fPrintUsage = func; 695 } 696 697 void Configuration::SetPrintUsage() 698 { 699 fPrintUsage = boost::bind(&Configuration::PrintUsage, this); 688 700 } 689 701 … … 803 815 804 816 if (getfiles.count("help")) 805 cout << endl << fOptionsCommandline[kVisible] << endl; 817 { 818 fPrintUsage(); 819 cout << fOptionsCommandline[kVisible] << endl; 820 } 806 821 if (getfiles.count("help-config")) 807 cout << endl <<fOptionsConfigfile[kVisible] << endl;822 cout << fOptionsConfigfile[kVisible] << endl; 808 823 if (getfiles.count("help-env")) 809 cout << endl <<fOptionsEnvironment[kVisible] << endl;824 cout << fOptionsEnvironment[kVisible] << endl; 810 825 if (getfiles.count("help-database")) 811 cout << endl <<fOptionsDatabase[kVisible] << endl;826 cout << fOptionsDatabase[kVisible] << endl; 812 827 813 828 // ------------------------ (4) -------------------------- … … 826 841 { 827 842 fDefaultFile = getfiles["default"].as<string>(); 828 c out<< "Reading configuration from '" << fDefaultFile << "'." << endl;843 cerr << "Reading configuration from '" << fDefaultFile << "'." << endl; 829 844 } 830 845 … … 862 877 { 863 878 fPriorityFile = getfiles["config"].as<string>(); 864 c out<< "Retrieved option from '" << fPriorityFile << "'." << endl;879 cerr << "Retrieved option from '" << fPriorityFile << "'." << endl; 865 880 } 866 881 … … 895 910 { 896 911 fDatabase = getdatabase["database"].as<string>(); 897 c out<< "Retrieving configuration from '" << fDatabase << "'." << endl;912 cerr << "Retrieving configuration from '" << fDatabase << "'." << endl; 898 913 } 899 914 -
trunk/FACT++/src/Configuration.h
r10220 r10296 45 45 46 46 /// Pointer to the mapper function for environment variables 47 boost::function1<std::string, std::string> fNameMapper; 47 boost::function<std::string(std::string)> fNameMapper; 48 boost::function<void()> fPrintUsage; 48 49 49 50 /// Helper function which return the max of the two arguments in the first argument … … 58 59 /// Print a list of all unkown options within the given vector 59 60 void PrintUnknown(std::vector<std::string> &vec, int steps=1); 61 62 virtual void PrintUsage() const { } 60 63 61 64 public: … … 81 84 void SetArgumentPositions(const po::positional_options_description &desc); 82 85 83 void SetNameMapper(const boost::function 1<std::string, std::string> &func);86 void SetNameMapper(const boost::function<std::string(std::string)> &func); 84 87 void SetNameMapper(); 88 89 void SetPrintUsage(const boost::function<void(void)> &func); 90 void SetPrintUsage(); 85 91 86 92 void AddEnv(const std::string &conf, const std::string &env) … … 95 101 // Process command line arguments 96 102 const po::variables_map &Parse(int argc, char **argv); 103 104 bool HasVersion() const 105 { 106 return Has("version"); 107 } 97 108 98 109 bool HasHelp() const
Note:
See TracChangeset
for help on using the changeset viewer.