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 {
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
Definition: CString.h:17
Definition: MessageException.h:30
virtual String message(void)
Definition: util_MessageException.cpp:50
Definition: String.h:30
void add(const T &v)
Definition: Vector.h:115
Definition: Manager.h:37
Definition: Option.h:34
OptionException(const String &message)
Definition: option_Manager.cpp:168
Definition: Option.h:52
Make(Manager &m)
Definition: Option.h:56
Make & cmd(string cmd)
Definition: Option.h:57
Make & help(cstring d)
Definition: Option.h:58
Make & description(cstring desc)
Definition: Option.h:59
Vector< string > cmds
Definition: Option.h:62
Manager & man
Definition: Option.h:61
cstring _desc
Definition: Option.h:63
Make(Manager *m)
Definition: Option.h:55
Definition: Option.h:49
virtual ~Option()
Definition: Option.h:68
virtual void process(String arg)=0
virtual cstring argDescription()=0
Option()
Definition: Option.h:66
virtual cstring description()
Definition: option_Option.cpp:117
cstring desc
Definition: Option.h:75
virtual usage_t usage()=0
usage_t
Definition: Option.h:41
@ arg_optional
Definition: Option.h:43
@ arg_none
Definition: Option.h:42
@ arg_required
Definition: Option.h:44
Definition: adapter.h:26