#define IH_ProgramOptions_ 1
// Custom includes
+#include <boost/scoped_ptr.hpp>
#include "Parse.hh"
///////////////////////////////ih.p////////////////////////////////////////
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);
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////////////////////////////////////////