args_visitor.hh

Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
00005  * Copyright (c) 2006 Stephen Bennett
00006  *
00007  * This file is part of the Paludis package manager. Paludis is free software;
00008  * you can redistribute it and/or modify it under the terms of the GNU General
00009  * Public License version 2, as published by the Free Software Foundation.
00010  *
00011  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
00012  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00014  * details.
00015  *
00016  * You should have received a copy of the GNU General Public License along with
00017  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00018  * Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 #ifndef PALUDIS_GUARD_ARGS_ARGS_VISITOR_HH
00022 #define PALUDIS_GUARD_ARGS_ARGS_VISITOR_HH 1
00023 
00024 #include <paludis/util/simple_visitor.hh>
00025 #include <paludis/util/wrapped_forward_iterator.hh>
00026 #include <paludis/util/attributes.hh>
00027 #include <string>
00028 
00029 /** \file
00030  * Declarations for ArgsVisitor.
00031  *
00032  * \ingroup g_args
00033  *
00034  * \section Examples
00035  *
00036  * - None at this time.
00037  */
00038 
00039 namespace paludis
00040 {
00041     namespace args
00042     {
00043         class ArgsOption;
00044         class StringArg;
00045         class AliasArg;
00046         class SwitchArg;
00047         class IntegerArg;
00048         class EnumArg;
00049         class StringSetArg;
00050         class StringSequenceArg;
00051 
00052         /**
00053          * Visitor class. Processes command-line options as they are found.
00054          *
00055          * \ingroup g_args
00056          */
00057         class PALUDIS_VISIBLE ArgsVisitor
00058         {
00059             public:
00060                 struct ArgsIteratorTag;
00061                 typedef WrappedForwardIterator<ArgsIteratorTag, std::string> ArgsIterator;
00062 
00063             private:
00064                 ArgsIterator * _args_index, _args_end;
00065                 std::string _env_prefix;
00066 
00067                 const std::string & get_param(const ArgsOption &);
00068 
00069                 std::string env_name(const std::string & long_name) const;
00070 
00071                 bool _no;
00072 
00073             public:
00074                 /**
00075                  * Constructor
00076                  */
00077                 ArgsVisitor(ArgsIterator *, ArgsIterator,
00078                         const std::string & env_prefix = "");
00079 
00080                 /// Visit a StringArg.
00081                 void visit(StringArg &);
00082 
00083                 /// Visit an AliasArg.
00084                 void visit(AliasArg &);
00085 
00086                 /// Visit a SwitchArg.
00087                 void visit(SwitchArg &);
00088 
00089                 /// Visit an IntegerArg.
00090                 void visit(IntegerArg &);
00091 
00092                 /// Visit an EnumArg.
00093                 void visit(EnumArg &);
00094 
00095                 /// Visit a StringSetArg.
00096                 void visit(StringSetArg &);
00097 
00098                 /// Visit a StringSequenceArg.
00099                 void visit(StringSequenceArg &);
00100 
00101                 /// Change whether we're visiting a --no- option
00102                 void set_no(const bool);
00103         };
00104     }
00105 }
00106 
00107 #endif

Generated on Mon Sep 21 10:36:08 2009 for paludis by  doxygen 1.5.4