GetoptParser.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
24 //----------------------------------------------------------------------
25 #ifndef ICL_CORE_CONFIG_GETOPT_PARSER_H_INCLUDED
26 #define ICL_CORE_CONFIG_GETOPT_PARSER_H_INCLUDED
27 
28 #include "icl_core/BaseTypes.h"
29 #include "icl_core/Deprecate.h"
30 #include "icl_core/List.h"
31 #include "icl_core/Map.h"
32 #include "icl_core/Vector.h"
36 
37 namespace icl_core {
38 namespace config {
39 
55 {
56 public:
58  {
60  ePRC_Relaxed
61  };
63 
65  {
67  eCLC_Cleanup
68  };
70 
71  struct KeyValue
72  {
73  KeyValue(const icl_core::String& key, const icl_core::String& value)
74  : m_key(key),
75  m_value(value)
76  { }
77 
80  };
82 
85  static Getopt& instance();
86 
91  void activateExtraCmdParams(const icl_core::String& delimiter = "--");
92 
95  void addParameter(const GetoptParameter& parameter);
96 
99  void addParameter(const GetoptParameterList& parameters);
100 
103  void addParameter(const GetoptPositionalParameter& parameter);
104 
108  void addParameter(const GetoptPositionalParameterList& parameters);
109 
116  bool initialize(int& argc, char *argv[], bool remove_read_arguments);
117 
130  bool initialize(int& argc, char *argv[], CommandLineCleaning cleanup = eCLC_None,
131  ParameterRegistrationCheck registration_check = ePRC_Strict);
132 
135  bool isInitialized() const { return m_initialized; }
136 
138  int &argc();
139 
141  char** argv() const;
142 
145  icl_core::String extraCmdParam(size_t index) const;
146 
149  size_t extraCmdParamCount() const;
150 
156  icl_core::String paramOpt(const icl_core::String& name) const;
157 
160  bool paramOptPresent(const icl_core::String& name) const;
161 
164  KeyValueList paramPrefixOpt(const icl_core::String& prefix) const;
165 
168  bool paramPrefixOptPresent(const icl_core::String& prefix) const;
169 
174  icl_core::String paramNonOpt(size_t index) const;
175 
178  size_t paramNonOptCount() const;
179 
182  icl_core::String programName() const;
183 
186  icl_core::String programVersion() const;
187 
190  void setProgramVersion(icl_core::String const & version);
191 
194  void setProgramDescription(icl_core::String const & description);
195 
198  icl_core::String programDescription() const;
199 
202  void printHelp() const;
203 
205 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
206 
211 
217 
223 
229 
233  ICL_CORE_VC_DEPRECATE_STYLE bool Initialize(int& argc, char *argv[], bool remove_read_arguments)
235 
239  ICL_CORE_VC_DEPRECATE_STYLE bool Initialize(int& argc, char *argv[],
240  CommandLineCleaning cleanup = eCLC_None,
241  ParameterRegistrationCheck registration_check = ePRC_Strict)
243 
248 
254 
259 
265 
271 
275  ICL_CORE_VC_DEPRECATE_STYLE KeyValueList ParamPrefixOpt(const icl_core::String& prefix) const
277 
281  ICL_CORE_VC_DEPRECATE_STYLE bool ParamPrefixOptPresent(const icl_core::String& prefix) const
283 
288 
293 
298 
303 
304 #endif
305 
307 private:
308  Getopt();
309 
311  ParameterMap m_parameters;
312  ParameterMap m_prefix_parameters;
313  ParameterMap m_short_parameters;
319 
321 
322  int m_argc;
323  char** m_argv;
331 };
332 
333 }
334 }
335 #endif
icl_core::String m_extra_cmd_param_delimiter
Definition: GetoptParser.h:318
all options have to be registered
Definition: GetoptParser.h:59
ParameterMap m_short_prefix_parameters
Definition: GetoptParser.h:314
icl_core::Map< icl_core::String, GetoptParameter > ParameterMap
Definition: GetoptParser.h:310
bool initialize(int &argc, char *argv[], bool remove_read_arguments)
Definition: Config.cpp:50
#define ICL_CORE_VC_DEPRECATE_STYLE
Definition: Deprecate.h:53
#define ICL_CORE_VC_DEPRECATE
Definition: Deprecate.h:35
icl_core::Map< icl_core::String, icl_core::String > m_param_opt
Definition: GetoptParser.h:328
Handles commandline parameters.
Definition: GetoptParser.h:54
ICL_CORE_VC_DEPRECATE_STYLE icl_core::String ExtraCmdParam(size_t index) ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Config.h:854
icl_core::Vector< icl_core::String > m_extra_cmd_param
Definition: GetoptParser.h:330
ICL_CORE_VC_DEPRECATE CommandLineCleaning tCommandLineCleaning ICL_CORE_GCC_DEPRECATE
Definition: GetoptParser.h:69
Contains GetoptParameter.
void setProgramDescription(icl_core::String const &description)
Definition: Config.h:586
icl_core::String m_program_version
Definition: GetoptParser.h:325
icl_core::Vector< icl_core::String > m_param_non_opt
Definition: GetoptParser.h:327
#define ICL_CORE_CONFIG_IMPORT_EXPORT
Contains macros to deprecate classes, types, functions and variables.
ICL_CORE_VC_DEPRECATE_STYLE void AddParameter(const ConfigParameter &parameter) ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Config.h:872
icl_core::List< KeyValue > KeyValueList
Definition: GetoptParser.h:81
bool isInitialized() const
Definition: GetoptParser.h:135
ICL_CORE_VC_DEPRECATE_STYLE size_t ExtraCmdParamCount() ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Config.h:848
ParameterMap m_short_parameters
Definition: GetoptParser.h:313
ICL_CORE_VC_DEPRECATE_STYLE bool Initialize(int &argc, char *argv[], bool remove_read_arguments) ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Config.h:902
size_t extraCmdParamCount()
Definition: Config.h:521
GetoptPositionalParameterList m_required_positional_parameters
Definition: GetoptParser.h:315
ParameterMap m_prefix_parameters
Definition: GetoptParser.h:312
void activateExtraCmdParams(const icl_core::String &delimiter="--")
Definition: Config.h:531
bool paramOpt(const icl_core::String &name, typename icl_core::ConvertToRef< T >::ToRef value)
Definition: Config.h:384
Contains import/export definitions for the Win32 plattform.
icl_core::String m_program_description
Definition: GetoptParser.h:326
bool ParamOpt(const icl_core::String &name, typename icl_core::ConvertToRef< T >::ToRef value) ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Config.h:774
icl_core::String m_program_name
Definition: GetoptParser.h:324
void addParameter(const ConfigParameter &parameter)
Definition: Config.h:541
command line options are left untouched
Definition: GetoptParser.h:66
ICL_CORE_VC_DEPRECATE ParameterRegistrationCheck tParameterRegistrationCheck ICL_CORE_GCC_DEPRECATE
Definition: GetoptParser.h:62
icl_core::String extraCmdParam(size_t index)
Definition: Config.h:526
std::string String
Definition: BaseTypes.h:43
Contains GetoptPositionalParameter.
void printHelp()
Definition: Config.h:591
bool ParamNonOpt(size_t index, typename icl_core::ConvertToRef< T >::ToRef value) ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Config.h:826
Contains Interface base classes and base types.
ICL_CORE_VC_DEPRECATE_STYLE size_t ParamNonOptCount() ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Config.h:866
size_t paramNonOptCount()
Definition: Config.h:536
icl_core::Map< icl_core::String, KeyValueList > m_prefix_param_opt
Definition: GetoptParser.h:329
KeyValue(const icl_core::String &key, const icl_core::String &value)
Definition: GetoptParser.h:73
bool paramOptPresent(const icl_core::String &name)
Definition: Config.h:378
void setProgramVersion(icl_core::String const &version)
Definition: Config.h:581
ICL_CORE_VC_DEPRECATE_STYLE void ActivateExtraCmdParams(const icl_core::String &delimiter="--") ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Config.h:860
bool paramNonOpt(size_t index, typename icl_core::ConvertToRef< T >::ToRef value)
Definition: Config.h:470
ICL_CORE_VC_DEPRECATE_STYLE bool ParamOptPresent(const icl_core::String &name) ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Config.h:766
ICL_CORE_VC_DEPRECATE_STYLE void PrintHelp() ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Config.h:896
#define ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Deprecate.h:54
GetoptPositionalParameterList m_optional_positional_parameters
Definition: GetoptParser.h:316


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58