<!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: MultiSwitchArg.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&nbsp;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&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>MultiSwitchArg.h</h1><a href="MultiSwitchArg_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="comment">/****************************************************************************** </span>
<a name="l00003"></a>00003 <span class="comment">*</span>
<a name="l00004"></a>00004 <span class="comment">*  file:  MultiSwitchArg.h</span>
<a name="l00005"></a>00005 <span class="comment">*</span>
<a name="l00006"></a>00006 <span class="comment">*  Copyright (c) 2003, Michael E. Smoot .</span>
<a name="l00007"></a>00007 <span class="comment">*  Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.</span>
<a name="l00008"></a>00008 <span class="comment">*  Copyright (c) 2005, Michael E. Smoot, Daniel Aarno, Erik Zeek.</span>
<a name="l00009"></a>00009 <span class="comment">*  All rights reverved.</span>
<a name="l00010"></a>00010 <span class="comment">*</span>
<a name="l00011"></a>00011 <span class="comment">*  See the file COPYING in the top directory of this distribution for</span>
<a name="l00012"></a>00012 <span class="comment">*  more information.</span>
<a name="l00013"></a>00013 <span class="comment">*</span>
<a name="l00014"></a>00014 <span class="comment">*  THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS</span>
<a name="l00015"></a>00015 <span class="comment">*  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<a name="l00016"></a>00016 <span class="comment">*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</span>
<a name="l00017"></a>00017 <span class="comment">*  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<a name="l00018"></a>00018 <span class="comment">*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</span>
<a name="l00019"></a>00019 <span class="comment">*  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</span>
<a name="l00020"></a>00020 <span class="comment">*  DEALINGS IN THE SOFTWARE.</span>
<a name="l00021"></a>00021 <span class="comment">*</span>
<a name="l00022"></a>00022 <span class="comment">*****************************************************************************/</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="preprocessor">#ifndef TCLAP_MULTI_SWITCH_ARG_H</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#define TCLAP_MULTI_SWITCH_ARG_H</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;<a class="code" href="SwitchArg_8h.html">tclap/SwitchArg.h</a>&gt;</span>
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <span class="keyword">namespace </span>TCLAP {
<a name="l00034"></a>00034 
<a name="l00039"></a><a class="code" href="classTCLAP_1_1MultiSwitchArg.html">00039</a> <span class="keyword">class </span><a class="code" href="classTCLAP_1_1MultiSwitchArg.html" title="A multiple switch argument.">MultiSwitchArg</a> : <span class="keyword">public</span> <a class="code" href="classTCLAP_1_1SwitchArg.html" title="A simple switch argument.">SwitchArg</a>
<a name="l00040"></a>00040 {
<a name="l00041"></a>00041     <span class="keyword">protected</span>:
<a name="l00042"></a>00042 
<a name="l00046"></a><a class="code" href="classTCLAP_1_1MultiSwitchArg.html#ab488d4bcdde96fc9edea87ee9b6f5839">00046</a>         <span class="keywordtype">int</span> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#ab488d4bcdde96fc9edea87ee9b6f5839" title="The value of the switch.">_value</a>;
<a name="l00047"></a>00047 
<a name="l00052"></a><a class="code" href="classTCLAP_1_1MultiSwitchArg.html#afcd5b3e418e455af3d31aec1e300bb74">00052</a>         <span class="keywordtype">int</span> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#afcd5b3e418e455af3d31aec1e300bb74" title="Used to support the reset() method so that ValueArg can be reset to their constructed...">_default</a>;
<a name="l00053"></a>00053 
<a name="l00054"></a>00054     <span class="keyword">public</span>:
<a name="l00055"></a>00055 
<a name="l00069"></a>00069         <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a37db9658517f206fd69936e1458d59b0" title="MultiSwitchArg constructor.">MultiSwitchArg</a>(<span class="keyword">const</span> std::string&amp; flag, 
<a name="l00070"></a>00070                 <span class="keyword">const</span> std::string&amp; name,
<a name="l00071"></a>00071                 <span class="keyword">const</span> std::string&amp; desc,
<a name="l00072"></a>00072                 <span class="keywordtype">int</span> init = 0,
<a name="l00073"></a>00073                 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL);
<a name="l00074"></a>00074 
<a name="l00075"></a>00075 
<a name="l00090"></a>00090         <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a37db9658517f206fd69936e1458d59b0" title="MultiSwitchArg constructor.">MultiSwitchArg</a>(<span class="keyword">const</span> std::string&amp; flag, 
<a name="l00091"></a>00091                 <span class="keyword">const</span> std::string&amp; name,
<a name="l00092"></a>00092                 <span class="keyword">const</span> std::string&amp; desc,
<a name="l00093"></a>00093                 <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>&amp; parser,
<a name="l00094"></a>00094                 <span class="keywordtype">int</span> init = 0,
<a name="l00095"></a>00095                 <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL);
<a name="l00096"></a>00096 
<a name="l00097"></a>00097 
<a name="l00106"></a>00106         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a91c3d349570f21d8af6dc90767d747a2" title="Handles the processing of the argument.">processArg</a>(<span class="keywordtype">int</span>* i, std::vector&lt;std::string&gt;&amp; args); 
<a name="l00107"></a>00107 
<a name="l00111"></a>00111         <span class="keywordtype">int</span> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a0389e414c11ebbab4a88dfbbf3af18bd" title="Returns int, the number of times the switch has been set.">getValue</a>();
<a name="l00112"></a>00112 
<a name="l00116"></a>00116         std::string <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a083c07003f948691e94ce94d0b6376ed" title="Returns the shortID for this Arg.">shortID</a>(<span class="keyword">const</span> std::string&amp; val) <span class="keyword">const</span>;
<a name="l00117"></a>00117 
<a name="l00121"></a>00121         std::string <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a0b0aacc09c93462bab4347f86db0fccd" title="Returns the longID for this Arg.">longID</a>(<span class="keyword">const</span> std::string&amp; val) <span class="keyword">const</span>;
<a name="l00122"></a>00122         
<a name="l00123"></a>00123         <span class="keywordtype">void</span> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#ac320530811dbca7fdcb2a41ab252fce4" title="Clears the Arg object and allows it to be reused by new command lines.">reset</a>();
<a name="l00124"></a>00124 
<a name="l00125"></a>00125 };
<a name="l00126"></a>00126 
<a name="l00128"></a>00128 <span class="comment">//BEGIN MultiSwitchArg.cpp</span>
<a name="l00130"></a><a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a37db9658517f206fd69936e1458d59b0">00130</a> <span class="comment"></span><span class="keyword">inline</span> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a37db9658517f206fd69936e1458d59b0" title="MultiSwitchArg constructor.">MultiSwitchArg::MultiSwitchArg</a>(<span class="keyword">const</span> std::string&amp; flag,
<a name="l00131"></a>00131                     <span class="keyword">const</span> std::string&amp; name,
<a name="l00132"></a>00132                     <span class="keyword">const</span> std::string&amp; desc,
<a name="l00133"></a>00133                     <span class="keywordtype">int</span> init,
<a name="l00134"></a>00134                     <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v )
<a name="l00135"></a>00135 : <a class="code" href="classTCLAP_1_1SwitchArg.html" title="A simple switch argument.">SwitchArg</a>(flag, name, desc, false, v),
<a name="l00136"></a>00136 _value( init ),
<a name="l00137"></a>00137 _default( init )
<a name="l00138"></a>00138 { }
<a name="l00139"></a>00139 
<a name="l00140"></a><a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a0443d4a222630ac45aa67e40f2de3541">00140</a> <span class="keyword">inline</span> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a37db9658517f206fd69936e1458d59b0" title="MultiSwitchArg constructor.">MultiSwitchArg::MultiSwitchArg</a>(<span class="keyword">const</span> std::string&amp; flag,
<a name="l00141"></a>00141                     <span class="keyword">const</span> std::string&amp; name, 
<a name="l00142"></a>00142                     <span class="keyword">const</span> std::string&amp; desc, 
<a name="l00143"></a>00143                     <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>&amp; parser,
<a name="l00144"></a>00144                     <span class="keywordtype">int</span> init,
<a name="l00145"></a>00145                     <a class="code" href="classTCLAP_1_1Visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v )
<a name="l00146"></a>00146 : <a class="code" href="classTCLAP_1_1SwitchArg.html" title="A simple switch argument.">SwitchArg</a>(flag, name, desc, false, v),
<a name="l00147"></a>00147 _value( init ),
<a name="l00148"></a>00148 _default( init )
<a name="l00149"></a>00149 { 
<a name="l00150"></a>00150     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="l00151"></a>00151 }
<a name="l00152"></a>00152 
<a name="l00153"></a><a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a0389e414c11ebbab4a88dfbbf3af18bd">00153</a> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a0389e414c11ebbab4a88dfbbf3af18bd" title="Returns int, the number of times the switch has been set.">MultiSwitchArg::getValue</a>() { <span class="keywordflow">return</span> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#ab488d4bcdde96fc9edea87ee9b6f5839" title="The value of the switch.">_value</a>; }
<a name="l00154"></a>00154 
<a name="l00155"></a><a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a91c3d349570f21d8af6dc90767d747a2">00155</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a91c3d349570f21d8af6dc90767d747a2" title="Handles the processing of the argument.">MultiSwitchArg::processArg</a>(<span class="keywordtype">int</span> *i, std::vector&lt;std::string&gt;&amp; args)
<a name="l00156"></a>00156 {
<a name="l00157"></a>00157     <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> &amp;&amp; <a class="code" href="classTCLAP_1_1Arg.html#a4d412155b8f9b4956e64e91c48e55a3b" title="Whether to ignore the rest.">Arg::ignoreRest</a>() )
<a name="l00158"></a>00158         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00159"></a>00159 
<a name="l00160"></a>00160     <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>( args[*i] ))
<a name="l00161"></a>00161     {
<a name="l00162"></a>00162         <span class="comment">// so the isSet() method will work</span>
<a name="l00163"></a>00163         <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="l00164"></a>00164 
<a name="l00165"></a>00165         <span class="comment">// Matched argument: increment value.</span>
<a name="l00166"></a>00166         ++<a class="code" href="classTCLAP_1_1MultiSwitchArg.html#ab488d4bcdde96fc9edea87ee9b6f5839" title="The value of the switch.">_value</a>;
<a name="l00167"></a>00167 
<a name="l00168"></a>00168         <a class="code" href="classTCLAP_1_1Arg.html#aa963d0d4c8cb297e1f4cf74143bf6d1b" title="Performs the special handling described by the Vistitor.">_checkWithVisitor</a>();
<a name="l00169"></a>00169 
<a name="l00170"></a>00170         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00171"></a>00171     }
<a name="l00172"></a>00172     <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="classTCLAP_1_1SwitchArg.html#af5fbd44d462539941b09e960034d692c" title="Checks a string to see if any of the chars in the string match the flag for this...">combinedSwitchesMatch</a>( args[*i] ) )
<a name="l00173"></a>00173     {
<a name="l00174"></a>00174         <span class="comment">// so the isSet() method will work</span>
<a name="l00175"></a>00175         <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="l00176"></a>00176 
<a name="l00177"></a>00177         <span class="comment">// Matched argument: increment value.</span>
<a name="l00178"></a>00178         ++<a class="code" href="classTCLAP_1_1MultiSwitchArg.html#ab488d4bcdde96fc9edea87ee9b6f5839" title="The value of the switch.">_value</a>;
<a name="l00179"></a>00179 
<a name="l00180"></a>00180         <span class="comment">// Check for more in argument and increment value.</span>
<a name="l00181"></a>00181         <span class="keywordflow">while</span> ( <a class="code" href="classTCLAP_1_1SwitchArg.html#af5fbd44d462539941b09e960034d692c" title="Checks a string to see if any of the chars in the string match the flag for this...">combinedSwitchesMatch</a>( args[*i] ) ) 
<a name="l00182"></a>00182             ++<a class="code" href="classTCLAP_1_1MultiSwitchArg.html#ab488d4bcdde96fc9edea87ee9b6f5839" title="The value of the switch.">_value</a>;
<a name="l00183"></a>00183 
<a name="l00184"></a>00184         <a class="code" href="classTCLAP_1_1Arg.html#aa963d0d4c8cb297e1f4cf74143bf6d1b" title="Performs the special handling described by the Vistitor.">_checkWithVisitor</a>();
<a name="l00185"></a>00185 
<a name="l00186"></a>00186         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00187"></a>00187     }
<a name="l00188"></a>00188     <span class="keywordflow">else</span>
<a name="l00189"></a>00189         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00190"></a>00190 }
<a name="l00191"></a>00191 
<a name="l00192"></a>00192 <span class="keyword">inline</span> std::string 
<a name="l00193"></a><a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a083c07003f948691e94ce94d0b6376ed">00193</a> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a083c07003f948691e94ce94d0b6376ed" title="Returns the shortID for this Arg.">MultiSwitchArg::shortID</a>(<span class="keyword">const</span> std::string&amp; val)<span class="keyword"> const</span>
<a name="l00194"></a>00194 <span class="keyword"></span>{
<a name="l00195"></a>00195     <span class="keywordflow">return</span> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a083c07003f948691e94ce94d0b6376ed" title="Returns the shortID for this Arg.">Arg::shortID</a>(val) + <span class="stringliteral">&quot; ... &quot;</span>;
<a name="l00196"></a>00196 }
<a name="l00197"></a>00197 
<a name="l00198"></a>00198 <span class="keyword">inline</span> std::string 
<a name="l00199"></a><a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a0b0aacc09c93462bab4347f86db0fccd">00199</a> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a0b0aacc09c93462bab4347f86db0fccd" title="Returns the longID for this Arg.">MultiSwitchArg::longID</a>(<span class="keyword">const</span> std::string&amp; val)<span class="keyword"> const</span>
<a name="l00200"></a>00200 <span class="keyword"></span>{
<a name="l00201"></a>00201     <span class="keywordflow">return</span> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#a0b0aacc09c93462bab4347f86db0fccd" title="Returns the longID for this Arg.">Arg::longID</a>(val) + <span class="stringliteral">&quot;  (accepted multiple times)&quot;</span>;
<a name="l00202"></a>00202 }
<a name="l00203"></a>00203 
<a name="l00204"></a>00204 <span class="keyword">inline</span> <span class="keywordtype">void</span>
<a name="l00205"></a><a class="code" href="classTCLAP_1_1MultiSwitchArg.html#ac320530811dbca7fdcb2a41ab252fce4">00205</a> <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#ac320530811dbca7fdcb2a41ab252fce4" title="Clears the Arg object and allows it to be reused by new command lines.">MultiSwitchArg::reset</a>()
<a name="l00206"></a>00206 {
<a name="l00207"></a>00207     <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#ab488d4bcdde96fc9edea87ee9b6f5839" title="The value of the switch.">MultiSwitchArg::_value</a> = <a class="code" href="classTCLAP_1_1MultiSwitchArg.html#afcd5b3e418e455af3d31aec1e300bb74" title="Used to support the reset() method so that ValueArg can be reset to their constructed...">MultiSwitchArg::_default</a>;
<a name="l00208"></a>00208 }
<a name="l00209"></a>00209 
<a name="l00211"></a>00211 <span class="comment">//END MultiSwitchArg.cpp</span>
<a name="l00213"></a>00213 <span class="comment"></span>
<a name="l00214"></a>00214 } <span class="comment">//namespace TCLAP</span>
<a name="l00215"></a>00215 
<a name="l00216"></a>00216 <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&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.0 </small></address>
</body>
</html>