UnlabeledValueArg.h
Go to the documentation of this file.
1 
2 /******************************************************************************
3  *
4  * file: UnlabeledValueArg.h
5  *
6  * Copyright (c) 2003, Michael E. Smoot .
7  * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
8  * All rights reverved.
9  *
10  * See the file COPYING in the top directory of this distribution for
11  * more information.
12  *
13  * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19  * DEALINGS IN THE SOFTWARE.
20  *
21  *****************************************************************************/
22 
23 
24 #ifndef TCLAP_UNLABELED_VALUE_ARGUMENT_H
25 #define TCLAP_UNLABELED_VALUE_ARGUMENT_H
26 
27 #include <string>
28 #include <vector>
29 
30 #include <tclap/ValueArg.h>
32 
33 
34 namespace TCLAP {
35 
42 template<class T>
43 class UnlabeledValueArg : public ValueArg<T>
44 {
45 
46  // If compiler has two stage name lookup (as gcc >= 3.4 does)
47  // this is requried to prevent undef. symbols
52  using ValueArg<T>::_name;
56 
57  public:
58 
81  const std::string& desc,
82  bool req,
83  T value,
84  const std::string& typeDesc,
85  bool ignoreable = false,
86  Visitor* v = NULL);
87 
110  UnlabeledValueArg( const std::string& name,
111  const std::string& desc,
112  bool req,
113  T value,
114  const std::string& typeDesc,
116  bool ignoreable = false,
117  Visitor* v = NULL );
118 
138  UnlabeledValueArg( const std::string& name,
139  const std::string& desc,
140  bool req,
141  T value,
142  Constraint<T>* constraint,
143  bool ignoreable = false,
144  Visitor* v = NULL );
145 
146 
167  UnlabeledValueArg( const std::string& name,
168  const std::string& desc,
169  bool req,
170  T value,
171  Constraint<T>* constraint,
172  CmdLineInterface& parser,
173  bool ignoreable = false,
174  Visitor* v = NULL);
175 
184  virtual bool processArg(int* i, std::vector<std::string>& args);
185 
189  virtual std::string shortID(const std::string& val="val") const;
190 
194  virtual std::string longID(const std::string& val="val") const;
195 
199  virtual bool operator==(const Arg& a ) const;
200 
205  virtual void addToList( std::list<Arg*>& argList ) const;
206 
207 };
208 
212 template<class T>
214  const std::string& desc,
215  bool req,
216  T val,
217  const std::string& typeDesc,
218  bool ignoreable,
219  Visitor* v)
220 : ValueArg<T>("", name, desc, req, val, typeDesc, v)
221 {
222  _ignoreable = ignoreable;
223 
225 
226 }
227 
228 template<class T>
230  const std::string& desc,
231  bool req,
232  T val,
233  const std::string& typeDesc,
235  bool ignoreable,
236  Visitor* v)
237 : ValueArg<T>("", name, desc, req, val, typeDesc, v)
238 {
239  _ignoreable = ignoreable;
241  parser.add( this );
242 }
243 
247 template<class T>
249  const std::string& desc,
250  bool req,
251  T val,
252  Constraint<T>* constraint,
253  bool ignoreable,
254  Visitor* v)
255 : ValueArg<T>("", name, desc, req, val, constraint, v)
256 {
257  _ignoreable = ignoreable;
259 }
260 
261 template<class T>
263  const std::string& desc,
264  bool req,
265  T val,
266  Constraint<T>* constraint,
268  bool ignoreable,
269  Visitor* v)
270 : ValueArg<T>("", name, desc, req, val, constraint, v)
271 {
272  _ignoreable = ignoreable;
274  parser.add( this );
275 }
276 
280 template<class T>
281 bool UnlabeledValueArg<T>::processArg(int *i, std::vector<std::string>& args)
282 {
283 
284  if ( _alreadySet )
285  return false;
286 
287  if ( _hasBlanks( args[*i] ) )
288  return false;
289 
290  // never ignore an unlabeled arg
291 
292  _extractValue( args[*i] );
293  _alreadySet = true;
294  return true;
295 }
296 
300 template<class T>
302 {
303  static_cast<void>(val); // Ignore input, don't warn
304  return std::string("<") + _typeDesc + ">";
305 }
306 
310 template<class T>
312 {
313  static_cast<void>(val); // Ignore input, don't warn
314 
315  // Ideally we would like to be able to use RTTI to return the name
316  // of the type required for this argument. However, g++ at least,
317  // doesn't appear to return terribly useful "names" of the types.
318  return std::string("<") + _typeDesc + ">";
319 }
320 
324 template<class T>
326 {
327  if ( _name == a.getName() || _description == a.getDescription() )
328  return true;
329  else
330  return false;
331 }
332 
333 template<class T>
334 void UnlabeledValueArg<T>::addToList( std::list<Arg*>& argList ) const
335 {
336  argList.push_back( const_cast<Arg*>(static_cast<const Arg* const>(this)) );
337 }
338 
339 }
340 #endif
bool _alreadySet
Definition: Arg.h:137
void _extractValue(const std::string &val)
Definition: ValueArg.h:400
Definition: Arg.h:64
GLuint const GLchar * name
bool _hasBlanks(const std::string &s) const
Definition: Arg.h:641
std::string getDescription() const
Definition: Arg.h:554
GLfloat value
virtual void addToList(std::list< Arg * > &argList) const
parser
Definition: enums.py:61
static void check(bool req, const std::string &argName)
GLsizei const GLchar *const * string
virtual bool operator==(const Arg &a) const
const std::string & getName() const
Definition: Arg.h:569
GLboolean GLboolean GLboolean GLboolean a
GLuint GLfloat * val
UnlabeledValueArg(const std::string &name, const std::string &desc, bool req, T value, const std::string &typeDesc, bool ignoreable=false, Visitor *v=NULL)
virtual std::string longID(const std::string &val="val") const
std::string _description
Definition: Arg.h:112
virtual void add(Arg &a)=0
virtual bool processArg(int *i, std::vector< std::string > &args)
bool _ignoreable
Definition: Arg.h:150
std::string _typeDesc
Definition: ValueArg.h:67
std::string _name
Definition: Arg.h:107
#define NULL
Definition: tinycthread.c:47
int i
Definition: Arg.h:57
virtual std::string toString() const
Definition: Arg.h:599
virtual std::string shortID(const std::string &val="val") const
GLdouble v


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:13