yat/utility/OptionInFile.h

Code
Comments
Other
Rev Date Author Line
1014 01 Feb 08 peter 1 #ifndef _theplu_yat_utility_option_in_file_
1014 01 Feb 08 peter 2 #define _theplu_yat_utility_option_in_file_
1014 01 Feb 08 peter 3
1014 01 Feb 08 peter 4 // $Id$
1014 01 Feb 08 peter 5
1014 01 Feb 08 peter 6 /*
2119 12 Dec 09 peter 7   Copyright (C) 2008 Jari Häkkinen, Peter Johansson
4359 23 Aug 23 peter 8   Copyright (C) 2009 Peter Johansson
1014 01 Feb 08 peter 9
1437 25 Aug 08 peter 10   This file is part of the yat library, http://dev.thep.lu.se/yat
1014 01 Feb 08 peter 11
1014 01 Feb 08 peter 12   The yat library is free software; you can redistribute it and/or
1014 01 Feb 08 peter 13   modify it under the terms of the GNU General Public License as
1486 09 Sep 08 jari 14   published by the Free Software Foundation; either version 3 of the
1014 01 Feb 08 peter 15   License, or (at your option) any later version.
1014 01 Feb 08 peter 16
1014 01 Feb 08 peter 17   The yat library is distributed in the hope that it will be useful,
1014 01 Feb 08 peter 18   but WITHOUT ANY WARRANTY; without even the implied warranty of
1014 01 Feb 08 peter 19   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1014 01 Feb 08 peter 20   General Public License for more details.
1014 01 Feb 08 peter 21
1014 01 Feb 08 peter 22   You should have received a copy of the GNU General Public License
1487 10 Sep 08 jari 23   along with yat. If not, see <http://www.gnu.org/licenses/>.
1014 01 Feb 08 peter 24 */
1014 01 Feb 08 peter 25
2057 11 Sep 09 peter 26 #include "deprecate.h"
1014 01 Feb 08 peter 27 #include "OptionFile.h"
1014 01 Feb 08 peter 28
1014 01 Feb 08 peter 29 #include <iosfwd>
1014 01 Feb 08 peter 30 #include <string>
1014 01 Feb 08 peter 31
1014 01 Feb 08 peter 32 namespace theplu {
1014 01 Feb 08 peter 33 namespace yat {
1014 01 Feb 08 peter 34 namespace utility {
1014 01 Feb 08 peter 35
1014 01 Feb 08 peter 36   class CommandLine;
1014 01 Feb 08 peter 37   /**
1014 01 Feb 08 peter 38      \brief Class for file related options
2057 11 Sep 09 peter 39
2057 11 Sep 09 peter 40      \deprecated Provided for backward compatibility with the 0.5
2057 11 Sep 09 peter 41      API. Use OptionFile and StreamRedirect instead (see CommandLine
2057 11 Sep 09 peter 42      for example code).
1014 01 Feb 08 peter 43    */
1014 01 Feb 08 peter 44   class OptionInFile : public OptionFile
1014 01 Feb 08 peter 45   {
1014 01 Feb 08 peter 46   public:
1014 01 Feb 08 peter 47     /**
4200 19 Aug 22 peter 48        \brief Constructor
4200 19 Aug 22 peter 49
1014 01 Feb 08 peter 50        \param cmd Commandline Option is associated with
1014 01 Feb 08 peter 51        \param name string such as "file" for --file, "f" for -f or
1014 01 Feb 08 peter 52        "f,file" for having both short and long option name
1014 01 Feb 08 peter 53        \param desc string used in help display
1014 01 Feb 08 peter 54        \param required If true option must be found in commandline or
1014 01 Feb 08 peter 55        exception is thrown in validation
1014 01 Feb 08 peter 56     */
4200 19 Aug 22 peter 57     OptionInFile(CommandLine& cmd, std::string name, std::string desc,
4200 19 Aug 22 peter 58                  bool required=false) YAT_DEPRECATE_GCC_PRE4_3;
1014 01 Feb 08 peter 59
1014 01 Feb 08 peter 60     /**
1014 01 Feb 08 peter 61        \brief Destructor
1014 01 Feb 08 peter 62     */
1014 01 Feb 08 peter 63     virtual ~OptionInFile(void);
1014 01 Feb 08 peter 64
1014 01 Feb 08 peter 65     /**
1014 01 Feb 08 peter 66        \return ifstream corresponding to value(). If option was not
1014 01 Feb 08 peter 67        found during parsing, std::cin is returned.
1014 01 Feb 08 peter 68     */
1014 01 Feb 08 peter 69     std::istream& istream(void);
1014 01 Feb 08 peter 70
1014 01 Feb 08 peter 71   private:
1014 01 Feb 08 peter 72     std::ifstream* is_;
4200 19 Aug 22 peter 73
2057 11 Sep 09 peter 74   } YAT_DEPRECATE;
1014 01 Feb 08 peter 75
1014 01 Feb 08 peter 76 }}} // of namespace utility, yat, and theplu
1014 01 Feb 08 peter 77
1014 01 Feb 08 peter 78 #endif