00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #include "ProgramOptions.ih"
00027
00028
00029
00030 #define prefix_ inline
00031
00032
00033
00034
00035
00036 prefix_ senf::console::detail::ProgramOptionsSource::ptr
00037 senf::console::detail::ProgramOptionsSource::create(int argc, char const ** argv)
00038 {
00039 return ptr(new ProgramOptionsSource(argc,argv));
00040 }
00041
00042 prefix_ senf::console::detail::ProgramOptionsSource::ProgramOptionsSource(int argc,
00043 char const ** argv)
00044 : argc_ (argc), argv_ (argv)
00045 {}
00046
00047 prefix_ senf::console::detail::ProgramOptionsSource &
00048 senf::console::detail::ProgramOptionsSource::alias(char letter, std::string const & longOpt,
00049 bool withArg)
00050 {
00051 shortOptions_.insert(std::make_pair(letter, ShortOption(withArg, longOpt)));
00052 return *this;
00053 }
00054
00055
00056
00057
00058 prefix_ senf::console::detail::ProgramOptionsSource::ShortOption::
00059 ShortOption(bool withArg_, std::string const & longOpt_)
00060 : withArg (withArg_), longOpt (longOpt_)
00061 {}
00062
00063
00064
00065
00066 prefix_ senf::console::ProgramOptions::ProgramOptions(int argc, char const ** argv,
00067 DirectoryNode & root)
00068 : detail::BundleMixin (root), config_ (add(detail::ProgramOptionsSource::create(argc, argv)))
00069 {}
00070
00071 prefix_ senf::console::ProgramOptions &
00072 senf::console::ProgramOptions::alias(char letter, std::string const & longOpt, bool withArg)
00073 {
00074 config_.alias(letter, longOpt, withArg);
00075 return *this;
00076 }
00077
00078
00079
00080 prefix_ senf::console::detail::ProgramOptionsSource::ptr
00081 senf::console::OptionsConfig(int argc, char const ** argv)
00082 {
00083 return detail::ProgramOptionsSource::create(argc, argv);
00084 }
00085
00086
00087 #undef prefix_
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098