replacedCmdUnlabledMultiArg.h
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003  *
00004  *  file:  ReplacedUnlabeledMultiArg.h
00005  *
00006  *  Copyright (c) 2003, Michael E. Smoot.
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 #ifndef replacedCmdUnlabledMultiArg_H_
00023 #define replacedCmdUnlabledMultiArg_H_
00024 
00027 
00028 #include <string>
00029 #include <vector>
00030 
00031 #include <cmdLine/cmdMultiArg.h>
00032 
00033 namespace MAKLogger
00034 {
00035 
00041 template<class T>
00042 class ReplacedUnlabeledMultiArg : public DtCmdLine::MultiArg<T>
00043 {
00044 
00045    public:
00046 
00047 #ifndef __solaris__
00048 
00049 
00050       using DtCmdLine::MultiArg<T>::_ignoreable;
00051       using DtCmdLine::MultiArg<T>::_hasBlanks;
00052       using DtCmdLine::MultiArg<T>::_extractValue;
00053       using DtCmdLine::MultiArg<T>::_typeDesc;
00054       using DtCmdLine::MultiArg<T>::_name;
00055       using DtCmdLine::MultiArg<T>::_description;
00056 #endif
00057 
00058 
00059 
00075       ReplacedUnlabeledMultiArg( const std::string& name,
00076                        const std::string& desc,
00077                        const std::string& typeDesc,
00078                      bool ignoreable = false,
00079                        DtCmdLine::Visitor* v = NULL );
00096       ReplacedUnlabeledMultiArg( const std::string& name,
00097                        const std::string& desc,
00098                        const std::string& typeDesc,
00099                      DtCmdLine::CmdLineInterface& parser,
00100                      bool ignoreable = false,
00101                        DtCmdLine::Visitor* v = NULL );
00102 
00116       ReplacedUnlabeledMultiArg( const std::string& name,
00117                      const std::string& desc,
00118                      const std::vector<T>& allowed,
00119                      bool ignoreable = false,
00120                      DtCmdLine::Visitor* v = NULL );
00121 
00136       ReplacedUnlabeledMultiArg( const std::string& name,
00137                      const std::string& desc,
00138                      const std::vector<T>& allowed,
00139                      DtCmdLine::CmdLineInterface& parser,
00140                      bool ignoreable = false,
00141                      DtCmdLine::Visitor* v = NULL );
00142 
00151       virtual bool processArg(int* i, std::vector<std::string>& args);
00152 
00157       virtual std::string shortID(const std::string& val) const;
00158 
00163       virtual std::string longID(const std::string& val) const;
00164 
00169       virtual void addToList( std::list<DtCmdLine::Arg*>& argList ) const;
00170 };
00171 
00172 template<class T>
00173 ReplacedUnlabeledMultiArg<T>::ReplacedUnlabeledMultiArg(const std::string& name,
00174                                     const std::string& desc,
00175                                    const std::string& typeDesc,
00176                               bool ignoreable,
00177                                    DtCmdLine::Visitor* v)
00178 : DtCmdLine::MultiArg<T>("", name, desc,  false, typeDesc, v)
00179 {
00180    _ignoreable = ignoreable;
00181 }
00182 
00183 template<class T>
00184 ReplacedUnlabeledMultiArg<T>::ReplacedUnlabeledMultiArg(const std::string& name,
00185                                     const std::string& desc,
00186                                    const std::string& typeDesc,
00187                               DtCmdLine::CmdLineInterface& parser,
00188                               bool ignoreable,
00189                                    DtCmdLine::Visitor* v)
00190 : DtCmdLine::MultiArg<T>("", name, desc,  false, typeDesc, v)
00191 {
00192    _ignoreable = ignoreable;
00193    parser.add( this );
00194 }
00195 
00196 
00197 template<class T>
00198 ReplacedUnlabeledMultiArg<T>::ReplacedUnlabeledMultiArg(const std::string& name,
00199                                     const std::string& desc,
00200                                    const std::vector<T>& allowed,
00201                               bool ignoreable,
00202                                    DtCmdLine::Visitor* v)
00203 : DtCmdLine::MultiArg<T>("", name, desc,  false, allowed, v)
00204 {
00205    _ignoreable = ignoreable;
00206 }
00207 
00208 template<class T>
00209 ReplacedUnlabeledMultiArg<T>::ReplacedUnlabeledMultiArg(const std::string& name,
00210                                     const std::string& desc,
00211                                    const std::vector<T>& allowed,
00212                               DtCmdLine::CmdLineInterface& parser,
00213                               bool ignoreable,
00214                                    DtCmdLine::Visitor* v)
00215 : DtCmdLine::MultiArg<T>("", name, desc,  false, allowed, v)
00216 {
00217    _ignoreable = ignoreable;
00218    parser.add( this );
00219 }
00220 
00221 
00222 template<class T>
00223 bool ReplacedUnlabeledMultiArg<T>::processArg(int *i, std::vector<std::string>& args)
00224 {
00225 
00226    if ( _hasBlanks( args[*i] ) )
00227       return false;
00228 
00230 
00231    _extractValue( args[*i] );
00232    return true;
00233 }
00234 
00235 template<class T>
00236 std::string ReplacedUnlabeledMultiArg<T>::shortID(const std::string& val) const
00237 {
00238    std::string id = "<" + _typeDesc + "> ...";
00239 
00240    return id;
00241 }
00242 
00243 template<class T>
00244 std::string ReplacedUnlabeledMultiArg<T>::longID(const std::string& val) const
00245 {
00246    std::string id = "<" + _typeDesc + ">  (accepted multiple times)";
00247 
00248    return id;
00249 }
00250 
00259 
00260 template<class T>
00261 void ReplacedUnlabeledMultiArg<T>::addToList( std::list<DtCmdLine::Arg*>& argList ) const
00262 {
00263    argList.push_back( (DtCmdLine::Arg*)this );
00264 }
00265 
00266 }
00267 
00268 #endif

Document ID: Generated on Tue Oct 11 19:41:03 EDT 2011 from SVN revision 107422
Copyright © 2005-2011 VT MÄK Inc. All Rights Reserved (www.mak.com)