UnlabeledMultiArg.h
Go to the documentation of this file.
1 
2 /******************************************************************************
3  *
4  * file: UnlabeledMultiArg.h
5  *
6  * Copyright (c) 2003, Michael E. Smoot.
7  * All rights reverved.
8  *
9  * See the file COPYING in the top directory of this distribution for
10  * more information.
11  *
12  * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
13  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18  * DEALINGS IN THE SOFTWARE.
19  *
20  *****************************************************************************/
21 
22 
23 #ifndef TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H
24 #define TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H
25 
26 #include <string>
27 #include <vector>
28 
29 #include <tclap/MultiArg.h>
31 
32 namespace TCLAP {
33 
39 template<class T>
40 class UnlabeledMultiArg : public MultiArg<T>
41 {
42 
43  // If compiler has two stage name lookup (as gcc >= 3.4 does)
44  // this is requried to prevent undef. symbols
49  using MultiArg<T>::_name;
53 
54  public:
55 
74  const std::string& desc,
75  bool req,
76  const std::string& typeDesc,
77  bool ignoreable = false,
78  Visitor* v = NULL );
97  UnlabeledMultiArg( const std::string& name,
98  const std::string& desc,
99  bool req,
100  const std::string& typeDesc,
102  bool ignoreable = false,
103  Visitor* v = NULL );
104 
120  UnlabeledMultiArg( const std::string& name,
121  const std::string& desc,
122  bool req,
123  Constraint<T>* constraint,
124  bool ignoreable = false,
125  Visitor* v = NULL );
126 
143  UnlabeledMultiArg( const std::string& name,
144  const std::string& desc,
145  bool req,
146  Constraint<T>* constraint,
147  CmdLineInterface& parser,
148  bool ignoreable = false,
149  Visitor* v = NULL );
150 
159  virtual bool processArg(int* i, std::vector<std::string>& args);
160 
165  virtual std::string shortID(const std::string& val="val") const;
166 
171  virtual std::string longID(const std::string& val="val") const;
172 
177  virtual bool operator==(const Arg& a) const;
178 
183  virtual void addToList( std::list<Arg*>& argList ) const;
184 };
185 
186 template<class T>
188  const std::string& desc,
189  bool req,
190  const std::string& typeDesc,
191  bool ignoreable,
192  Visitor* v)
193 : MultiArg<T>("", name, desc, req, typeDesc, v)
194 {
195  _ignoreable = ignoreable;
197 }
198 
199 template<class T>
201  const std::string& desc,
202  bool req,
203  const std::string& typeDesc,
205  bool ignoreable,
206  Visitor* v)
207 : MultiArg<T>("", name, desc, req, typeDesc, v)
208 {
209  _ignoreable = ignoreable;
211  parser.add( this );
212 }
213 
214 
215 template<class T>
217  const std::string& desc,
218  bool req,
219  Constraint<T>* constraint,
220  bool ignoreable,
221  Visitor* v)
222 : MultiArg<T>("", name, desc, req, constraint, v)
223 {
224  _ignoreable = ignoreable;
226 }
227 
228 template<class T>
230  const std::string& desc,
231  bool req,
232  Constraint<T>* constraint,
234  bool ignoreable,
235  Visitor* v)
236 : MultiArg<T>("", name, desc, req, constraint, v)
237 {
238  _ignoreable = ignoreable;
240  parser.add( this );
241 }
242 
243 
244 template<class T>
245 bool UnlabeledMultiArg<T>::processArg(int *i, std::vector<std::string>& args)
246 {
247 
248  if ( _hasBlanks( args[*i] ) )
249  return false;
250 
251  // never ignore an unlabeled multi arg
252 
253 
254  // always take the first value, regardless of the start string
255  _extractValue( args[(*i)] );
256 
257  /*
258  // continue taking args until we hit the end or a start string
259  while ( (unsigned int)(*i)+1 < args.size() &&
260  args[(*i)+1].find_first_of( Arg::flagStartString() ) != 0 &&
261  args[(*i)+1].find_first_of( Arg::nameStartString() ) != 0 )
262  _extractValue( args[++(*i)] );
263  */
264 
265  _alreadySet = true;
266 
267  return true;
268 }
269 
270 template<class T>
272 {
273  static_cast<void>(val); // Ignore input, don't warn
274  return std::string("<") + _typeDesc + "> ...";
275 }
276 
277 template<class T>
279 {
280  static_cast<void>(val); // Ignore input, don't warn
281  return std::string("<") + _typeDesc + "> (accepted multiple times)";
282 }
283 
284 template<class T>
286 {
287  if ( _name == a.getName() || _description == a.getDescription() )
288  return true;
289  else
290  return false;
291 }
292 
293 template<class T>
294 void UnlabeledMultiArg<T>::addToList( std::list<Arg*>& argList ) const
295 {
296  argList.push_back( const_cast<Arg*>(static_cast<const Arg* const>(this)) );
297 }
298 
299 }
300 
301 #endif
bool _alreadySet
Definition: Arg.h:137
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
virtual std::string shortID(const std::string &val="val") const
parser
Definition: enums.py:61
static void check(bool req, const std::string &argName)
virtual bool processArg(int *i, std::vector< std::string > &args)
GLsizei const GLchar *const * string
const std::string & getName() const
Definition: Arg.h:569
GLboolean GLboolean GLboolean GLboolean a
GLuint GLfloat * val
std::string _typeDesc
Definition: MultiArg.h:56
void _extractValue(const std::string &val)
Definition: MultiArg.h:398
virtual void addToList(std::list< Arg * > &argList) const
std::string _description
Definition: Arg.h:112
virtual std::string longID(const std::string &val="val") const
virtual void add(Arg &a)=0
bool _ignoreable
Definition: Arg.h:150
UnlabeledMultiArg(const std::string &name, const std::string &desc, bool req, const std::string &typeDesc, bool ignoreable=false, Visitor *v=NULL)
virtual bool operator==(const Arg &a) const
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
GLdouble v


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