2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief ProgramOptions internal header */
17 #ifndef IH_SENF_Scheduler_Console_ProgramOptions_
18 #define IH_SENF_Scheduler_Console_ProgramOptions_ 1
21 #include <boost/scoped_ptr.hpp>
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
32 class ProgramOptionsSource : public ConfigSource
35 typedef boost::intrusive_ptr<ProgramOptionsSource> ptr;
37 static ptr create(int argc, char const ** argv);
39 template <class Container>
40 ProgramOptionsSource & nonOptions(Container & container);
41 ProgramOptionsSource & alias(char letter, std::string const & longOpt, bool withArg=false);
44 ProgramOptionsSource(int argc, char const ** argv);
46 virtual void v_parse(RestrictedExecutor & executor);
48 void parseLongOption(std::string const & arg, RestrictedExecutor & executor);
49 void parseNonOption(std::string const & arg, RestrictedExecutor & executor);
51 struct NonOptionContainer
53 virtual ~NonOptionContainer();
54 virtual void clear() = 0;
55 virtual void push_back(std::string const & value) = 0;
58 template <class Container>
59 struct NonOptionContainerImpl
60 : public NonOptionContainer
62 NonOptionContainerImpl(Container & c);
65 void push_back(std::string const & value);
72 ShortOption(bool withArg, std::string const & longOpt);
77 typedef std::map<char, ShortOption> ShortOptions;
81 CommandParser parser_;
82 ShortOptions shortOptions_;
83 boost::scoped_ptr<NonOptionContainer> nonOptions_;
90 //-/////////////////////////////////////////////////////////////////////////////////////////////////
98 // c-file-style: "senf"
99 // indent-tabs-mode: nil
100 // ispell-local-dictionary: "american"
101 // compile-command: "scons -u test"