Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Option.h
1 /*
2  * Option class interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2004-07, IRIT UPS.
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef ELM_OPTION_OPTION_H
22 #define ELM_OPTION_OPTION_H
23 
24 #include <elm/util/VarArg.h>
25 #include <elm/string.h>
26 #include <elm/io.h>
27 #include <elm/data/Vector.h>
28 
29 namespace elm { namespace option {
30 
31 class Manager;
32 
33 // OptionException exception
35 public:
37 };
38 
39 
40 // Argument usage
41 typedef enum usage_t {
45 } usage_t;
46 
47 
48 // Option class
49 class Option {
50 public:
51 
52  class Make {
53  friend class Option;
54  public:
55  inline Make(Manager *m): man(*m) { }
56  inline Make(Manager& m): man(m) { }
57  inline Make& cmd(string cmd) { cmds.add(cmd); return *this; }
58  inline Make& help(cstring d) { _desc = d; return *this; }
59  inline Make& description(cstring desc) { _desc = desc; return *this; }
60  protected:
64  };
65 
66  inline Option() { }
67  Option(const Make& make);
68  virtual ~Option() { }
69  virtual cstring description();
70  virtual usage_t usage() = 0;
71  virtual cstring argDescription() = 0;
72  virtual void process(String arg) = 0;
73 
74 protected:
76 };
77 
78 } } // elm::option
79 
80 #endif // ELM_OPTION_OPTION_H
elm::MessageException
Definition: MessageException.h:30
elm::option::arg_none
@ arg_none
Definition: Option.h:42
elm::option::Option::Option
Option()
Definition: Option.h:66
Make
elm::option::Option::Make::man
Manager & man
Definition: Option.h:61
elm::MessageException::message
virtual String message(void)
Definition: util_MessageException.cpp:50
elm::option::Option::Make::_desc
cstring _desc
Definition: Option.h:63
elm::option::Option::Make::description
Make & description(cstring desc)
Definition: Option.h:59
elm::option::usage_t
usage_t
Definition: Option.h:41
elm::option::Manager
Definition: Manager.h:37
elm::CString
Definition: CString.h:17
elm::option::Option::Make
Definition: Option.h:52
elm::option::Option::usage
virtual usage_t usage()=0
elm::option::Option::argDescription
virtual cstring argDescription()=0
elm
Definition: adapter.h:26
elm::Vector::add
void add(const T &v)
Definition: Vector.h:101
elm::Vector< string >
elm::option::Option
Definition: Option.h:49
elm::option::Option::Make::help
Make & help(cstring d)
Definition: Option.h:58
elm::option::Option::Make::cmd
Make & cmd(string cmd)
Definition: Option.h:57
elm::option::Option::Make::cmds
Vector< string > cmds
Definition: Option.h:62
elm::option::Option::description
virtual cstring description()
Definition: option_Option.cpp:117
elm::option::OptionException
Definition: Option.h:34
elm::String
Definition: String.h:30
elm::option::arg_optional
@ arg_optional
Definition: Option.h:43
elm::option::OptionException::OptionException
OptionException(const String &message)
Definition: option_Manager.cpp:168
elm::option::arg_required
@ arg_required
Definition: Option.h:44
elm::option::Option::~Option
virtual ~Option()
Definition: Option.h:68
elm::option::Option::Make::Make
Make(Manager &m)
Definition: Option.h:56
elm::option::Option::process
virtual void process(String arg)=0
elm::option::Option::desc
cstring desc
Definition: Option.h:75
elm::option::Option::Make::Make
Make(Manager *m)
Definition: Option.h:55