source: trunk/yat/utility/OptionFile.h

Last change on this file was 2119, checked in by Peter, 12 years ago

converted files to utf-8. fixes #577

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1#ifndef _theplu_yat_utility_option_file_
2#define _theplu_yat_utility_option_file_
3
4// $Id: OptionFile.h 2119 2009-12-12 23:11:43Z peter $
5
6/*
7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2009 Peter Johansson
9
10  This file is part of the yat library, http://dev.thep.lu.se/yat
11
12  The yat library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 3 of the
15  License, or (at your option) any later version.
16
17  The yat library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21
22  You should have received a copy of the GNU General Public License
23  along with yat. If not, see <http://www.gnu.org/licenses/>.
24*/
25
26#include "OptionArg.h"
27
28#include <string>
29
30namespace theplu {
31namespace yat {
32namespace utility {
33
34  class CommandLine;
35  /**
36     \brief Class for file related options
37
38     This class could be used for an option with argument when the
39     argument is a file. The class adds some convenience on top of
40     OptionArg<std::string> by utilizing the FileUtil class. Besides
41     setting the name and description of the option and whether the
42     option must appear in the command line, you can declare whether
43     the file must exist and whether it must fulfill certain file
44     permissions. If any of these requirements are not met, an
45     exception will be thrown during the validation phase in
46     CommandLine::parse.
47
48     \see FileUtil
49   */
50  class OptionFile : public OptionArg<std::string>
51  {
52  public:
53    /**
54       \brief Constructor
55       
56       \param cmd Commandline Option is associated with
57       \param name string such as "file" for --file, "f" for -f or
58       "f,file" for having both short and long option name
59       \param desc string used in help display
60       \param required If true option must be found in commandline or
61       exception is thrown in validation
62       \param exist if true File must exist, see FileUtil::exists()
63       \param bits used to check permission on file, see
64       FileUtil::permissions()
65    */
66    OptionFile(CommandLine& cmd, std::string name, std::string desc, 
67               bool required=false, bool exist=false, std::string bits=""); 
68
69    /**
70       \brief Destructor
71    */
72    virtual ~OptionFile(void);
73
74  private:
75    void do_validate2() const;
76
77    bool exist_;
78    std::string bits_;
79   
80  };
81
82}}} // of namespace utility, yat, and theplu
83
84#endif
Note: See TracBrowser for help on using the repository browser.