Ignore:
Timestamp:
24/08/10 11:23:06 (21 months ago)
Author:
Freddie Akeroyd
Message:

Update to tclap 1.2.0 from http://tclap.sourceforge.net/
Refs #244

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/third_party/tclap/SwitchArg.h

    r857 r1515  
    4646                bool _value; 
    4747 
     48                /** 
     49                 * Used to support the reset() method so that ValueArg can be 
     50                 * reset to their constructed value. 
     51                 */ 
     52        bool _default; 
    4853 
    4954        public: 
     
    6469                              const std::string& name,  
    6570                              const std::string& desc, 
    66                               bool def, 
     71                              bool def = false, 
    6772                                  Visitor* v = NULL); 
    6873 
     
    8489                              const std::string& name,  
    8590                              const std::string& desc, 
    86                               bool def, 
    8791                                  CmdLineInterface& parser, 
     92                              bool def = false, 
    8893                                  Visitor* v = NULL); 
    8994                                   
     
    109114                 */ 
    110115                bool getValue(); 
     116                 
     117                virtual void reset(); 
     118 
    111119}; 
    112120 
     
    117125                                 const std::string& name,  
    118126                                 const std::string& desc,  
    119                          bool _default, 
     127                         bool default_val, 
    120128                                         Visitor* v ) 
    121129: Arg(flag, name, desc, false, false, v), 
    122   _value( _default ) 
     130  _value( default_val ), 
     131  _default( default_val ) 
    123132{ } 
    124133 
     
    126135                                        const std::string& name,  
    127136                                        const std::string& desc,  
    128                                         bool _default, 
    129137                                        CmdLineInterface& parser, 
     138                                        bool default_val, 
    130139                                        Visitor* v ) 
    131140: Arg(flag, name, desc, false, false, v), 
    132   _value( _default ) 
     141  _value( default_val ), 
     142  _default(default_val) 
    133143{  
    134144        parser.add( this ); 
     
    140150{ 
    141151        // make sure this is actually a combined switch 
    142         if ( combinedSwitches[0] != Arg::flagStartString()[0] ) 
     152        if ( combinedSwitches.length() > 0 && 
     153             combinedSwitches[0] != Arg::flagStartString()[0] ) 
    143154                return false; 
    144155 
     
    148159                return false; 
    149160 
     161        // make sure the delimiter isn't in the string  
     162        if ( combinedSwitches.find_first_of( Arg::delimiter() ) != std::string::npos ) 
     163                return false; 
     164 
    150165        // ok, we're not specifying a ValueArg, so we know that we have 
    151166        // a combined switch list.   
    152167        for ( unsigned int i = 1; i < combinedSwitches.length(); i++ ) 
    153                 if ( combinedSwitches[i] == _flag[0] )  
     168                if ( _flag.length() > 0 &&  
     169                     combinedSwitches[i] == _flag[0] && 
     170                     _flag[0] != Arg::flagStartString()[0] )  
    154171                { 
    155172                        // update the combined switches so this one is no longer present 
     
    180197                        ret = true; 
    181198 
    182                 if ( _alreadySet ) 
     199                if ( _alreadySet || ( !ret && combinedSwitchesMatch( args[*i] ) ) ) 
    183200                        throw(CmdLineParseException("Argument already set!", toString()));       
    184201 
     
    198215} 
    199216 
     217inline void SwitchArg::reset() 
     218{ 
     219        Arg::reset(); 
     220        _value = _default;   
     221} 
    200222////////////////////////////////////////////////////////////////////// 
    201223//End SwitchArg.cpp 
Note: See TracChangeset for help on using the changeset viewer.