VR-Link API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cmdValueArg.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * file: ValueArg.h
4  *
5  * Copyright (c) 2003, Michael E. Smoot .
6  * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
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 cmdValueArg_H_
24 #define cmdValueArg_H_
25 
29 
30 #include <string>
31 #include <vector>
32 #include "cmdArg.h"
33 
34 #ifdef HAVE_CONFIG_H
35 #include <config.h>
36 #else
37 #define HAVE_SSTREAM
38 #endif
39 
40 #if defined(HAVE_SSTREAM)
41 #include <sstream>
42 #elif defined(HAVE_STRSTREAM)
43 #include <strstream>
44 #else
45 #error "Need a stringstream (sstream or strstream) to compile!"
46 #endif
47 
48 #ifdef DtUSE_UTILITIES_NAMESPACE
49 namespace DtUSE_UTILITIES_NAMESPACE
50 {
51 #endif
52 
53 namespace DtCmdLine {
54 
62  template<class T>
63  class ValueArg : public Arg
64  {
65 
66  public:
67 
89  ValueArg( const std::string& flag,
90  const std::string& name,
91  const std::string& desc,
92  bool req,
93  T value,
94  const std::string& typeDesc,
95  Visitor* v = NULL);
96 
97 
118  ValueArg( const std::string& flag,
119  const std::string& name,
120  const std::string& desc,
121  bool req,
122  T value,
123  const std::string& typeDesc,
124  CmdLineInterface& parser,
125  Visitor* v = NULL );
126 
147  //
148  ValueArg( const std::string& flag,
149  const std::string& name,
150  const std::string& desc,
151  bool req,
152  T value,
153  const std::vector<T>& allowed,
154  CmdLineInterface& parser,
155  Visitor* v = NULL );
156 
176  ValueArg( const std::string& flag,
177  const std::string& name,
178  const std::string& desc,
179  bool req,
180  T value,
181  const std::vector<T>& allowed,
182  Visitor* v = NULL );
183 
191  virtual bool processArg(int* i, std::vector<std::string>& args);
192 
194  const T& getValue() const;
195 
197  T& getValue() ;
198 
200  void setValue(const T& val);
201 
204  T* getInternalPtrValue();
205 
207  operator T&();
208 
211  virtual std::string shortID(const std::string& val = "val") const;
212 
215  virtual std::string longID(const std::string& val = "val") const;
216 
217  protected:
218 
223 
228  std::vector<T> _allowed;
229 
235  std::string _typeDesc;
236 
241  void _extractValue( const std::string& val );
242 
245  void _checkAllowed( const std::string& val );
246 
248  void allowedInit();
249 
250  };
251 
252 }
253 
254 #ifdef DtUSE_UTILITIES_NAMESPACE
255 }
256 #endif
257 
259 #define cmdValueArg_inl_
260 
261 #include "cmdValueArg.inl"
262 #undef cmdValueArg_inl_
263 
264 #endif

Document ID: Generated on Wed Jan 7 13:31:29 EST 2015 from SVN revision 149162
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)