BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
commandlineParser.h
Go to the documentation of this file.
1 #ifndef BALL_FORMAT_COMMANDLINEPARSER_H
2 #define BALL_FORMAT_COMMANDLINEPARSER_H
3 
4 #ifndef BALL_DATATYPE_OPTIONS_H
5 # include <BALL/DATATYPE/options.h>
6 #endif
7 
8 #ifndef BALL_DATATYPE_STRING_H
9 # include <BALL/DATATYPE/string.h>
10 #endif
11 
12 #ifndef BALL_FORMAT_PARAMFILE_H
13 # include <BALL/FORMAT/paramFile.h>
14 #endif
15 
16 #include <map>
17 #include <set>
18 
19 namespace BALL
20 {
46  {
47  public:
48  CommandlineParser(String tool_name, String tool_description, String tool_version, String build_date, String category="");
49 
51  void setToolManual(const String& manual);
52 
53  static const String NOT_FOUND;
54  static const list<String> EMTPY_LIST;
55 
56  // - CLI switch
57  // - description
58  // - parameter type
59  // - required
60  // - default value
61  // - hidden in galaxy
62  void registerParameter(String name, String description, ParameterType type, bool mandatory = false, String default_value = "", bool hidden = false);
63 
64  void registerFlag(String name, String description, bool default_gui_value = false, bool hidden = false);
65 
66  void registerAdvancedParameters(Options& options);
67 
68  // exclude parameter from showing in help mode e.g. galaxy specific multi-output parameter
69  void setParameterAsAdvanced(String name);
70 
72  void setParameterRestrictions(String par_name, double min_value, double max_value);
73 
75  void setParameterRestrictions(String par_name, list<String>& allowed_values);
76 
86  void setOutputFormatSource(String output_parname, String input_parname);
87 
92  void setSupportedFormats(String par_name, String supported_formats);
93 
96  void parse(int argc, char* argv[]);
97 
100  void copyAdvancedParametersToOptions(Options& options);
101 
107  const String& get(String name);
108 
111  bool has(String name);
112 
117  const list<String>& getList(String name);
118 
123  void printHelp(const std::set<String>& parameter_names = std::set<String>(), bool show_manual = true);
124 
125  void printToolInfo();
126 
127  const String& getStartTime();
128 
131  const String& getStartCommand();
132 
133  private:
134 
135  void replaceEscapedCharacters_(String& parameter_value);
136 
137  void checkAndRegisterParameter(String name, String description, ParameterType type, bool mandatory = false, String default_value = "", bool perform_check = true, bool hidden=false);
138 
139  void checkAndRegisterFlag(String name, String description, bool default_gui_value = false, bool perform_check = true, bool hidden=false);
140 
141 
142  void validateRegisteredFilesHaveFormats();
143 
145  void checkParameterName(const String& name, const bool perform_check = true);
146 
148  std::set<String> reserved_params_;
149 
151  std::list<std::pair<String, String> > escaped_chars_;
152  std::map<String, list<String> > parameter_map_;
153  std::map<String, ParameterDescription> registered_parameters_;
154 
155  std::map<String, ParameterDescription> registered_flags_;
156  typedef std::map<String, ParameterDescription>::iterator MapIterator;
157  std::list<MapIterator> original_parameter_order_;
158  std::list<MapIterator> original_flag_order_;
159  Size max_parname_length_;
160  Size max_flagname_length_;
161  String tool_name_;
162  String tool_description_;
163  String tool_version_;
164  String build_date_;
165  String hostname_;
166  String start_time_;
167  String tool_manual_;
168  String start_command_;
169  String tool_category_;
170  };
171 }
172 
173 #endif // BALL_FORMAT_COMMANDLINEPARSER_H
static const String NOT_FOUND
#define BALL_EXPORT
Definition: COMMON/global.h:50
static const list< String > EMTPY_LIST