VR-Link API Documentation for DIS
cmdValueArg.h
Go to the documentation of this file.
00001 /****************************************************************************** 
00002  * 
00003  *  file:  ValueArg.h
00004  * 
00005  *  Copyright (c) 2003, Michael E. Smoot .
00006  *  Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
00007  *  All rights reverved.
00008  * 
00009  *  See the file COPYING in the top directory of this distribution for
00010  *  more information.
00011  *  
00012  *  THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 
00013  *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
00014  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
00015  *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
00016  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
00017  *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
00018  *  DEALINGS IN THE SOFTWARE.  
00019  *  
00020  *****************************************************************************/ 
00021 
00022 
00023 #ifndef cmdValueArg_H_
00024 #define cmdValueArg_H_
00025 
00029 
00030 #include <string>
00031 #include <vector>
00032 #include "cmdArg.h"
00033 
00034 #ifdef HAVE_CONFIG_H
00035 #include <config.h>
00036 #else
00037 #define HAVE_SSTREAM
00038 #endif
00039 
00040 #if defined(HAVE_SSTREAM)
00041 #include <sstream>
00042 #elif defined(HAVE_STRSTREAM)
00043 #include <strstream>
00044 #else
00045 #error "Need a stringstream (sstream or strstream) to compile!"
00046 #endif
00047 
00048 #ifdef DtUSE_UTILITIES_NAMESPACE
00049 namespace DtUSE_UTILITIES_NAMESPACE
00050 {
00051 #endif
00052 
00053 namespace DtCmdLine {
00054 
00062    template<class T>
00063       class ValueArg : public Arg 
00064    {
00065 
00066    public:
00067 
00089          ValueArg( const std::string& flag, 
00090                    const std::string& name, 
00091                    const std::string& desc, 
00092                    bool req, 
00093                    T value,
00094                    const std::string& typeDesc,
00095                    Visitor* v = NULL);
00096 
00097 
00118          ValueArg( const std::string& flag, 
00119                    const std::string& name, 
00120                    const std::string& desc, 
00121                    bool req, 
00122                    T value,
00123                    const std::string& typeDesc,
00124                    CmdLineInterface& parser,
00125                    Visitor* v = NULL );
00126 
00147          //
00148          ValueArg( const std::string& flag, 
00149                    const std::string& name, 
00150                    const std::string& desc, 
00151                    bool req, 
00152                    T value,
00153                    const std::vector<T>& allowed,
00154                    CmdLineInterface& parser,
00155                    Visitor* v = NULL );
00156 
00176          ValueArg( const std::string& flag, 
00177                    const std::string& name, 
00178                    const std::string& desc, 
00179                    bool req, 
00180                    T value,
00181                    const std::vector<T>& allowed,
00182                    Visitor* v = NULL );
00183 
00191          virtual bool processArg(int* i, std::vector<std::string>& args); 
00192 
00194          const T& getValue() const;
00195 
00197          T& getValue() ;
00198 
00200          void setValue(const T& val);
00201 
00204          T* getInternalPtrValue();
00205 
00207          operator T&();
00208 
00211          virtual std::string shortID(const std::string& val = "val") const;
00212 
00215          virtual std::string longID(const std::string& val = "val") const;
00216 
00217       protected: 
00218 
00222          T _value;
00223 
00228          std::vector<T> _allowed;
00229 
00235          std::string _typeDesc;
00236 
00241          void _extractValue( const std::string& val );
00242 
00245          void _checkAllowed( const std::string& val );
00246 
00248          void allowedInit();
00249 
00250       };
00251 
00252 } 
00253 
00254 #ifdef DtUSE_UTILITIES_NAMESPACE
00255 }     
00256 #endif
00257 
00259 #define cmdValueArg_inl_
00260  
00261 #include "cmdValueArg.inl"
00262 #undef cmdValueArg_inl_
00263 
00264 #endif

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)