VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cmdUnlabeledMultiArg.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 DtCmdLine_MULTIPLE_UNLABELED_ARGUMENT_H
24 #define DtCmdLine_MULTIPLE_UNLABELED_ARGUMENT_H
25 
29 
30 #include <string>
31 #include <vector>
32 
33 #include "cmdMultiArg.h"
34 
35 #ifdef DtUSE_UTILITIES_NAMESPACE
36 namespace DtUSE_UTILITIES_NAMESPACE
37 {
38 #endif
39 
40  namespace DtCmdLine {
41 
47 
48  template<class T>
49  class UnlabeledMultiArg : public MultiArg<T>
50  {
51 #ifndef __solaris__
52 
53 
58  using MultiArg<T>::_name;
60 #endif
61 
62  public:
63 
79  UnlabeledMultiArg( const std::string& name,
80  const std::string& desc,
81  const std::string& typeDesc,
82  bool ignoreable = false,
83  Visitor* v = NULL );
100  UnlabeledMultiArg( const std::string& name,
101  const std::string& desc,
102  const std::string& typeDesc,
103  CmdLineInterface& parser,
104  bool ignoreable = false,
105  Visitor* v = NULL );
106 
120  UnlabeledMultiArg( const std::string& name,
121  const std::string& desc,
122  const std::vector<T>& allowed,
123  bool ignoreable = false,
124  Visitor* v = NULL );
125 
140  UnlabeledMultiArg( const std::string& name,
141  const std::string& desc,
142  const std::vector<T>& allowed,
143  CmdLineInterface& parser,
144  bool ignoreable = false,
145  Visitor* v = NULL );
146 
155  virtual bool processArg(int* i, std::vector<std::string>& args);
156 
161  virtual std::string shortID(const std::string& val="val") const;
162 
167  virtual std::string longID(const std::string& val="val") const;
168 
173  virtual bool operator==(const Arg& a) const;
174 
179  virtual void addToList( std::list<Arg*>& argList ) const;
180  };
181 
182  template<class T>
183  UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name,
184  const std::string& desc,
185  const std::string& typeDesc,
186  bool ignoreable,
187  Visitor* v)
188  : MultiArg<T>("", name, desc, false, typeDesc, v)
189  {
190  _ignoreable = ignoreable;
191  }
192 
193  template<class T>
194  UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name,
195  const std::string& desc,
196  const std::string& typeDesc,
197  CmdLineInterface& parser,
198  bool ignoreable,
199  Visitor* v)
200  : MultiArg<T>("", name, desc, false, typeDesc, v)
201  {
202  _ignoreable = ignoreable;
203  parser.add( this );
204  }
205 
206 
207  template<class T>
208  UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name,
209  const std::string& desc,
210  const std::vector<T>& allowed,
211  bool ignoreable,
212  Visitor* v)
213  : MultiArg<T>("", name, desc, false, allowed, v)
214  {
215  _ignoreable = ignoreable;
216  }
217 
218  template<class T>
219  UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name,
220  const std::string& desc,
221  const std::vector<T>& allowed,
222  CmdLineInterface& parser,
223  bool ignoreable,
224  Visitor* v)
225  : MultiArg<T>("", name, desc, false, allowed, v)
226  {
227  _ignoreable = ignoreable;
228  parser.add( this );
229  }
230 
231 
232  template<class T>
233  bool UnlabeledMultiArg<T>::processArg(int *i, std::vector<std::string>& args)
234  {
235 
236  if ( _hasBlanks( args[*i] ) )
237  return false;
238 
240 
241  _extractValue( args[*i] );
242  return true;
243  }
244 
245  template<class T>
246  std::string UnlabeledMultiArg<T>::shortID(const std::string& val) const
247  {
248  std::string id = "<" + _typeDesc + "> ...";
249 
250  return id;
251  }
252 
253  template<class T>
254  std::string UnlabeledMultiArg<T>::longID(const std::string& val) const
255  {
256  std::string id = "<" + _typeDesc + "> (accepted multiple times)";
257 
258  return id;
259  }
260 
261  template<class T>
263  {
264  if ( _name == a.getName() || _description == a.getDescription() )
265  return true;
266  else
267  return false;
268  }
269 
270  template<class T>
271  void UnlabeledMultiArg<T>::addToList( std::list<Arg*>& argList ) const
272  {
273  argList.push_back( (Arg*)this );
274  }
275 
276  }
277 
278 #ifdef DtUSE_UTILITIES_NAMESPACE
279 }
280 #endif
281 
282 #endif

Document ID: Generated on Tue Mar 1 02:56:17 EST 2016 from SVN revision 162687
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)