yat  0.8.3pre
Option.h
00001 #ifndef _theplu_yat_utility_option_
00002 #define _theplu_yat_utility_option_
00003 
00004 // $Id: Option.h 2384 2010-12-22 14:03:36Z peter $
00005 
00006 /*
00007   Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
00008   Copyright (C) 2009, 2010 Peter Johansson
00009 
00010   This file is part of the yat library, http://dev.thep.lu.se/yat
00011 
00012   The yat library is free software; you can redistribute it and/or
00013   modify it under the terms of the GNU General Public License as
00014   published by the Free Software Foundation; either version 3 of the
00015   License, or (at your option) any later version.
00016 
00017   The yat library is distributed in the hope that it will be useful,
00018   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00020   General Public License for more details.
00021 
00022   You should have received a copy of the GNU General Public License
00023   along with yat. If not, see <http://www.gnu.org/licenses/>.
00024 */
00025 
00026 #include <string>
00027 #include <vector>
00028 
00029 namespace theplu {
00030 namespace yat {
00031 namespace utility {
00032 
00033   class CommandLine;
00037   class Option
00038   {
00039   public:
00048     Option(CommandLine& cmd, std::string name, std::string desc); 
00049 
00053     virtual ~Option(void);
00054     
00058     std::string description(void) const;
00059 
00065     void description(const std::string& description);
00066 
00070     std::string long_name(void) const;
00071 
00075     void parse(std::vector<std::string>::iterator&, 
00076                const std::vector<std::string>::iterator&);
00077 
00083     bool present(void) const;
00084 
00098     std::string print(void);
00099 
00103     void reset(void);
00104 
00108     char short_name(void) const;
00109 
00116     void validate(void);
00117 
00118   protected:
00122     const CommandLine& cmd(void) const;
00123 
00124   private:
00125     virtual void do_parse(std::vector<std::string>::iterator&, 
00126                           const std::vector<std::string>::iterator&)=0;
00127 
00130     virtual std::string print1(void) const;
00131 
00134     virtual std::string print2(void) const;
00135 
00138     virtual std::string print3(void) const;
00139 
00142     virtual std::string print4(void) const;
00143 
00146     virtual void do_validate(void) const=0;
00147 
00148 
00149     const CommandLine& cmd_;
00150     std::string description_;
00151     std::string long_name_;
00152     bool present_;
00153     char short_name_;
00154 
00155     // copy not allowed
00156     Option(const Option&);
00157     Option& operator=(const Option&);
00158   };
00159 
00160 }}} // of namespace utility, yat, and theplu
00161 
00162 #endif

Generated on Thu Dec 20 2012 03:12:58 for yat by  doxygen 1.8.0-20120409