Changeset 1515 for trunk/third_party/tclap/SwitchArg.h
- Timestamp:
- 24/08/10 11:23:06 (21 months ago)
- File:
-
- 1 edited
-
trunk/third_party/tclap/SwitchArg.h (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/third_party/tclap/SwitchArg.h
r857 r1515 46 46 bool _value; 47 47 48 /** 49 * Used to support the reset() method so that ValueArg can be 50 * reset to their constructed value. 51 */ 52 bool _default; 48 53 49 54 public: … … 64 69 const std::string& name, 65 70 const std::string& desc, 66 bool def ,71 bool def = false, 67 72 Visitor* v = NULL); 68 73 … … 84 89 const std::string& name, 85 90 const std::string& desc, 86 bool def,87 91 CmdLineInterface& parser, 92 bool def = false, 88 93 Visitor* v = NULL); 89 94 … … 109 114 */ 110 115 bool getValue(); 116 117 virtual void reset(); 118 111 119 }; 112 120 … … 117 125 const std::string& name, 118 126 const std::string& desc, 119 bool _default,127 bool default_val, 120 128 Visitor* v ) 121 129 : Arg(flag, name, desc, false, false, v), 122 _value( _default ) 130 _value( default_val ), 131 _default( default_val ) 123 132 { } 124 133 … … 126 135 const std::string& name, 127 136 const std::string& desc, 128 bool _default,129 137 CmdLineInterface& parser, 138 bool default_val, 130 139 Visitor* v ) 131 140 : Arg(flag, name, desc, false, false, v), 132 _value( _default ) 141 _value( default_val ), 142 _default(default_val) 133 143 { 134 144 parser.add( this ); … … 140 150 { 141 151 // 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] ) 143 154 return false; 144 155 … … 148 159 return false; 149 160 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 150 165 // ok, we're not specifying a ValueArg, so we know that we have 151 166 // a combined switch list. 152 167 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] ) 154 171 { 155 172 // update the combined switches so this one is no longer present … … 180 197 ret = true; 181 198 182 if ( _alreadySet )199 if ( _alreadySet || ( !ret && combinedSwitchesMatch( args[*i] ) ) ) 183 200 throw(CmdLineParseException("Argument already set!", toString())); 184 201 … … 198 215 } 199 216 217 inline void SwitchArg::reset() 218 { 219 Arg::reset(); 220 _value = _default; 221 } 200 222 ////////////////////////////////////////////////////////////////////// 201 223 //End SwitchArg.cpp
Note: See TracChangeset
for help on using the changeset viewer.
