gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Bug fix in arg_parser.h (fix ticket #31) and doc improvements
0 1 0
default
1 file changed with 16 insertions and 16 deletions:
↑ Collapse diff ↑
Show white space 12 line context
... ...
@@ -124,44 +124,44 @@
124 124
    ~ArgParser();
125 125

	
126 126
    ///Add a new integer type option
127 127

	
128 128
    ///\param name The name of the option. The leading '-' must be omitted.
129 129
    ///\param help A help string.
130
    ///\param value A default value for the option
130
    ///\param value A default value for the option.
131 131
    ///\param obl Indicate if the option is mandatory.
132 132
    ArgParser &intOption(const std::string &name,
133 133
		    const std::string &help,
134 134
		    int value=0, bool obl=false);
135 135

	
136 136
    ///Add a new floating point type option
137 137

	
138 138
    ///\param name The name of the option. The leading '-' must be omitted.
139 139
    ///\param help A help string.
140
    ///\param value A default value for the option
140
    ///\param value A default value for the option.
141 141
    ///\param obl Indicate if the option is mandatory.
142 142
    ArgParser &doubleOption(const std::string &name,
143 143
		      const std::string &help,
144 144
		      double value=0, bool obl=false);
145 145

	
146 146
    ///Add a new bool type option
147 147

	
148 148
    ///\param name The name of the option. The leading '-' must be omitted.
149 149
    ///\param help A help string.
150
    ///\param value A default value for the option
150
    ///\param value A default value for the option.
151 151
    ///\param obl Indicate if the option is mandatory.
152
    ////\note A mandatory bool obtion is of very little use.)
152
    ///\note A mandatory bool obtion is of very little use.
153 153
    ArgParser &boolOption(const std::string &name,
154 154
		      const std::string &help,
155 155
		      bool value=false, bool obl=false);
156 156

	
157 157
    ///Add a new string type option
158 158

	
159 159
    ///\param name The name of the option. The leading '-' must be omitted.
160 160
    ///\param help A help string.
161
    ///\param value A default value for the option
161
    ///\param value A default value for the option.
162 162
    ///\param obl Indicate if the option is mandatory.
163 163
    ArgParser &stringOption(const std::string &name,
164 164
		      const std::string &help,
165 165
		      std::string value="", bool obl=false);
166 166

	
167 167
    ///\name Options with external storage
... ...
@@ -193,23 +193,23 @@
193 193
    ///Add a new bool type option with a storage reference
194 194

	
195 195
    ///\param name The name of the option. The leading '-' must be omitted.
196 196
    ///\param help A help string.
197 197
    ///\param obl Indicate if the option is mandatory.
198 198
    ///\retval ref The value of the argument will be written to this variable.
199
    ////\note A mandatory bool obtion is of very little use.)
199
    ///\note A mandatory bool obtion is of very little use.
200 200
    ArgParser &refOption(const std::string &name,
201 201
		      const std::string &help,
202 202
		      bool &ref, bool obl=false);
203 203

	
204 204
    ///Add a new string type option with a storage reference
205 205

	
206 206
    ///\param name The name of the option. The leading '-' must be omitted.
207 207
    ///\param help A help string.
208
    ///\param obl Indicate if the option is mandatory.
208 209
    ///\retval ref The value of the argument will be written to this variable.
209
    ///\param obl Indicate if the option is mandatory.
210 210
    ArgParser &refOption(const std::string &name,
211 211
		      const std::string &help,
212 212
		      std::string &ref, bool obl=false);
213 213
    
214 214
    ///@}
215 215

	
... ...
@@ -308,47 +308,47 @@
308 308
      ///\e
309 309
      RefType(ArgParser &p,const std::string &n) :_parser(p),_name(n) {}
310 310
      ///\e
311 311
      operator bool() 
312 312
      {
313 313
	Opts::iterator i = _parser._opts.find(_name);
314
	LEMON_ASSERT(i==_parser._opts.end(),
314
	LEMON_ASSERT(i!=_parser._opts.end(),
315 315
		     std::string()+"Unkown option: '"+_name+"'");
316
	LEMON_ASSERT(i->second.type!=ArgParser::BOOL,
316
	LEMON_ASSERT(i->second.type==ArgParser::BOOL,
317 317
		     std::string()+"'"+_name+"' is a bool option");
318 318
	return *(i->second.bool_p);
319 319
      }
320 320
      ///\e
321 321
      operator std::string()
322 322
      {
323 323
	Opts::iterator i = _parser._opts.find(_name);
324
	LEMON_ASSERT(i==_parser._opts.end(),
324
	LEMON_ASSERT(i!=_parser._opts.end(),
325 325
		     std::string()+"Unkown option: '"+_name+"'");
326
	LEMON_ASSERT(i->second.type!=ArgParser::STRING,
326
	LEMON_ASSERT(i->second.type==ArgParser::STRING,
327 327
		     std::string()+"'"+_name+"' is a string option");
328 328
	return *(i->second.string_p);
329 329
      }
330 330
      ///\e
331 331
      operator double() 
332 332
      {
333 333
	Opts::iterator i = _parser._opts.find(_name);
334
	LEMON_ASSERT(i==_parser._opts.end(),
334
	LEMON_ASSERT(i!=_parser._opts.end(),
335 335
		     std::string()+"Unkown option: '"+_name+"'");
336
	LEMON_ASSERT(i->second.type!=ArgParser::DOUBLE &&
337
		     i->second.type!=ArgParser::INTEGER,
336
	LEMON_ASSERT(i->second.type==ArgParser::DOUBLE ||
337
		     i->second.type==ArgParser::INTEGER,
338 338
		     std::string()+"'"+_name+"' is a floating point option");
339 339
	return i->second.type==ArgParser::DOUBLE ?
340 340
	  *(i->second.double_p) : *(i->second.int_p);
341 341
      }
342 342
      ///\e
343 343
      operator int() 
344 344
      {
345 345
	Opts::iterator i = _parser._opts.find(_name);
346
	LEMON_ASSERT(i==_parser._opts.end(),
346
	LEMON_ASSERT(i!=_parser._opts.end(),
347 347
		     std::string()+"Unkown option: '"+_name+"'");
348
	LEMON_ASSERT(i->second.type!=ArgParser::INTEGER,
348
	LEMON_ASSERT(i->second.type==ArgParser::INTEGER,
349 349
		     std::string()+"'"+_name+"' is an integer option");
350 350
	return *(i->second.int_p);
351 351
      }
352 352

	
353 353
    };
354 354

	
0 comments (0 inline)