Console: Documentation of the configuration support
[senf.git] / Console / ProgramOptions.ih
index 36e9e55..e02d174 100644 (file)
@@ -27,6 +27,7 @@
 #define IH_ProgramOptions_ 1
 
 // Custom includes
+#include <boost/scoped_ptr.hpp>
 #include "Parse.hh"
 
 ///////////////////////////////ih.p////////////////////////////////////////
@@ -35,10 +36,18 @@ namespace senf {
 namespace console {
 namespace detail {
     
+#ifndef DOXYGEN
+
     class ProgramOptionsSource : public ConfigSource
     {
     public:
+        typedef boost::intrusive_ptr<ProgramOptionsSource> ptr;
+
         static ptr create(int argc, char ** argv);
+
+        template <class Container>
+        ProgramOptionsSource & nonOptions(Container & container);
+        ProgramOptionsSource & alias(char letter, std::string const & longOpt, bool withArg=false);
         
     private:
         ProgramOptionsSource(int argc, char ** argv);
@@ -47,12 +56,44 @@ namespace detail {
 
         void parseLongOption(std::string const & arg, RestrictedExecutor & executor);
         void parseNonOption(std::string const & arg, RestrictedExecutor & executor);
+
+        struct NonOptionContainer
+        {
+            virtual ~NonOptionContainer();
+            virtual void clear() = 0;
+            virtual void push_back(std::string const & value) = 0;
+        };
+
+        template <class Container>
+        struct NonOptionContainerImpl
+            : public NonOptionContainer
+        {
+            NonOptionContainerImpl(Container & c);
+
+            void clear();
+            void push_back(std::string const & value);
+
+            Container & c_;
+        };
+
+        struct ShortOption
+        {
+            ShortOption(bool withArg, std::string const & longOpt);
+            bool withArg;
+            std::string longOpt;
+        };
+
+        typedef std::map<char, ShortOption> ShortOptions;
         
         int argc_;
         char ** argv_;
         CommandParser parser_;
+        ShortOptions shortOptions_;
+        boost::scoped_ptr<NonOptionContainer> nonOptions_;
     };
 
+#endif
+
 }}}
 
 ///////////////////////////////ih.e////////////////////////////////////////