Changeset 10220 for trunk/FACT++/src/Configuration.cc
- Timestamp:
- 03/03/11 19:28:48 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Configuration.cc
r10198 r10220 166 166 If the second option is false, the options will not be displayed in any 167 167 \b --help directive, but are available to the user. Each of the functions 168 can be called more than once. 168 can be called more than once. If an option should be available from 169 all kind of inputs AddOptions() can be used which will call all 170 four other AddOptions() functions. 169 171 170 172 A special case are the options from environment variables. Since you might 171 want to use the same option-key for the command-line and the environment 173 want to use the same option-key for the command-line and the environment, 172 174 a mapping is needed (e.g. from \b PATH to \b --path). This mapping 173 can be implemented by a mapping function and be initialized like this: 175 can be implemented by a mapping function or by the build in mapping 176 and be initialized like this: 174 177 175 178 \code 176 179 177 const string name_mapper(const string &str) 180 conf.AddEnv("path", "PATH"); 181 182 \endcode 183 184 or 185 186 \code 187 188 const string name_mapper(const string str) 178 189 { 179 190 return str=="PATH" ? "path" : ""; … … 421 432 //! 422 433 // 423 Configuration::Configuration(const string &prgname) : fName(prgname), fNameMapper(&NameMapper) 434 Configuration::Configuration(const string &prgname) : fName(prgname), 435 fNameMapper(bind1st(mem_fun(&Configuration::DefaultMapper), this)) 424 436 { 425 437 po::options_description generic("Generic options"); … … 665 677 //! 666 678 // 667 void Configuration::SetNameMapper(const string (*mapper)(const string&)) 668 { 669 fNameMapper = mapper; 679 void Configuration::SetNameMapper(const boost::function1<std::string, std::string> &func) 680 { 681 fNameMapper = func; 682 } 683 684 void Configuration::SetNameMapper() 685 { 686 fNameMapper = bind1st(mem_fun(&Configuration::DefaultMapper), this); 670 687 } 671 688 … … 902 919 // ------------------------ (11) ------------------------- 903 920 904 const po::parsed_options parsed_environment = po::parse_environment(opt_environment, *fNameMapper);921 const po::parsed_options parsed_environment = po::parse_environment(opt_environment, fNameMapper); 905 922 906 923 // ------------------------ (12) -------------------------
Note:
See TracChangeset
for help on using the changeset viewer.