4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief ProgramOptions internal header */
26 #ifndef IH_SENF_Scheduler_Console_ProgramOptions_
27 #define IH_SENF_Scheduler_Console_ProgramOptions_ 1
30 #include <boost/scoped_ptr.hpp>
33 ///////////////////////////////ih.p////////////////////////////////////////
41 class ProgramOptionsSource : public ConfigSource
44 typedef boost::intrusive_ptr<ProgramOptionsSource> ptr;
46 static ptr create(int argc, char const ** argv);
48 template <class Container>
49 ProgramOptionsSource & nonOptions(Container & container);
50 ProgramOptionsSource & alias(char letter, std::string const & longOpt, bool withArg=false);
53 ProgramOptionsSource(int argc, char const ** argv);
55 virtual void v_parse(RestrictedExecutor & executor);
57 void parseLongOption(std::string const & arg, RestrictedExecutor & executor);
58 void parseNonOption(std::string const & arg, RestrictedExecutor & executor);
60 struct NonOptionContainer
62 virtual ~NonOptionContainer();
63 virtual void clear() = 0;
64 virtual void push_back(std::string const & value) = 0;
67 template <class Container>
68 struct NonOptionContainerImpl
69 : public NonOptionContainer
71 NonOptionContainerImpl(Container & c);
74 void push_back(std::string const & value);
81 ShortOption(bool withArg, std::string const & longOpt);
86 typedef std::map<char, ShortOption> ShortOptions;
90 CommandParser parser_;
91 ShortOptions shortOptions_;
92 boost::scoped_ptr<NonOptionContainer> nonOptions_;
99 ///////////////////////////////ih.e////////////////////////////////////////
106 // comment-column: 40
107 // c-file-style: "senf"
108 // indent-tabs-mode: nil
109 // ispell-local-dictionary: "american"
110 // compile-command: "scons -u test"