<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> <title>tclap: ValueArg.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.0 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>ValueArg.h</h1><a href="ValueArg_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/****************************************************************************** </span> <a name="l00002"></a>00002 <span class="comment"> * </span> <a name="l00003"></a>00003 <span class="comment"> * file: ValueArg.h</span> <a name="l00004"></a>00004 <span class="comment"> * </span> <a name="l00005"></a>00005 <span class="comment"> * Copyright (c) 2003, Michael E. Smoot .</span> <a name="l00006"></a>00006 <span class="comment"> * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.</span> <a name="l00007"></a>00007 <span class="comment"> * All rights reverved.</span> <a name="l00008"></a>00008 <span class="comment"> * </span> <a name="l00009"></a>00009 <span class="comment"> * See the file COPYING in the top directory of this distribution for</span> <a name="l00010"></a>00010 <span class="comment"> * more information.</span> <a name="l00011"></a>00011 <span class="comment"> * </span> <a name="l00012"></a>00012 <span class="comment"> * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS </span> <a name="l00013"></a>00013 <span class="comment"> * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, </span> <a name="l00014"></a>00014 <span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL </span> <a name="l00015"></a>00015 <span class="comment"> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER </span> <a name="l00016"></a>00016 <span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING </span> <a name="l00017"></a>00017 <span class="comment"> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER </span> <a name="l00018"></a>00018 <span class="comment"> * DEALINGS IN THE SOFTWARE. </span> <a name="l00019"></a>00019 <span class="comment"> * </span> <a name="l00020"></a>00020 <span class="comment"> *****************************************************************************/</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="preprocessor">#ifndef TCLAP_VALUE_ARGUMENT_H</span> <a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#define TCLAP_VALUE_ARGUMENT_H</span> <a name="l00025"></a>00025 <span class="preprocessor"></span> <a name="l00026"></a>00026 <span class="preprocessor">#include <string></span> <a name="l00027"></a>00027 <span class="preprocessor">#include <vector></span> <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="preprocessor">#include <<a class="code" href="Arg_8h.html">tclap/Arg.h</a>></span> <a name="l00030"></a>00030 <span class="preprocessor">#include <<a class="code" href="Constraint_8h.html">tclap/Constraint.h</a>></span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="keyword">namespace </span>TCLAP { <a name="l00033"></a>00033 <a name="l00042"></a>00042 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00043"></a><a class="code" href="classTCLAP_1_1ValueArg.html">00043</a> <span class="keyword">class </span><a class="code" href="classTCLAP_1_1ValueArg.html" title="The basic labeled argument that parses a value.">ValueArg</a> : <span class="keyword">public</span> <a class="code" href="classTCLAP_1_1Arg.html" title="A virtual base class that defines the essential data for all arguments.">Arg</a> <a name="l00044"></a>00044 { <a name="l00045"></a>00045 <span class="keyword">protected</span>: <a name="l00046"></a>00046 <a name="l00052"></a><a class="code" href="classTCLAP_1_1ValueArg.html#a45d5fdfce5865c02e6663f7438d485c7">00052</a> T <a class="code" href="classTCLAP_1_1ValueArg.html#a45d5fdfce5865c02e6663f7438d485c7" title="The value parsed from the command line.">_value</a>; <a name="l00053"></a>00053 <a name="l00058"></a><a class="code" href="classTCLAP_1_1ValueArg.html#a118e3a7932700a8e3626d8f9ee2e0c95">00058</a> T <a class="code" href="classTCLAP_1_1ValueArg.html#a118e3a7932700a8e3626d8f9ee2e0c95" title="Used to support the reset() method so that ValueArg can be reset to their constructed...">_default</a>; <a name="l00059"></a>00059 <a name="l00067"></a><a class="code" href="classTCLAP_1_1ValueArg.html#a78c5e5b67ce4bcebb57c886d9aa49259">00067</a> std::string <a class="code" href="classTCLAP_1_1ValueArg.html#a78c5e5b67ce4bcebb57c886d9aa49259" title="A human readable description of the type to be parsed.">_typeDesc</a>; <a name="l00068"></a>00068 <a name="l00072"></a><a class="code" href="classTCLAP_1_1ValueArg.html#aa383908cff37688cf7493d46c840d03b">00072</a> <a class="code" href="classTCLAP_1_1Constraint.html" title="The interface that defines the interaction between the Arg and Constraint.">Constraint<T></a>* <a class="code" href="classTCLAP_1_1ValueArg.html#aa383908cff37688cf7493d46c840d03b" title="A Constraint this Arg must conform to.">_constraint</a>; <a name="l00073"></a>00073 <a name="l00080"></a>00080 <span class="keywordtype">void</span> <a class="code" href="classTCLAP_1_1ValueArg.html#af0ecdb6537febfcaa322e7131d2b3bf8" title="Extracts the value from the string.">_extractValue</a>( <span class="keyword">const</span> std::string& val ); <a name="l00081"></a>00081 <a name="l00082"></a>00082 <span class="keyword">public</span>: <a name="l00083"></a>00083 <a name="l00107"></a>00107 <a class="code" href="classTCLAP_1_1ValueArg.html#ab2818435a1749bee3233b1f364dabf09" title="Labeled ValueArg constructor.">ValueArg</a>( <span class="keyword">const</span> std::string& flag, <a name="l00108"></a>00108 <span class="keyword">const</span> std::string& name, <a name="l00109"></a>00109 <span class="keyword">const</span> std::string& desc, <a name="l00110"></a>00110 <span class="keywordtype">bool</span> req, <a name="l00111"></a>00111 T value, <a name="l00112"></a>00112 <span class="keyword">const</span> std::string& typeDesc, <a name="l00113"></a>00113 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL); <a name="l00114"></a>00114 <a name="l00115"></a>00115 <a name="l00140"></a>00140 <a class="code" href="classTCLAP_1_1ValueArg.html#ab2818435a1749bee3233b1f364dabf09" title="Labeled ValueArg constructor.">ValueArg</a>( <span class="keyword">const</span> std::string& flag, <a name="l00141"></a>00141 <span class="keyword">const</span> std::string& name, <a name="l00142"></a>00142 <span class="keyword">const</span> std::string& desc, <a name="l00143"></a>00143 <span class="keywordtype">bool</span> req, <a name="l00144"></a>00144 T value, <a name="l00145"></a>00145 <span class="keyword">const</span> std::string& typeDesc, <a name="l00146"></a>00146 <a class="code" href="classTCLAP_1_1CmdLineInterface.html" title="The base class that manages the command line definition and passes along the parsing...">CmdLineInterface</a>& parser, <a name="l00147"></a>00147 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL ); <a name="l00148"></a>00148 <a name="l00171"></a>00171 <a class="code" href="classTCLAP_1_1ValueArg.html#ab2818435a1749bee3233b1f364dabf09" title="Labeled ValueArg constructor.">ValueArg</a>( <span class="keyword">const</span> std::string& flag, <a name="l00172"></a>00172 <span class="keyword">const</span> std::string& name, <a name="l00173"></a>00173 <span class="keyword">const</span> std::string& desc, <a name="l00174"></a>00174 <span class="keywordtype">bool</span> req, <a name="l00175"></a>00175 T value, <a name="l00176"></a>00176 <a class="code" href="classTCLAP_1_1Constraint.html" title="The interface that defines the interaction between the Arg and Constraint.">Constraint<T></a>* constraint, <a name="l00177"></a>00177 <a class="code" href="classTCLAP_1_1CmdLineInterface.html" title="The base class that manages the command line definition and passes along the parsing...">CmdLineInterface</a>& parser, <a name="l00178"></a>00178 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL ); <a name="l00179"></a>00179 <a name="l00201"></a>00201 <a class="code" href="classTCLAP_1_1ValueArg.html#ab2818435a1749bee3233b1f364dabf09" title="Labeled ValueArg constructor.">ValueArg</a>( <span class="keyword">const</span> std::string& flag, <a name="l00202"></a>00202 <span class="keyword">const</span> std::string& name, <a name="l00203"></a>00203 <span class="keyword">const</span> std::string& desc, <a name="l00204"></a>00204 <span class="keywordtype">bool</span> req, <a name="l00205"></a>00205 T value, <a name="l00206"></a>00206 <a class="code" href="classTCLAP_1_1Constraint.html" title="The interface that defines the interaction between the Arg and Constraint.">Constraint<T></a>* constraint, <a name="l00207"></a>00207 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL ); <a name="l00208"></a>00208 <a name="l00218"></a>00218 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTCLAP_1_1ValueArg.html#a71e6ee7c7324724b6fc067c5ffe31160" title="Handles the processing of the argument.">processArg</a>(<span class="keywordtype">int</span>* i, std::vector<std::string>& args); <a name="l00219"></a>00219 <a name="l00223"></a>00223 T& <a class="code" href="classTCLAP_1_1ValueArg.html#a46900b79f4549a37003120be284adfee" title="Returns the value of the argument.">getValue</a>() ; <a name="l00224"></a>00224 <a name="l00229"></a>00229 <span class="keyword">virtual</span> std::string <a class="code" href="classTCLAP_1_1ValueArg.html#abb1eb22814d0a0da49c5f8bb57362d09" title="Specialization of shortID.">shortID</a>(<span class="keyword">const</span> std::string& val = <span class="stringliteral">"val"</span>) <span class="keyword">const</span>; <a name="l00230"></a>00230 <a name="l00235"></a>00235 <span class="keyword">virtual</span> std::string <a class="code" href="classTCLAP_1_1ValueArg.html#a586d25c04c39ddf0e589605d79f72f8a" title="Specialization of longID.">longID</a>(<span class="keyword">const</span> std::string& val = <span class="stringliteral">"val"</span>) <span class="keyword">const</span>; <a name="l00236"></a>00236 <a name="l00237"></a>00237 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classTCLAP_1_1ValueArg.html#a1bc480b71c4d8ac3646e796af8fb6e14" title="Clears the Arg object and allows it to be reused by new command lines.">reset</a>() ; <a name="l00238"></a>00238 <a name="l00239"></a>00239 <span class="keyword">private</span>: <a name="l00243"></a>00243 <a class="code" href="classTCLAP_1_1ValueArg.html" title="The basic labeled argument that parses a value.">ValueArg<T></a>(<span class="keyword">const</span> <a class="code" href="classTCLAP_1_1ValueArg.html" title="The basic labeled argument that parses a value.">ValueArg<T></a>& rhs); <a name="l00244"></a>00244 <a class="code" href="classTCLAP_1_1ValueArg.html" title="The basic labeled argument that parses a value.">ValueArg<T></a>& operator=(<span class="keyword">const</span> <a class="code" href="classTCLAP_1_1ValueArg.html" title="The basic labeled argument that parses a value.">ValueArg<T></a>& rhs); <a name="l00245"></a>00245 }; <a name="l00246"></a>00246 <a name="l00247"></a>00247 <a name="l00251"></a>00251 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00252"></a><a class="code" href="classTCLAP_1_1ValueArg.html#ab2818435a1749bee3233b1f364dabf09">00252</a> <a class="code" href="classTCLAP_1_1ValueArg.html#ab2818435a1749bee3233b1f364dabf09" title="Labeled ValueArg constructor.">ValueArg<T>::ValueArg</a>(<span class="keyword">const</span> std::string& flag, <a name="l00253"></a>00253 <span class="keyword">const</span> std::string& name, <a name="l00254"></a>00254 <span class="keyword">const</span> std::string& desc, <a name="l00255"></a>00255 <span class="keywordtype">bool</span> req, <a name="l00256"></a>00256 T val, <a name="l00257"></a>00257 <span class="keyword">const</span> std::string& typeDesc, <a name="l00258"></a>00258 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v) <a name="l00259"></a>00259 : <a class="code" href="classTCLAP_1_1Arg.html" title="A virtual base class that defines the essential data for all arguments.">Arg</a>(flag, name, desc, req, true, v), <a name="l00260"></a>00260 _value( val ), <a name="l00261"></a>00261 _default( val ), <a name="l00262"></a>00262 _typeDesc( typeDesc ), <a name="l00263"></a>00263 _constraint( NULL ) <a name="l00264"></a>00264 { } <a name="l00265"></a>00265 <a name="l00266"></a>00266 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00267"></a><a class="code" href="classTCLAP_1_1ValueArg.html#a3b34856ee6613ccabe60d2c5a6cc714f">00267</a> <a class="code" href="classTCLAP_1_1ValueArg.html#ab2818435a1749bee3233b1f364dabf09" title="Labeled ValueArg constructor.">ValueArg<T>::ValueArg</a>(<span class="keyword">const</span> std::string& flag, <a name="l00268"></a>00268 <span class="keyword">const</span> std::string& name, <a name="l00269"></a>00269 <span class="keyword">const</span> std::string& desc, <a name="l00270"></a>00270 <span class="keywordtype">bool</span> req, <a name="l00271"></a>00271 T val, <a name="l00272"></a>00272 <span class="keyword">const</span> std::string& typeDesc, <a name="l00273"></a>00273 <a class="code" href="classTCLAP_1_1CmdLineInterface.html" title="The base class that manages the command line definition and passes along the parsing...">CmdLineInterface</a>& parser, <a name="l00274"></a>00274 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v) <a name="l00275"></a>00275 : <a class="code" href="classTCLAP_1_1Arg.html" title="A virtual base class that defines the essential data for all arguments.">Arg</a>(flag, name, desc, req, true, v), <a name="l00276"></a>00276 _value( val ), <a name="l00277"></a>00277 _default( val ), <a name="l00278"></a>00278 _typeDesc( typeDesc ), <a name="l00279"></a>00279 _constraint( NULL ) <a name="l00280"></a>00280 { <a name="l00281"></a>00281 parser.<a class="code" href="classTCLAP_1_1CmdLineInterface.html#a13b29ab754c030185e58f779dc355631" title="Adds an argument to the list of arguments to be parsed.">add</a>( <span class="keyword">this</span> ); <a name="l00282"></a>00282 } <a name="l00283"></a>00283 <a name="l00284"></a>00284 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00285"></a><a class="code" href="classTCLAP_1_1ValueArg.html#a152c816b8bdb19efada14e8aec9bd05c">00285</a> <a class="code" href="classTCLAP_1_1ValueArg.html#ab2818435a1749bee3233b1f364dabf09" title="Labeled ValueArg constructor.">ValueArg<T>::ValueArg</a>(<span class="keyword">const</span> std::string& flag, <a name="l00286"></a>00286 <span class="keyword">const</span> std::string& name, <a name="l00287"></a>00287 <span class="keyword">const</span> std::string& desc, <a name="l00288"></a>00288 <span class="keywordtype">bool</span> req, <a name="l00289"></a>00289 T val, <a name="l00290"></a>00290 <a class="code" href="classTCLAP_1_1Constraint.html" title="The interface that defines the interaction between the Arg and Constraint.">Constraint<T></a>* constraint, <a name="l00291"></a>00291 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v) <a name="l00292"></a>00292 : <a class="code" href="classTCLAP_1_1Arg.html" title="A virtual base class that defines the essential data for all arguments.">Arg</a>(flag, name, desc, req, true, v), <a name="l00293"></a>00293 _value( val ), <a name="l00294"></a>00294 _default( val ), <a name="l00295"></a>00295 _typeDesc( constraint->shortID() ), <a name="l00296"></a>00296 _constraint( constraint ) <a name="l00297"></a>00297 { } <a name="l00298"></a>00298 <a name="l00299"></a>00299 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00300"></a><a class="code" href="classTCLAP_1_1ValueArg.html#aa054e7649b5d9db4861eed344a8f5840">00300</a> <a class="code" href="classTCLAP_1_1ValueArg.html#ab2818435a1749bee3233b1f364dabf09" title="Labeled ValueArg constructor.">ValueArg<T>::ValueArg</a>(<span class="keyword">const</span> std::string& flag, <a name="l00301"></a>00301 <span class="keyword">const</span> std::string& name, <a name="l00302"></a>00302 <span class="keyword">const</span> std::string& desc, <a name="l00303"></a>00303 <span class="keywordtype">bool</span> req, <a name="l00304"></a>00304 T val, <a name="l00305"></a>00305 <a class="code" href="classTCLAP_1_1Constraint.html" title="The interface that defines the interaction between the Arg and Constraint.">Constraint<T></a>* constraint, <a name="l00306"></a>00306 <a class="code" href="classTCLAP_1_1CmdLineInterface.html" title="The base class that manages the command line definition and passes along the parsing...">CmdLineInterface</a>& parser, <a name="l00307"></a>00307 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v) <a name="l00308"></a>00308 : <a class="code" href="classTCLAP_1_1Arg.html" title="A virtual base class that defines the essential data for all arguments.">Arg</a>(flag, name, desc, req, true, v), <a name="l00309"></a>00309 _value( val ), <a name="l00310"></a>00310 _default( val ), <a name="l00311"></a>00311 _typeDesc( constraint->shortID() ), <a name="l00312"></a>00312 _constraint( constraint ) <a name="l00313"></a>00313 { <a name="l00314"></a>00314 parser.<a class="code" href="classTCLAP_1_1CmdLineInterface.html#a13b29ab754c030185e58f779dc355631" title="Adds an argument to the list of arguments to be parsed.">add</a>( <span class="keyword">this</span> ); <a name="l00315"></a>00315 } <a name="l00316"></a>00316 <a name="l00317"></a>00317 <a name="l00321"></a>00321 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00322"></a><a class="code" href="classTCLAP_1_1ValueArg.html#a46900b79f4549a37003120be284adfee">00322</a> T& <a class="code" href="classTCLAP_1_1ValueArg.html#a46900b79f4549a37003120be284adfee" title="Returns the value of the argument.">ValueArg<T>::getValue</a>() { <span class="keywordflow">return</span> <a class="code" href="classTCLAP_1_1ValueArg.html#a45d5fdfce5865c02e6663f7438d485c7" title="The value parsed from the command line.">_value</a>; } <a name="l00323"></a>00323 <a name="l00327"></a>00327 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00328"></a><a class="code" href="classTCLAP_1_1ValueArg.html#a71e6ee7c7324724b6fc067c5ffe31160">00328</a> <span class="keywordtype">bool</span> <a class="code" href="classTCLAP_1_1ValueArg.html#a71e6ee7c7324724b6fc067c5ffe31160" title="Handles the processing of the argument.">ValueArg<T>::processArg</a>(<span class="keywordtype">int</span> *i, std::vector<std::string>& args) <a name="l00329"></a>00329 { <a name="l00330"></a>00330 <span class="keywordflow">if</span> ( <a class="code" href="classTCLAP_1_1Arg.html#a9832bb7564f4ab472bd51b7b1bbc683f" title="Whether this argument can be ignored, if desired.">_ignoreable</a> && <a class="code" href="classTCLAP_1_1Arg.html#a4d412155b8f9b4956e64e91c48e55a3b" title="Whether to ignore the rest.">Arg::ignoreRest</a>() ) <a name="l00331"></a>00331 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00332"></a>00332 <a name="l00333"></a>00333 <span class="keywordflow">if</span> ( <a class="code" href="classTCLAP_1_1Arg.html#a2eb0ffefe163218bdc8b4b7a33a974a7" title="Checks whether a given string has blank chars, indicating that it is a combined SwitchArg...">_hasBlanks</a>( args[*i] ) ) <a name="l00334"></a>00334 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00335"></a>00335 <a name="l00336"></a>00336 std::string flag = args[*i]; <a name="l00337"></a>00337 <a name="l00338"></a>00338 std::string value = <span class="stringliteral">""</span>; <a name="l00339"></a>00339 <a class="code" href="classTCLAP_1_1Arg.html#a54595328e81f5fb77859563690faab25" title="Trims a value off of the flag.">trimFlag</a>( flag, value ); <a name="l00340"></a>00340 <a name="l00341"></a>00341 <span class="keywordflow">if</span> ( <a class="code" href="classTCLAP_1_1Arg.html#aac37b1b734b477e5d16f2037dba9c125" title="A method that tests whether a string matches this argument.">argMatches</a>( flag ) ) <a name="l00342"></a>00342 { <a name="l00343"></a>00343 <span class="keywordflow">if</span> ( <a class="code" href="classTCLAP_1_1Arg.html#a829e32129857d2683e5791a5df1208ec" title="Indicates whether the argument has been set.">_alreadySet</a> ) <a name="l00344"></a>00344 { <a name="l00345"></a>00345 <span class="keywordflow">if</span> ( <a class="code" href="classTCLAP_1_1Arg.html#ab413bd1d8a7ecf3c89672ee23ef791ba" title="Indicates that the arg was set as part of an XOR and not on the command line.">_xorSet</a> ) <a name="l00346"></a>00346 <span class="keywordflow">throw</span>( <a class="code" href="classTCLAP_1_1CmdLineParseException.html" title="Thrown from CmdLine when the arguments on the command line are not properly specified...">CmdLineParseException</a>( <a name="l00347"></a>00347 <span class="stringliteral">"Mutually exclusive argument already set!"</span>, <a name="l00348"></a>00348 <a class="code" href="classTCLAP_1_1Arg.html#ac98a357568c21f0eb6ca2220b8a3d4a2" title="Returns a simple string representation of the argument.">toString</a>()) ); <a name="l00349"></a>00349 <span class="keywordflow">else</span> <a name="l00350"></a>00350 <span class="keywordflow">throw</span>( <a class="code" href="classTCLAP_1_1CmdLineParseException.html" title="Thrown from CmdLine when the arguments on the command line are not properly specified...">CmdLineParseException</a>(<span class="stringliteral">"Argument already set!"</span>, <a name="l00351"></a>00351 <a class="code" href="classTCLAP_1_1Arg.html#ac98a357568c21f0eb6ca2220b8a3d4a2" title="Returns a simple string representation of the argument.">toString</a>()) ); <a name="l00352"></a>00352 } <a name="l00353"></a>00353 <a name="l00354"></a>00354 <span class="keywordflow">if</span> ( <a class="code" href="classTCLAP_1_1Arg.html#aadef6ca7e40f5b3d3fd03186976aea7e" title="The delimiter that separates an argument flag/name from the value.">Arg::delimiter</a>() != <span class="charliteral">' '</span> && value == <span class="stringliteral">""</span> ) <a name="l00355"></a>00355 <span class="keywordflow">throw</span>( <a class="code" href="classTCLAP_1_1ArgParseException.html" title="Thrown from within the child Arg classes when it fails to properly parse the argument...">ArgParseException</a>( <a name="l00356"></a>00356 <span class="stringliteral">"Couldn't find delimiter for this argument!"</span>, <a name="l00357"></a>00357 <a class="code" href="classTCLAP_1_1Arg.html#ac98a357568c21f0eb6ca2220b8a3d4a2" title="Returns a simple string representation of the argument.">toString</a>() ) ); <a name="l00358"></a>00358 <a name="l00359"></a>00359 <span class="keywordflow">if</span> ( value == <span class="stringliteral">""</span> ) <a name="l00360"></a>00360 { <a name="l00361"></a>00361 (*i)++; <a name="l00362"></a>00362 <span class="keywordflow">if</span> ( static_cast<unsigned int>(*i) < args.size() ) <a name="l00363"></a>00363 <a class="code" href="classTCLAP_1_1ValueArg.html#af0ecdb6537febfcaa322e7131d2b3bf8" title="Extracts the value from the string.">_extractValue</a>( args[*i] ); <a name="l00364"></a>00364 <span class="keywordflow">else</span> <a name="l00365"></a>00365 <span class="keywordflow">throw</span>( <a class="code" href="classTCLAP_1_1ArgParseException.html" title="Thrown from within the child Arg classes when it fails to properly parse the argument...">ArgParseException</a>(<span class="stringliteral">"Missing a value for this argument!"</span>, <a name="l00366"></a>00366 <a class="code" href="classTCLAP_1_1Arg.html#ac98a357568c21f0eb6ca2220b8a3d4a2" title="Returns a simple string representation of the argument.">toString</a>() ) ); <a name="l00367"></a>00367 } <a name="l00368"></a>00368 <span class="keywordflow">else</span> <a name="l00369"></a>00369 <a class="code" href="classTCLAP_1_1ValueArg.html#af0ecdb6537febfcaa322e7131d2b3bf8" title="Extracts the value from the string.">_extractValue</a>( value ); <a name="l00370"></a>00370 <a name="l00371"></a>00371 <a class="code" href="classTCLAP_1_1Arg.html#a829e32129857d2683e5791a5df1208ec" title="Indicates whether the argument has been set.">_alreadySet</a> = <span class="keyword">true</span>; <a name="l00372"></a>00372 <a class="code" href="classTCLAP_1_1Arg.html#aa963d0d4c8cb297e1f4cf74143bf6d1b" title="Performs the special handling described by the Vistitor.">_checkWithVisitor</a>(); <a name="l00373"></a>00373 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00374"></a>00374 } <a name="l00375"></a>00375 <span class="keywordflow">else</span> <a name="l00376"></a>00376 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00377"></a>00377 } <a name="l00378"></a>00378 <a name="l00382"></a>00382 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00383"></a><a class="code" href="classTCLAP_1_1ValueArg.html#abb1eb22814d0a0da49c5f8bb57362d09">00383</a> std::string <a class="code" href="classTCLAP_1_1ValueArg.html#abb1eb22814d0a0da49c5f8bb57362d09" title="Specialization of shortID.">ValueArg<T>::shortID</a>(<span class="keyword">const</span> std::string& val)<span class="keyword"> const</span> <a name="l00384"></a>00384 <span class="keyword"></span>{ <a name="l00385"></a>00385 <span class="keyword">static_cast<</span><span class="keywordtype">void</span><span class="keyword">></span>(val); <span class="comment">// Ignore input, don't warn</span> <a name="l00386"></a>00386 <span class="keywordflow">return</span> <a class="code" href="classTCLAP_1_1ValueArg.html#abb1eb22814d0a0da49c5f8bb57362d09" title="Specialization of shortID.">Arg::shortID</a>( <a class="code" href="classTCLAP_1_1ValueArg.html#a78c5e5b67ce4bcebb57c886d9aa49259" title="A human readable description of the type to be parsed.">_typeDesc</a> ); <a name="l00387"></a>00387 } <a name="l00388"></a>00388 <a name="l00392"></a>00392 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00393"></a><a class="code" href="classTCLAP_1_1ValueArg.html#a586d25c04c39ddf0e589605d79f72f8a">00393</a> std::string <a class="code" href="classTCLAP_1_1ValueArg.html#a586d25c04c39ddf0e589605d79f72f8a" title="Specialization of longID.">ValueArg<T>::longID</a>(<span class="keyword">const</span> std::string& val)<span class="keyword"> const</span> <a name="l00394"></a>00394 <span class="keyword"></span>{ <a name="l00395"></a>00395 <span class="keyword">static_cast<</span><span class="keywordtype">void</span><span class="keyword">></span>(val); <span class="comment">// Ignore input, don't warn</span> <a name="l00396"></a>00396 <span class="keywordflow">return</span> <a class="code" href="classTCLAP_1_1ValueArg.html#a586d25c04c39ddf0e589605d79f72f8a" title="Specialization of longID.">Arg::longID</a>( <a class="code" href="classTCLAP_1_1ValueArg.html#a78c5e5b67ce4bcebb57c886d9aa49259" title="A human readable description of the type to be parsed.">_typeDesc</a> ); <a name="l00397"></a>00397 } <a name="l00398"></a>00398 <a name="l00399"></a>00399 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00400"></a><a class="code" href="classTCLAP_1_1ValueArg.html#af0ecdb6537febfcaa322e7131d2b3bf8">00400</a> <span class="keywordtype">void</span> <a class="code" href="classTCLAP_1_1ValueArg.html#af0ecdb6537febfcaa322e7131d2b3bf8" title="Extracts the value from the string.">ValueArg<T>::_extractValue</a>( <span class="keyword">const</span> std::string& val ) <a name="l00401"></a>00401 { <a name="l00402"></a>00402 <span class="keywordflow">try</span> { <a name="l00403"></a>00403 <a class="code" href="namespaceTCLAP.html#a80473f9a24db31df0206504c2cdf0a8d">ExtractValue</a>(<a class="code" href="classTCLAP_1_1ValueArg.html#a45d5fdfce5865c02e6663f7438d485c7" title="The value parsed from the command line.">_value</a>, val, <span class="keyword">typename</span> <a class="code" href="structTCLAP_1_1ArgTraits.html" title="Arg traits are used to get compile type specialization when parsing argument values...">ArgTraits<T>::ValueCategory</a>()); <a name="l00404"></a>00404 } <span class="keywordflow">catch</span>( <a class="code" href="classTCLAP_1_1ArgParseException.html" title="Thrown from within the child Arg classes when it fails to properly parse the argument...">ArgParseException</a> &e) { <a name="l00405"></a>00405 <span class="keywordflow">throw</span> <a class="code" href="classTCLAP_1_1ArgParseException.html" title="Thrown from within the child Arg classes when it fails to properly parse the argument...">ArgParseException</a>(e.<a class="code" href="classTCLAP_1_1ArgException.html#a0656dab88a7129bc288821bacd653d08" title="Returns the error text.">error</a>(), <a class="code" href="classTCLAP_1_1Arg.html#ac98a357568c21f0eb6ca2220b8a3d4a2" title="Returns a simple string representation of the argument.">toString</a>()); <a name="l00406"></a>00406 } <a name="l00407"></a>00407 <a name="l00408"></a>00408 <span class="keywordflow">if</span> ( <a class="code" href="classTCLAP_1_1ValueArg.html#aa383908cff37688cf7493d46c840d03b" title="A Constraint this Arg must conform to.">_constraint</a> != NULL ) <a name="l00409"></a>00409 <span class="keywordflow">if</span> ( ! <a class="code" href="classTCLAP_1_1ValueArg.html#aa383908cff37688cf7493d46c840d03b" title="A Constraint this Arg must conform to.">_constraint</a>->check( <a class="code" href="classTCLAP_1_1ValueArg.html#a45d5fdfce5865c02e6663f7438d485c7" title="The value parsed from the command line.">_value</a> ) ) <a name="l00410"></a>00410 <span class="keywordflow">throw</span>( <a class="code" href="classTCLAP_1_1CmdLineParseException.html" title="Thrown from CmdLine when the arguments on the command line are not properly specified...">CmdLineParseException</a>( <span class="stringliteral">"Value '"</span> + val + <a name="l00411"></a>00411 + <span class="stringliteral">"' does not meet constraint: "</span> <a name="l00412"></a>00412 + <a class="code" href="classTCLAP_1_1ValueArg.html#aa383908cff37688cf7493d46c840d03b" title="A Constraint this Arg must conform to.">_constraint</a>->description(), <a name="l00413"></a>00413 <a class="code" href="classTCLAP_1_1Arg.html#ac98a357568c21f0eb6ca2220b8a3d4a2" title="Returns a simple string representation of the argument.">toString</a>() ) ); <a name="l00414"></a>00414 } <a name="l00415"></a>00415 <a name="l00416"></a>00416 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00417"></a><a class="code" href="classTCLAP_1_1ValueArg.html#a1bc480b71c4d8ac3646e796af8fb6e14">00417</a> <span class="keywordtype">void</span> <a class="code" href="classTCLAP_1_1ValueArg.html#a1bc480b71c4d8ac3646e796af8fb6e14" title="Clears the Arg object and allows it to be reused by new command lines.">ValueArg<T>::reset</a>() <a name="l00418"></a>00418 { <a name="l00419"></a>00419 <a class="code" href="classTCLAP_1_1ValueArg.html#a1bc480b71c4d8ac3646e796af8fb6e14" title="Clears the Arg object and allows it to be reused by new command lines.">Arg::reset</a>(); <a name="l00420"></a>00420 <a class="code" href="classTCLAP_1_1ValueArg.html#a45d5fdfce5865c02e6663f7438d485c7" title="The value parsed from the command line.">_value</a> = <a class="code" href="classTCLAP_1_1ValueArg.html#a118e3a7932700a8e3626d8f9ee2e0c95" title="Used to support the reset() method so that ValueArg can be reset to their constructed...">_default</a>; <a name="l00421"></a>00421 } <a name="l00422"></a>00422 <a name="l00423"></a>00423 } <span class="comment">// namespace TCLAP</span> <a name="l00424"></a>00424 <a name="l00425"></a>00425 <span class="preprocessor">#endif</span> </pre></div></div> <hr size="1"/><address style="text-align: right;"><small>Generated on Sat Apr 16 15:34:24 2011 for tclap by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.0 </small></address> </body> </html>
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 16129 | tjuricek |
Rename/move files again... this time to the hyphenated-approach. |
||
//guest/tjuricek/file_system_client/main/vendor/tclap-1.2.1/docs/html/ValueArg_8h_source.html | |||||
#1 | 16119 | tjuricek | Rename/move to meet workshop project conventions. | ||
//guest/tjuricek/fsclient/vendor/tclap-1.2.1/docs/html/ValueArg_8h_source.html | |||||
#1 | 16118 | tjuricek |
FSClient initial version: handles add, edit This is a proof-of-concept app that mirrors an existing Perforce workspace to handle running commands like "p4 add" and "p4 edit" automatically when your apps add and write files. See the readme for more information. |