<!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: MultiArg.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>MultiArg.h</h1><a href="MultiArg_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: MultiArg.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_MULTIPLE_ARGUMENT_H</span> <a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#define TCLAP_MULTIPLE_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="l00038"></a>00038 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00039"></a><a class="code" href="classTCLAP_1_1MultiArg.html">00039</a> <span class="keyword">class </span><a class="code" href="classTCLAP_1_1MultiArg.html" title="An argument that allows multiple values of type T to be specified.">MultiArg</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="l00040"></a>00040 { <a name="l00041"></a>00041 <span class="keyword">public</span>: <a name="l00042"></a><a class="code" href="classTCLAP_1_1MultiArg.html#adae435f03fdde769bca57327487aab78">00042</a> <span class="keyword">typedef</span> std::vector<T> <a class="code" href="classTCLAP_1_1MultiArg.html#adae435f03fdde769bca57327487aab78">container_type</a>; <a name="l00043"></a><a class="code" href="classTCLAP_1_1MultiArg.html#a34196784baca2bd5aa079d639d49a7ca">00043</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> container_type::iterator <a class="code" href="classTCLAP_1_1MultiArg.html#a34196784baca2bd5aa079d639d49a7ca">iterator</a>; <a name="l00044"></a><a class="code" href="classTCLAP_1_1MultiArg.html#a3f8e9e8f5dcc7d3e6a518f42134cf64f">00044</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> container_type::const_iterator <a class="code" href="classTCLAP_1_1MultiArg.html#a3f8e9e8f5dcc7d3e6a518f42134cf64f">const_iterator</a>; <a name="l00045"></a>00045 <a name="l00046"></a>00046 <span class="keyword">protected</span>: <a name="l00047"></a>00047 <a name="l00051"></a><a class="code" href="classTCLAP_1_1MultiArg.html#aabcab153e09608343713a6ffef431783">00051</a> std::vector<T> <a class="code" href="classTCLAP_1_1MultiArg.html#aabcab153e09608343713a6ffef431783" title="The list of values parsed from the CmdLine.">_values</a>; <a name="l00052"></a>00052 <a name="l00056"></a><a class="code" href="classTCLAP_1_1MultiArg.html#a0f6a2b04fe15d1ede95165fc6e1949e8">00056</a> std::string <a class="code" href="classTCLAP_1_1MultiArg.html#a0f6a2b04fe15d1ede95165fc6e1949e8" title="The description of type T to be used in the usage.">_typeDesc</a>; <a name="l00057"></a>00057 <a name="l00061"></a><a class="code" href="classTCLAP_1_1MultiArg.html#afc754048b66bc3a251268947273ea906">00061</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_1MultiArg.html#afc754048b66bc3a251268947273ea906" title="A list of constraint on this Arg.">_constraint</a>; <a name="l00062"></a>00062 <a name="l00069"></a>00069 <span class="keywordtype">void</span> <a class="code" href="classTCLAP_1_1MultiArg.html#a26cbf5e86ac66d876f9285f1fda22470" title="Extracts the value from the string.">_extractValue</a>( <span class="keyword">const</span> std::string& val ); <a name="l00070"></a>00070 <a name="l00074"></a><a class="code" href="classTCLAP_1_1MultiArg.html#a93a3ef586f763d46839c0e737689b85f">00074</a> <span class="keywordtype">bool</span> <a class="code" href="classTCLAP_1_1MultiArg.html#a93a3ef586f763d46839c0e737689b85f" title="Used by XorHandler to decide whether to keep parsing for this arg.">_allowMore</a>; <a name="l00075"></a>00075 <a name="l00076"></a>00076 <span class="keyword">public</span>: <a name="l00077"></a>00077 <a name="l00095"></a>00095 <a class="code" href="classTCLAP_1_1MultiArg.html#a49b5437c7f06cd6864c07dc59814a953" title="Constructor.">MultiArg</a>( <span class="keyword">const</span> std::string& flag, <a name="l00096"></a>00096 <span class="keyword">const</span> std::string& name, <a name="l00097"></a>00097 <span class="keyword">const</span> std::string& desc, <a name="l00098"></a>00098 <span class="keywordtype">bool</span> req, <a name="l00099"></a>00099 <span class="keyword">const</span> std::string& typeDesc, <a name="l00100"></a>00100 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL); <a name="l00101"></a>00101 <a name="l00120"></a>00120 <a class="code" href="classTCLAP_1_1MultiArg.html#a49b5437c7f06cd6864c07dc59814a953" title="Constructor.">MultiArg</a>( <span class="keyword">const</span> std::string& flag, <a name="l00121"></a>00121 <span class="keyword">const</span> std::string& name, <a name="l00122"></a>00122 <span class="keyword">const</span> std::string& desc, <a name="l00123"></a>00123 <span class="keywordtype">bool</span> req, <a name="l00124"></a>00124 <span class="keyword">const</span> std::string& typeDesc, <a name="l00125"></a>00125 <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="l00126"></a>00126 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL ); <a name="l00127"></a>00127 <a name="l00143"></a>00143 <a class="code" href="classTCLAP_1_1MultiArg.html#a49b5437c7f06cd6864c07dc59814a953" title="Constructor.">MultiArg</a>( <span class="keyword">const</span> std::string& flag, <a name="l00144"></a>00144 <span class="keyword">const</span> std::string& name, <a name="l00145"></a>00145 <span class="keyword">const</span> std::string& desc, <a name="l00146"></a>00146 <span class="keywordtype">bool</span> req, <a name="l00147"></a>00147 <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="l00148"></a>00148 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL ); <a name="l00149"></a>00149 <a name="l00166"></a>00166 <a class="code" href="classTCLAP_1_1MultiArg.html#a49b5437c7f06cd6864c07dc59814a953" title="Constructor.">MultiArg</a>( <span class="keyword">const</span> std::string& flag, <a name="l00167"></a>00167 <span class="keyword">const</span> std::string& name, <a name="l00168"></a>00168 <span class="keyword">const</span> std::string& desc, <a name="l00169"></a>00169 <span class="keywordtype">bool</span> req, <a name="l00170"></a>00170 <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="l00171"></a>00171 <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="l00172"></a>00172 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL ); <a name="l00173"></a>00173 <a name="l00182"></a>00182 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTCLAP_1_1MultiArg.html#a344d3cf2128c510f92825e421ea667c7" title="Handles the processing of the argument.">processArg</a>(<span class="keywordtype">int</span>* i, std::vector<std::string>& args); <a name="l00183"></a>00183 <a name="l00188"></a>00188 <span class="keyword">const</span> std::vector<T>& <a class="code" href="classTCLAP_1_1MultiArg.html#aff4ff7f8d854dd668aaaf80511d8002b" title="Returns a vector of type T containing the values parsed from the command line.">getValue</a>(); <a name="l00189"></a>00189 <a name="l00194"></a><a class="code" href="classTCLAP_1_1MultiArg.html#a48058500cdc9ef8b9c2c9e6394ab499d">00194</a> <a class="code" href="classTCLAP_1_1MultiArg.html#a3f8e9e8f5dcc7d3e6a518f42134cf64f">const_iterator</a> <a class="code" href="classTCLAP_1_1MultiArg.html#a48058500cdc9ef8b9c2c9e6394ab499d" title="Returns an iterator over the values parsed from the command line.">begin</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTCLAP_1_1MultiArg.html#aabcab153e09608343713a6ffef431783" title="The list of values parsed from the CmdLine.">_values</a>.begin(); } <a name="l00195"></a>00195 <a name="l00200"></a><a class="code" href="classTCLAP_1_1MultiArg.html#ac30e414b799158ff6710fb1e7ce83aee">00200</a> <a class="code" href="classTCLAP_1_1MultiArg.html#a3f8e9e8f5dcc7d3e6a518f42134cf64f">const_iterator</a> <a class="code" href="classTCLAP_1_1MultiArg.html#ac30e414b799158ff6710fb1e7ce83aee" title="Returns the end of the values parsed from the command line.">end</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTCLAP_1_1MultiArg.html#aabcab153e09608343713a6ffef431783" title="The list of values parsed from the CmdLine.">_values</a>.end(); } <a name="l00201"></a>00201 <a name="l00206"></a>00206 <span class="keyword">virtual</span> std::string <a class="code" href="classTCLAP_1_1MultiArg.html#ac2c962112704b899f4c8b8565f2c4bb3" title="Returns the a short id string.">shortID</a>(<span class="keyword">const</span> std::string& val=<span class="stringliteral">"val"</span>) <span class="keyword">const</span>; <a name="l00207"></a>00207 <a name="l00212"></a>00212 <span class="keyword">virtual</span> std::string <a class="code" href="classTCLAP_1_1MultiArg.html#a16c00fbce6876bceabb3dab4723f7e79" title="Returns the a long id string.">longID</a>(<span class="keyword">const</span> std::string& val=<span class="stringliteral">"val"</span>) <span class="keyword">const</span>; <a name="l00213"></a>00213 <a name="l00218"></a>00218 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTCLAP_1_1MultiArg.html#a3cb7fec92f3d70e0e455c6bc33fbebab" title="Once we&#39;ve matched the first value, then the arg is no longer required.">isRequired</a>() <span class="keyword">const</span>; <a name="l00219"></a>00219 <a name="l00220"></a>00220 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTCLAP_1_1MultiArg.html#ab05097627c81cd65975fa1b99fae9bd0" title="Used for MultiArgs and XorHandler to determine whether args can still be set.">allowMore</a>(); <a name="l00221"></a>00221 <a name="l00222"></a>00222 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classTCLAP_1_1MultiArg.html#ab21f01f22978a1c0eea716399e9ff89b" title="Clears the Arg object and allows it to be reused by new command lines.">reset</a>(); <a name="l00223"></a>00223 <a name="l00224"></a>00224 <span class="keyword">private</span>: <a name="l00228"></a>00228 <a class="code" href="classTCLAP_1_1MultiArg.html" title="An argument that allows multiple values of type T to be specified.">MultiArg<T></a>(<span class="keyword">const</span> <a class="code" href="classTCLAP_1_1MultiArg.html" title="An argument that allows multiple values of type T to be specified.">MultiArg<T></a>& rhs); <a name="l00229"></a>00229 <a class="code" href="classTCLAP_1_1MultiArg.html" title="An argument that allows multiple values of type T to be specified.">MultiArg<T></a>& operator=(<span class="keyword">const</span> <a class="code" href="classTCLAP_1_1MultiArg.html" title="An argument that allows multiple values of type T to be specified.">MultiArg<T></a>& rhs); <a name="l00230"></a>00230 <a name="l00231"></a>00231 }; <a name="l00232"></a>00232 <a name="l00233"></a>00233 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00234"></a><a class="code" href="classTCLAP_1_1MultiArg.html#a49b5437c7f06cd6864c07dc59814a953">00234</a> <a class="code" href="classTCLAP_1_1MultiArg.html#a49b5437c7f06cd6864c07dc59814a953" title="Constructor.">MultiArg<T>::MultiArg</a>(<span class="keyword">const</span> std::string& flag, <a name="l00235"></a>00235 <span class="keyword">const</span> std::string& name, <a name="l00236"></a>00236 <span class="keyword">const</span> std::string& desc, <a name="l00237"></a>00237 <span class="keywordtype">bool</span> req, <a name="l00238"></a>00238 <span class="keyword">const</span> std::string& typeDesc, <a name="l00239"></a>00239 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v) : <a name="l00240"></a>00240 <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="l00241"></a>00241 _values(std::vector<T>()), <a name="l00242"></a>00242 _typeDesc( typeDesc ), <a name="l00243"></a>00243 _constraint( NULL ), <a name="l00244"></a>00244 _allowMore(false) <a name="l00245"></a>00245 { <a name="l00246"></a>00246 <a class="code" href="classTCLAP_1_1Arg.html#a13130a9a5d22c57a6d42a8883c9b1e0f">_acceptsMultipleValues</a> = <span class="keyword">true</span>; <a name="l00247"></a>00247 } <a name="l00248"></a>00248 <a name="l00249"></a>00249 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00250"></a><a class="code" href="classTCLAP_1_1MultiArg.html#a48c90a873389280f72fb5d6ef707b400">00250</a> <a class="code" href="classTCLAP_1_1MultiArg.html#a49b5437c7f06cd6864c07dc59814a953" title="Constructor.">MultiArg<T>::MultiArg</a>(<span class="keyword">const</span> std::string& flag, <a name="l00251"></a>00251 <span class="keyword">const</span> std::string& name, <a name="l00252"></a>00252 <span class="keyword">const</span> std::string& desc, <a name="l00253"></a>00253 <span class="keywordtype">bool</span> req, <a name="l00254"></a>00254 <span class="keyword">const</span> std::string& typeDesc, <a name="l00255"></a>00255 <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="l00256"></a>00256 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v) <a name="l00257"></a>00257 : <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="l00258"></a>00258 _values(std::vector<T>()), <a name="l00259"></a>00259 _typeDesc( typeDesc ), <a name="l00260"></a>00260 _constraint( NULL ), <a name="l00261"></a>00261 _allowMore(false) <a name="l00262"></a>00262 { <a name="l00263"></a>00263 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="l00264"></a>00264 <a class="code" href="classTCLAP_1_1Arg.html#a13130a9a5d22c57a6d42a8883c9b1e0f">_acceptsMultipleValues</a> = <span class="keyword">true</span>; <a name="l00265"></a>00265 } <a name="l00266"></a>00266 <a name="l00270"></a>00270 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00271"></a><a class="code" href="classTCLAP_1_1MultiArg.html#a38b1e32a8189356bd1e5ec7c2d43c1a3">00271</a> <a class="code" href="classTCLAP_1_1MultiArg.html#a49b5437c7f06cd6864c07dc59814a953" title="Constructor.">MultiArg<T>::MultiArg</a>(<span class="keyword">const</span> std::string& flag, <a name="l00272"></a>00272 <span class="keyword">const</span> std::string& name, <a name="l00273"></a>00273 <span class="keyword">const</span> std::string& desc, <a name="l00274"></a>00274 <span class="keywordtype">bool</span> req, <a name="l00275"></a>00275 <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="l00276"></a>00276 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v) <a name="l00277"></a>00277 : <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="l00278"></a>00278 _values(std::vector<T>()), <a name="l00279"></a>00279 _typeDesc( constraint->shortID() ), <a name="l00280"></a>00280 _constraint( constraint ), <a name="l00281"></a>00281 _allowMore(false) <a name="l00282"></a>00282 { <a name="l00283"></a>00283 <a class="code" href="classTCLAP_1_1Arg.html#a13130a9a5d22c57a6d42a8883c9b1e0f">_acceptsMultipleValues</a> = <span class="keyword">true</span>; <a name="l00284"></a>00284 } <a name="l00285"></a>00285 <a name="l00286"></a>00286 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00287"></a><a class="code" href="classTCLAP_1_1MultiArg.html#ad4fcd892de2f1ef275c30dc499215208">00287</a> <a class="code" href="classTCLAP_1_1MultiArg.html#a49b5437c7f06cd6864c07dc59814a953" title="Constructor.">MultiArg<T>::MultiArg</a>(<span class="keyword">const</span> std::string& flag, <a name="l00288"></a>00288 <span class="keyword">const</span> std::string& name, <a name="l00289"></a>00289 <span class="keyword">const</span> std::string& desc, <a name="l00290"></a>00290 <span class="keywordtype">bool</span> req, <a name="l00291"></a>00291 <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="l00292"></a>00292 <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="l00293"></a>00293 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v) <a name="l00294"></a>00294 : <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="l00295"></a>00295 _values(std::vector<T>()), <a name="l00296"></a>00296 _typeDesc( constraint->shortID() ), <a name="l00297"></a>00297 _constraint( constraint ), <a name="l00298"></a>00298 _allowMore(false) <a name="l00299"></a>00299 { <a name="l00300"></a>00300 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="l00301"></a>00301 <a class="code" href="classTCLAP_1_1Arg.html#a13130a9a5d22c57a6d42a8883c9b1e0f">_acceptsMultipleValues</a> = <span class="keyword">true</span>; <a name="l00302"></a>00302 } <a name="l00303"></a>00303 <a name="l00304"></a>00304 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00305"></a><a class="code" href="classTCLAP_1_1MultiArg.html#aff4ff7f8d854dd668aaaf80511d8002b">00305</a> <span class="keyword">const</span> std::vector<T>& <a class="code" href="classTCLAP_1_1MultiArg.html#aff4ff7f8d854dd668aaaf80511d8002b" title="Returns a vector of type T containing the values parsed from the command line.">MultiArg<T>::getValue</a>() { <span class="keywordflow">return</span> <a class="code" href="classTCLAP_1_1MultiArg.html#aabcab153e09608343713a6ffef431783" title="The list of values parsed from the CmdLine.">_values</a>; } <a name="l00306"></a>00306 <a name="l00307"></a>00307 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00308"></a><a class="code" href="classTCLAP_1_1MultiArg.html#a344d3cf2128c510f92825e421ea667c7">00308</a> <span class="keywordtype">bool</span> <a class="code" href="classTCLAP_1_1MultiArg.html#a344d3cf2128c510f92825e421ea667c7" title="Handles the processing of the argument.">MultiArg<T>::processArg</a>(<span class="keywordtype">int</span> *i, std::vector<std::string>& args) <a name="l00309"></a>00309 { <a name="l00310"></a>00310 <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="l00311"></a>00311 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00312"></a>00312 <a name="l00313"></a>00313 <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="l00314"></a>00314 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00315"></a>00315 <a name="l00316"></a>00316 std::string flag = args[*i]; <a name="l00317"></a>00317 std::string value = <span class="stringliteral">""</span>; <a name="l00318"></a>00318 <a name="l00319"></a>00319 <a class="code" href="classTCLAP_1_1Arg.html#a54595328e81f5fb77859563690faab25" title="Trims a value off of the flag.">trimFlag</a>( flag, value ); <a name="l00320"></a>00320 <a name="l00321"></a>00321 <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="l00322"></a>00322 { <a name="l00323"></a>00323 <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="l00324"></a>00324 <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="l00325"></a>00325 <span class="stringliteral">"Couldn't find delimiter for this argument!"</span>, <a name="l00326"></a>00326 <a class="code" href="classTCLAP_1_1Arg.html#ac98a357568c21f0eb6ca2220b8a3d4a2" title="Returns a simple string representation of the argument.">toString</a>() ) ); <a name="l00327"></a>00327 <a name="l00328"></a>00328 <span class="comment">// always take the first one, regardless of start string</span> <a name="l00329"></a>00329 <span class="keywordflow">if</span> ( value == <span class="stringliteral">""</span> ) <a name="l00330"></a>00330 { <a name="l00331"></a>00331 (*i)++; <a name="l00332"></a>00332 <span class="keywordflow">if</span> ( static_cast<unsigned int>(*i) < args.size() ) <a name="l00333"></a>00333 <a class="code" href="classTCLAP_1_1MultiArg.html#a26cbf5e86ac66d876f9285f1fda22470" title="Extracts the value from the string.">_extractValue</a>( args[*i] ); <a name="l00334"></a>00334 <span class="keywordflow">else</span> <a name="l00335"></a>00335 <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="l00336"></a>00336 <a class="code" href="classTCLAP_1_1Arg.html#ac98a357568c21f0eb6ca2220b8a3d4a2" title="Returns a simple string representation of the argument.">toString</a>() ) ); <a name="l00337"></a>00337 } <a name="l00338"></a>00338 <span class="keywordflow">else</span> <a name="l00339"></a>00339 <a class="code" href="classTCLAP_1_1MultiArg.html#a26cbf5e86ac66d876f9285f1fda22470" title="Extracts the value from the string.">_extractValue</a>( value ); <a name="l00340"></a>00340 <a name="l00341"></a>00341 <span class="comment">/*</span> <a name="l00342"></a>00342 <span class="comment"> // continuing taking the args until we hit one with a start string </span> <a name="l00343"></a>00343 <span class="comment"> while ( (unsigned int)(*i)+1 < args.size() &&</span> <a name="l00344"></a>00344 <span class="comment"> args[(*i)+1].find_first_of( Arg::flagStartString() ) != 0 &&</span> <a name="l00345"></a>00345 <span class="comment"> args[(*i)+1].find_first_of( Arg::nameStartString() ) != 0 ) </span> <a name="l00346"></a>00346 <span class="comment"> _extractValue( args[++(*i)] );</span> <a name="l00347"></a>00347 <span class="comment"> */</span> <a name="l00348"></a>00348 <a name="l00349"></a>00349 <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="l00350"></a>00350 <a class="code" href="classTCLAP_1_1Arg.html#aa963d0d4c8cb297e1f4cf74143bf6d1b" title="Performs the special handling described by the Vistitor.">_checkWithVisitor</a>(); <a name="l00351"></a>00351 <a name="l00352"></a>00352 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00353"></a>00353 } <a name="l00354"></a>00354 <span class="keywordflow">else</span> <a name="l00355"></a>00355 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00356"></a>00356 } <a name="l00357"></a>00357 <a name="l00361"></a>00361 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00362"></a><a class="code" href="classTCLAP_1_1MultiArg.html#ac2c962112704b899f4c8b8565f2c4bb3">00362</a> std::string <a class="code" href="classTCLAP_1_1MultiArg.html#ac2c962112704b899f4c8b8565f2c4bb3" title="Returns the a short id string.">MultiArg<T>::shortID</a>(<span class="keyword">const</span> std::string& val)<span class="keyword"> const</span> <a name="l00363"></a>00363 <span class="keyword"></span>{ <a name="l00364"></a>00364 <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="l00365"></a>00365 <span class="keywordflow">return</span> <a class="code" href="classTCLAP_1_1MultiArg.html#ac2c962112704b899f4c8b8565f2c4bb3" title="Returns the a short id string.">Arg::shortID</a>(<a class="code" href="classTCLAP_1_1MultiArg.html#a0f6a2b04fe15d1ede95165fc6e1949e8" title="The description of type T to be used in the usage.">_typeDesc</a>) + <span class="stringliteral">" ... "</span>; <a name="l00366"></a>00366 } <a name="l00367"></a>00367 <a name="l00371"></a>00371 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00372"></a><a class="code" href="classTCLAP_1_1MultiArg.html#a16c00fbce6876bceabb3dab4723f7e79">00372</a> std::string <a class="code" href="classTCLAP_1_1MultiArg.html#a16c00fbce6876bceabb3dab4723f7e79" title="Returns the a long id string.">MultiArg<T>::longID</a>(<span class="keyword">const</span> std::string& val)<span class="keyword"> const</span> <a name="l00373"></a>00373 <span class="keyword"></span>{ <a name="l00374"></a>00374 <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="l00375"></a>00375 <span class="keywordflow">return</span> <a class="code" href="classTCLAP_1_1MultiArg.html#a16c00fbce6876bceabb3dab4723f7e79" title="Returns the a long id string.">Arg::longID</a>(<a class="code" href="classTCLAP_1_1MultiArg.html#a0f6a2b04fe15d1ede95165fc6e1949e8" title="The description of type T to be used in the usage.">_typeDesc</a>) + <span class="stringliteral">" (accepted multiple times)"</span>; <a name="l00376"></a>00376 } <a name="l00377"></a>00377 <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_1MultiArg.html#a3cb7fec92f3d70e0e455c6bc33fbebab">00383</a> <span class="keywordtype">bool</span> <a class="code" href="classTCLAP_1_1MultiArg.html#a3cb7fec92f3d70e0e455c6bc33fbebab" title="Once we&#39;ve matched the first value, then the arg is no longer required.">MultiArg<T>::isRequired</a>()<span class="keyword"> const</span> <a name="l00384"></a>00384 <span class="keyword"></span>{ <a name="l00385"></a>00385 <span class="keywordflow">if</span> ( <a class="code" href="classTCLAP_1_1Arg.html#ad16408bd1ca4d8b1d14d6c5129545a84" title="Indicating whether the argument is required.">_required</a> ) <a name="l00386"></a>00386 { <a name="l00387"></a>00387 <span class="keywordflow">if</span> ( <a class="code" href="classTCLAP_1_1MultiArg.html#aabcab153e09608343713a6ffef431783" title="The list of values parsed from the CmdLine.">_values</a>.size() > 1 ) <a name="l00388"></a>00388 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00389"></a>00389 <span class="keywordflow">else</span> <a name="l00390"></a>00390 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00391"></a>00391 } <a name="l00392"></a>00392 <span class="keywordflow">else</span> <a name="l00393"></a>00393 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00394"></a>00394 <a name="l00395"></a>00395 } <a name="l00396"></a>00396 <a name="l00397"></a>00397 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00398"></a><a class="code" href="classTCLAP_1_1MultiArg.html#a26cbf5e86ac66d876f9285f1fda22470">00398</a> <span class="keywordtype">void</span> <a class="code" href="classTCLAP_1_1MultiArg.html#a26cbf5e86ac66d876f9285f1fda22470" title="Extracts the value from the string.">MultiArg<T>::_extractValue</a>( <span class="keyword">const</span> std::string& val ) <a name="l00399"></a>00399 { <a name="l00400"></a>00400 <span class="keywordflow">try</span> { <a name="l00401"></a>00401 T tmp; <a name="l00402"></a>00402 <a class="code" href="namespaceTCLAP.html#a80473f9a24db31df0206504c2cdf0a8d">ExtractValue</a>(tmp, 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="l00403"></a>00403 <a class="code" href="classTCLAP_1_1MultiArg.html#aabcab153e09608343713a6ffef431783" title="The list of values parsed from the CmdLine.">_values</a>.push_back(tmp); <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_1MultiArg.html#afc754048b66bc3a251268947273ea906" title="A list of constraint on this Arg.">_constraint</a> != NULL ) <a name="l00409"></a>00409 <span class="keywordflow">if</span> ( ! <a class="code" href="classTCLAP_1_1MultiArg.html#afc754048b66bc3a251268947273ea906" title="A list of constraint on this Arg.">_constraint</a>->check( <a class="code" href="classTCLAP_1_1MultiArg.html#aabcab153e09608343713a6ffef431783" title="The list of values parsed from the CmdLine.">_values</a>.back() ) ) <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_1MultiArg.html#afc754048b66bc3a251268947273ea906" title="A list of constraint on this Arg.">_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_1MultiArg.html#ab05097627c81cd65975fa1b99fae9bd0">00417</a> <span class="keywordtype">bool</span> <a class="code" href="classTCLAP_1_1MultiArg.html#ab05097627c81cd65975fa1b99fae9bd0" title="Used for MultiArgs and XorHandler to determine whether args can still be set.">MultiArg<T>::allowMore</a>() <a name="l00418"></a>00418 { <a name="l00419"></a>00419 <span class="keywordtype">bool</span> am = <a class="code" href="classTCLAP_1_1MultiArg.html#a93a3ef586f763d46839c0e737689b85f" title="Used by XorHandler to decide whether to keep parsing for this arg.">_allowMore</a>; <a name="l00420"></a>00420 <a class="code" href="classTCLAP_1_1MultiArg.html#a93a3ef586f763d46839c0e737689b85f" title="Used by XorHandler to decide whether to keep parsing for this arg.">_allowMore</a> = <span class="keyword">true</span>; <a name="l00421"></a>00421 <span class="keywordflow">return</span> am; <a name="l00422"></a>00422 } <a name="l00423"></a>00423 <a name="l00424"></a>00424 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00425"></a><a class="code" href="classTCLAP_1_1MultiArg.html#ab21f01f22978a1c0eea716399e9ff89b">00425</a> <span class="keywordtype">void</span> <a class="code" href="classTCLAP_1_1MultiArg.html#ab21f01f22978a1c0eea716399e9ff89b" title="Clears the Arg object and allows it to be reused by new command lines.">MultiArg<T>::reset</a>() <a name="l00426"></a>00426 { <a name="l00427"></a>00427 <a class="code" href="classTCLAP_1_1MultiArg.html#ab21f01f22978a1c0eea716399e9ff89b" title="Clears the Arg object and allows it to be reused by new command lines.">Arg::reset</a>(); <a name="l00428"></a>00428 <a class="code" href="classTCLAP_1_1MultiArg.html#aabcab153e09608343713a6ffef431783" title="The list of values parsed from the CmdLine.">_values</a>.clear(); <a name="l00429"></a>00429 } <a name="l00430"></a>00430 <a name="l00431"></a>00431 } <span class="comment">// namespace TCLAP</span> <a name="l00432"></a>00432 <a name="l00433"></a>00433 <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/MultiArg_8h_source.html | |||||
#1 | 16119 | tjuricek | Rename/move to meet workshop project conventions. | ||
//guest/tjuricek/fsclient/vendor/tclap-1.2.1/docs/html/MultiArg_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. |