<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>MultiArg.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <div align="left"><a href="http://www.mrpt.org/">Main MRPT website</a> > <b>C++ reference</b> </div> <div align="right"> <a href="index.html"><img border="0" src="mrpt_logo.png" alt="MRPT logo"></a> </div> <!-- Generated by Doxygen 1.7.5 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</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> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <div class="left"> <form id="FSearchBox" action="search.php" method="get"> <img id="MSearchSelect" src="search/mag.png" alt=""/> <input type="text" id="MSearchField" name="query" value="Search" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)"/> </form> </div><div class="right"></div> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">MultiArg.h</div> </div> </div> <div class="contents"> <a href="_multi_arg_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">mrpt/otherlibs/tclap/Arg.h</a>></span> <a name="l00030"></a>00030 <span class="preprocessor">#include <<a class="code" href="_constraint_8h.html">mrpt/otherlibs/tclap/Constraint.h</a>></span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="comment">//#ifdef HAVE_CONFIG_H</span> <a name="l00033"></a>00033 <span class="comment">//#include <config.h></span> <a name="l00034"></a>00034 <span class="comment">//#else</span> <a name="l00035"></a><a class="code" href="_multi_arg_8h.html#a91e904e6e4f21f803c49113b934e6966">00035</a> <span class="preprocessor">#define HAVE_SSTREAM</span> <a name="l00036"></a>00036 <span class="preprocessor"></span><span class="comment">//#endif</span> <a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="preprocessor">#if defined(HAVE_SSTREAM)</span> <a name="l00039"></a>00039 <span class="preprocessor"></span><span class="preprocessor">#include <sstream></span> <a name="l00040"></a>00040 <span class="preprocessor">#elif defined(HAVE_STRSTREAM)</span> <a name="l00041"></a>00041 <span class="preprocessor"></span><span class="preprocessor">#include <strstream></span> <a name="l00042"></a>00042 <span class="preprocessor">#else</span> <a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#error "Need a stringstream (sstream or strstream) to compile!"</span> <a name="l00044"></a>00044 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00045"></a>00045 <span class="preprocessor"></span> <a name="l00046"></a>00046 <span class="keyword">namespace </span>TCLAP { <a name="l00047"></a>00047 <a name="l00048"></a>00048 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">class </span>MultiArg; <a name="l00049"></a>00049 <a name="l00050"></a><a class="code" href="namespace_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r.html">00050</a> <span class="keyword">namespace </span>MULTI_ARG_HELPER { <a name="l00051"></a>00051 <a name="l00052"></a><a class="code" href="namespace_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r.html#a05e9d7d66a5aebe00a18ed3e642171b8a3a8b1e6fa3593f61a712dea63322da0d">00052</a> <span class="keyword">enum</span> <a class="code" href="namespace_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r.html#a05e9d7d66a5aebe00a18ed3e642171b8">Error_e</a> { <a class="code" href="namespace_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r.html#a05e9d7d66a5aebe00a18ed3e642171b8a34e78ac3b2516d88e25b585302d0b583">EXTRACT_FAILURE</a> = 1000, <a class="code" href="namespace_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r.html#a05e9d7d66a5aebe00a18ed3e642171b8a3a8b1e6fa3593f61a712dea63322da0d">EXTRACT_TOO_MANY</a> }; <a name="l00053"></a>00053 <span class="comment"></span> <a name="l00054"></a>00054 <span class="comment">/**</span> <a name="l00055"></a>00055 <span class="comment"> * This class is used to extract a value from an argument. </span> <a name="l00056"></a>00056 <span class="comment"> * It is used because we need a special implementation to</span> <a name="l00057"></a>00057 <span class="comment"> * deal with std::string and making a specialiced function</span> <a name="l00058"></a>00058 <span class="comment"> * puts it in the T segment, thus generating link errors.</span> <a name="l00059"></a>00059 <span class="comment"> * Having a specialiced class makes the symbols weak.</span> <a name="l00060"></a>00060 <span class="comment"> * This is not pretty but I don't know how to make it</span> <a name="l00061"></a>00061 <span class="comment"> * work any other way.</span> <a name="l00062"></a>00062 <span class="comment"> */</span> <a name="l00063"></a>00063 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00064"></a>00064 <span class="keyword">class </span>ValueExtractor <a name="l00065"></a>00065 { <a name="l00066"></a><a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#a4fd90887a83c77da13c68028274e2898">00066</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html" title="An argument that allows multiple values of type T to be specified.">MultiArg</a><T>; <a name="l00067"></a>00067 <a name="l00068"></a>00068 <span class="keyword">private</span>: <a name="l00069"></a>00069 <span class="comment"></span> <a name="l00070"></a>00070 <span class="comment"> /**</span> <a name="l00071"></a>00071 <span class="comment"> * Reference to the vector of values where the result of the </span> <a name="l00072"></a>00072 <span class="comment"> * extraction will be put.</span> <a name="l00073"></a>00073 <span class="comment"> */</span> <a name="l00074"></a><a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#accf177846487ac284fd6ed56360bee42">00074</a> std::vector<T> &<a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#accf177846487ac284fd6ed56360bee42" title="Reference to the vector of values where the result of the extraction will be put.">_values</a>; <a name="l00075"></a>00075 <span class="comment"></span> <a name="l00076"></a>00076 <span class="comment"> /**</span> <a name="l00077"></a>00077 <span class="comment"> * Constructor.</span> <a name="l00078"></a>00078 <span class="comment"> * \param values - Where the values extracted will be put.</span> <a name="l00079"></a>00079 <span class="comment"> */</span> <a name="l00080"></a><a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#a81711e578ba1725e85004f93d52ce5f2">00080</a> <a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#a81711e578ba1725e85004f93d52ce5f2" title="Constructor.">ValueExtractor</a>(<a class="code" href="classstd_1_1vector.html">std::vector<T></a> &values) : <a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#accf177846487ac284fd6ed56360bee42" title="Reference to the vector of values where the result of the extraction will be put.">_values</a>(values) {} <a name="l00081"></a>00081 <span class="comment"></span> <a name="l00082"></a>00082 <span class="comment"> /**</span> <a name="l00083"></a>00083 <span class="comment"> * Method that will attempt to parse the input stream for values</span> <a name="l00084"></a>00084 <span class="comment"> * of type T.</span> <a name="l00085"></a>00085 <span class="comment"> * \param val - Where the values parsed will be put.</span> <a name="l00086"></a>00086 <span class="comment"> */</span> <a name="l00087"></a><a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#a926cf2e3cdb09512334f5f228a81c821">00087</a> <span class="keywordtype">int</span> <a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#a926cf2e3cdb09512334f5f228a81c821" title="Method that will attempt to parse the input stream for values of type T.">extractValue</a>( <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& val ) <a name="l00088"></a>00088 { <a name="l00089"></a>00089 T temp; <a name="l00090"></a>00090 <a name="l00091"></a>00091 <span class="preprocessor">#if defined(HAVE_SSTREAM)</span> <a name="l00092"></a>00092 <span class="preprocessor"></span> std::istringstream is(val); <a name="l00093"></a>00093 <span class="preprocessor">#elif defined(HAVE_STRSTREAM)</span> <a name="l00094"></a>00094 <span class="preprocessor"></span> std::istrstream is(val.c_str()); <a name="l00095"></a>00095 <span class="preprocessor">#else</span> <a name="l00096"></a>00096 <span class="preprocessor"></span><span class="preprocessor">#error "Need a stringstream (sstream or strstream) to compile!"</span> <a name="l00097"></a>00097 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00098"></a>00098 <span class="preprocessor"></span> <a name="l00099"></a>00099 <span class="keywordtype">int</span> valuesRead = 0; <a name="l00100"></a>00100 <a name="l00101"></a>00101 <span class="keywordflow">while</span> ( is.good() ) <a name="l00102"></a>00102 { <a name="l00103"></a>00103 <span class="keywordflow">if</span> ( is.peek() != EOF ) <a name="l00104"></a>00104 is >> temp; <a name="l00105"></a>00105 <span class="keywordflow">else</span> <a name="l00106"></a>00106 <span class="keywordflow">break</span>; <a name="l00107"></a>00107 <a name="l00108"></a>00108 valuesRead++; <a name="l00109"></a>00109 } <a name="l00110"></a>00110 <a name="l00111"></a>00111 <span class="keywordflow">if</span> ( is.fail() ) <a name="l00112"></a>00112 <span class="keywordflow">return</span> <a class="code" href="namespace_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r.html#a05e9d7d66a5aebe00a18ed3e642171b8a34e78ac3b2516d88e25b585302d0b583">EXTRACT_FAILURE</a>; <a name="l00113"></a>00113 <a name="l00114"></a>00114 <span class="keywordflow">if</span> ( valuesRead > 1 ) <a name="l00115"></a>00115 <span class="keywordflow">return</span> <a class="code" href="namespace_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r.html#a05e9d7d66a5aebe00a18ed3e642171b8a3a8b1e6fa3593f61a712dea63322da0d">EXTRACT_TOO_MANY</a>; <a name="l00116"></a>00116 <a name="l00117"></a>00117 <a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#accf177846487ac284fd6ed56360bee42" title="Reference to the vector of values where the result of the extraction will be put.">_values</a>.push_back(temp); <a name="l00118"></a>00118 <a name="l00119"></a>00119 <span class="keywordflow">return</span> 0; <a name="l00120"></a>00120 } <a name="l00121"></a>00121 }; <a name="l00122"></a>00122 <span class="comment"></span> <a name="l00123"></a>00123 <span class="comment">/**</span> <a name="l00124"></a>00124 <span class="comment"> * Specialization for string. This is necessary because istringstream</span> <a name="l00125"></a>00125 <span class="comment"> * operator>> is not able to ignore spaces... meaning -x "X Y" will only </span> <a name="l00126"></a>00126 <span class="comment"> * read 'X'... and thus the specialization.</span> <a name="l00127"></a>00127 <span class="comment"> */</span> <a name="l00128"></a>00128 <span class="keyword">template</span><> <a name="l00129"></a>00129 <span class="keyword">class </span>ValueExtractor<std::string> <a name="l00130"></a>00130 { <a name="l00131"></a><a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor_3_01std_1_1string_01_4.html#a8cffeb01e97e0ae9af52b8a1c9431598">00131</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html" title="An argument that allows multiple values of type T to be specified.">MultiArg</a><std::string>; <a name="l00132"></a>00132 <a name="l00133"></a>00133 <span class="keyword">private</span>: <a name="l00134"></a>00134 <span class="comment"></span> <a name="l00135"></a>00135 <span class="comment"> /**</span> <a name="l00136"></a>00136 <span class="comment"> * Reference to the vector of strings where the result of the </span> <a name="l00137"></a>00137 <span class="comment"> * extraction will be put.</span> <a name="l00138"></a>00138 <span class="comment"> */</span> <a name="l00139"></a><a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor_3_01std_1_1string_01_4.html#a5afb3caa9ec0a83d676434a5b246cc0f">00139</a> std::vector<std::string> &<a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#accf177846487ac284fd6ed56360bee42" title="Reference to the vector of values where the result of the extraction will be put.">_values</a>; <a name="l00140"></a>00140 <span class="comment"></span> <a name="l00141"></a>00141 <span class="comment"> /**</span> <a name="l00142"></a>00142 <span class="comment"> * Constructor.</span> <a name="l00143"></a>00143 <span class="comment"> * \param values - Where the strings extracted will be put.</span> <a name="l00144"></a>00144 <span class="comment"> */</span> <a name="l00145"></a><a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor_3_01std_1_1string_01_4.html#ab1093d96096f5c831f365b3450deb687">00145</a> <a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html" title="This class is used to extract a value from an argument.">ValueExtractor</a>(std::vector<std::string> &values) : <a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#accf177846487ac284fd6ed56360bee42" title="Reference to the vector of values where the result of the extraction will be put.">_values</a>(values) {} <a name="l00146"></a>00146 <span class="comment"></span> <a name="l00147"></a>00147 <span class="comment"> /**</span> <a name="l00148"></a>00148 <span class="comment"> * Method that will attempt to parse the input stream for values</span> <a name="l00149"></a>00149 <span class="comment"> * of type std::string.</span> <a name="l00150"></a>00150 <span class="comment"> * \param val - Where the values parsed will be put.</span> <a name="l00151"></a>00151 <span class="comment"> */</span> <a name="l00152"></a><a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor_3_01std_1_1string_01_4.html#abe7adbe1a172115dbc808d9beccf499a">00152</a> <span class="keywordtype">int</span> <a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#a926cf2e3cdb09512334f5f228a81c821" title="Method that will attempt to parse the input stream for values of type T.">extractValue</a>( <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& val ) <a name="l00153"></a>00153 { <a name="l00154"></a>00154 <a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#accf177846487ac284fd6ed56360bee42" title="Reference to the vector of values where the result of the extraction will be put.">_values</a>.push_back( val ); <a name="l00155"></a>00155 <span class="keywordflow">return</span> 0; <a name="l00156"></a>00156 } <a name="l00157"></a>00157 }; <a name="l00158"></a>00158 <a name="l00159"></a>00159 } <span class="comment">//namespace MULTI_ARG_HELPER</span> <a name="l00160"></a>00160 <span class="comment"></span> <a name="l00161"></a>00161 <span class="comment">/**</span> <a name="l00162"></a>00162 <span class="comment"> * An argument that allows multiple values of type T to be specified. Very</span> <a name="l00163"></a>00163 <span class="comment"> * similar to a ValueArg, except a vector of values will be returned</span> <a name="l00164"></a>00164 <span class="comment"> * instead of just one.</span> <a name="l00165"></a>00165 <span class="comment"> */</span> <a name="l00166"></a>00166 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00167"></a>00167 <span class="keyword">class </span>MultiArg : <span class="keyword">public</span> Arg <a name="l00168"></a>00168 { <a name="l00169"></a>00169 <span class="keyword">protected</span>: <a name="l00170"></a>00170 <span class="comment"></span> <a name="l00171"></a>00171 <span class="comment"> /**</span> <a name="l00172"></a>00172 <span class="comment"> * The list of values parsed from the CmdLine.</span> <a name="l00173"></a>00173 <span class="comment"> */</span> <a name="l00174"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#abdcaa5c2a11ca40e67c3cdb24ad44787">00174</a> std::vector<T> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#abdcaa5c2a11ca40e67c3cdb24ad44787" title="The list of values parsed from the CmdLine.">_values</a>; <a name="l00175"></a>00175 <span class="comment"></span> <a name="l00176"></a>00176 <span class="comment"> /**</span> <a name="l00177"></a>00177 <span class="comment"> * The description of type T to be used in the usage.</span> <a name="l00178"></a>00178 <span class="comment"> */</span> <a name="l00179"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a32ca12bc926a082637e54cfa26e6b4d9">00179</a> std::string <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a32ca12bc926a082637e54cfa26e6b4d9" title="The description of type T to be used in the usage.">_typeDesc</a>; <a name="l00180"></a>00180 <span class="comment"></span> <a name="l00181"></a>00181 <span class="comment"> /**</span> <a name="l00182"></a>00182 <span class="comment"> * A list of constraint on this Arg. </span> <a name="l00183"></a>00183 <span class="comment"> */</span> <a name="l00184"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#ad49e0de4050e61292fb63db7f001f3af">00184</a> <a class="code" href="class_t_c_l_a_p_1_1_constraint.html">Constraint<T></a>* <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#ad49e0de4050e61292fb63db7f001f3af" title="A list of constraint on this Arg.">_constraint</a>; <a name="l00185"></a>00185 <span class="comment"></span> <a name="l00186"></a>00186 <span class="comment"> /**</span> <a name="l00187"></a>00187 <span class="comment"> * Extracts the value from the string.</span> <a name="l00188"></a>00188 <span class="comment"> * Attempts to parse string as type T, if this fails an exception</span> <a name="l00189"></a>00189 <span class="comment"> * is thrown.</span> <a name="l00190"></a>00190 <span class="comment"> * \param val - The string to be read.</span> <a name="l00191"></a>00191 <span class="comment"> */</span> <a name="l00192"></a>00192 <span class="keywordtype">void</span> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a8bed6f0d24f677dfaf4e1bc50c035b50" title="Extracts the value from the string.">_extractValue</a>( <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& val ); <a name="l00193"></a>00193 <a name="l00194"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a63243dd7c1cf6d6a4d7e99bd764d7fd7">00194</a> <span class="keywordtype">bool</span> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a63243dd7c1cf6d6a4d7e99bd764d7fd7">_allowMore</a>; <a name="l00195"></a>00195 <a name="l00196"></a>00196 <span class="keyword">public</span>: <a name="l00197"></a>00197 <span class="comment"></span> <a name="l00198"></a>00198 <span class="comment"> /**</span> <a name="l00199"></a>00199 <span class="comment"> * Constructor.</span> <a name="l00200"></a>00200 <span class="comment"> * \param flag - The one character flag that identifies this</span> <a name="l00201"></a>00201 <span class="comment"> * argument on the command line.</span> <a name="l00202"></a>00202 <span class="comment"> * \param name - A one word name for the argument. Can be</span> <a name="l00203"></a>00203 <span class="comment"> * used as a long flag on the command line.</span> <a name="l00204"></a>00204 <span class="comment"> * \param desc - A description of what the argument is for or</span> <a name="l00205"></a>00205 <span class="comment"> * does.</span> <a name="l00206"></a>00206 <span class="comment"> * \param req - Whether the argument is required on the command</span> <a name="l00207"></a>00207 <span class="comment"> * line.</span> <a name="l00208"></a>00208 <span class="comment"> * \param typeDesc - A short, human readable description of the</span> <a name="l00209"></a>00209 <span class="comment"> * type that this object expects. This is used in the generation</span> <a name="l00210"></a>00210 <span class="comment"> * of the USAGE statement. The goal is to be helpful to the end user</span> <a name="l00211"></a>00211 <span class="comment"> * of the program.</span> <a name="l00212"></a>00212 <span class="comment"> * \param v - An optional visitor. You probably should not</span> <a name="l00213"></a>00213 <span class="comment"> * use this unless you have a very good reason.</span> <a name="l00214"></a>00214 <span class="comment"> */</span> <a name="l00215"></a>00215 <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a1adf1287dba853b95213516bbedbbb62" title="Constructor.">MultiArg</a>( <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& flag, <a name="l00216"></a>00216 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& name, <a name="l00217"></a>00217 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& desc, <a name="l00218"></a>00218 <span class="keywordtype">bool</span> req, <a name="l00219"></a>00219 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& typeDesc, <a name="l00220"></a>00220 <a class="code" href="class_t_c_l_a_p_1_1_visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL); <a name="l00221"></a>00221 <span class="comment"></span> <a name="l00222"></a>00222 <span class="comment"> /**</span> <a name="l00223"></a>00223 <span class="comment"> * Constructor.</span> <a name="l00224"></a>00224 <span class="comment"> * \param flag - The one character flag that identifies this</span> <a name="l00225"></a>00225 <span class="comment"> * argument on the command line.</span> <a name="l00226"></a>00226 <span class="comment"> * \param name - A one word name for the argument. Can be</span> <a name="l00227"></a>00227 <span class="comment"> * used as a long flag on the command line.</span> <a name="l00228"></a>00228 <span class="comment"> * \param desc - A description of what the argument is for or</span> <a name="l00229"></a>00229 <span class="comment"> * does.</span> <a name="l00230"></a>00230 <span class="comment"> * \param req - Whether the argument is required on the command</span> <a name="l00231"></a>00231 <span class="comment"> * line.</span> <a name="l00232"></a>00232 <span class="comment"> * \param typeDesc - A short, human readable description of the</span> <a name="l00233"></a>00233 <span class="comment"> * type that this object expects. This is used in the generation</span> <a name="l00234"></a>00234 <span class="comment"> * of the USAGE statement. The goal is to be helpful to the end user</span> <a name="l00235"></a>00235 <span class="comment"> * of the program.</span> <a name="l00236"></a>00236 <span class="comment"> * \param parser - A CmdLine parser object to add this Arg to</span> <a name="l00237"></a>00237 <span class="comment"> * \param v - An optional visitor. You probably should not</span> <a name="l00238"></a>00238 <span class="comment"> * use this unless you have a very good reason.</span> <a name="l00239"></a>00239 <span class="comment"> */</span> <a name="l00240"></a>00240 <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a1adf1287dba853b95213516bbedbbb62" title="Constructor.">MultiArg</a>( <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& flag, <a name="l00241"></a>00241 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& name, <a name="l00242"></a>00242 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& desc, <a name="l00243"></a>00243 <span class="keywordtype">bool</span> req, <a name="l00244"></a>00244 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& typeDesc, <a name="l00245"></a>00245 <a class="code" href="class_t_c_l_a_p_1_1_cmd_line_interface.html" title="The base class that manages the command line definition and passes along the parsing to the appropria...">CmdLineInterface</a>& parser, <a name="l00246"></a>00246 <a class="code" href="class_t_c_l_a_p_1_1_visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL ); <a name="l00247"></a>00247 <span class="comment"></span> <a name="l00248"></a>00248 <span class="comment"> /**</span> <a name="l00249"></a>00249 <span class="comment"> * Constructor.</span> <a name="l00250"></a>00250 <span class="comment"> * \param flag - The one character flag that identifies this</span> <a name="l00251"></a>00251 <span class="comment"> * argument on the command line.</span> <a name="l00252"></a>00252 <span class="comment"> * \param name - A one word name for the argument. Can be</span> <a name="l00253"></a>00253 <span class="comment"> * used as a long flag on the command line.</span> <a name="l00254"></a>00254 <span class="comment"> * \param desc - A description of what the argument is for or</span> <a name="l00255"></a>00255 <span class="comment"> * does.</span> <a name="l00256"></a>00256 <span class="comment"> * \param req - Whether the argument is required on the command</span> <a name="l00257"></a>00257 <span class="comment"> * line.</span> <a name="l00258"></a>00258 <span class="comment"> * \param constraint - A pointer to a Constraint object used</span> <a name="l00259"></a>00259 <span class="comment"> * to constrain this Arg.</span> <a name="l00260"></a>00260 <span class="comment"> * \param v - An optional visitor. You probably should not</span> <a name="l00261"></a>00261 <span class="comment"> * use this unless you have a very good reason.</span> <a name="l00262"></a>00262 <span class="comment"> */</span> <a name="l00263"></a>00263 <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a1adf1287dba853b95213516bbedbbb62" title="Constructor.">MultiArg</a>( <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& flag, <a name="l00264"></a>00264 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& name, <a name="l00265"></a>00265 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& desc, <a name="l00266"></a>00266 <span class="keywordtype">bool</span> req, <a name="l00267"></a>00267 <a class="code" href="class_t_c_l_a_p_1_1_constraint.html">Constraint<T></a>* constraint, <a name="l00268"></a>00268 <a class="code" href="class_t_c_l_a_p_1_1_visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL ); <a name="l00269"></a>00269 <span class="comment"></span> <a name="l00270"></a>00270 <span class="comment"> /**</span> <a name="l00271"></a>00271 <span class="comment"> * Constructor.</span> <a name="l00272"></a>00272 <span class="comment"> * \param flag - The one character flag that identifies this</span> <a name="l00273"></a>00273 <span class="comment"> * argument on the command line.</span> <a name="l00274"></a>00274 <span class="comment"> * \param name - A one word name for the argument. Can be</span> <a name="l00275"></a>00275 <span class="comment"> * used as a long flag on the command line.</span> <a name="l00276"></a>00276 <span class="comment"> * \param desc - A description of what the argument is for or</span> <a name="l00277"></a>00277 <span class="comment"> * does.</span> <a name="l00278"></a>00278 <span class="comment"> * \param req - Whether the argument is required on the command</span> <a name="l00279"></a>00279 <span class="comment"> * line.</span> <a name="l00280"></a>00280 <span class="comment"> * \param constraint - A pointer to a Constraint object used</span> <a name="l00281"></a>00281 <span class="comment"> * to constrain this Arg.</span> <a name="l00282"></a>00282 <span class="comment"> * \param parser - A CmdLine parser object to add this Arg to</span> <a name="l00283"></a>00283 <span class="comment"> * \param v - An optional visitor. You probably should not</span> <a name="l00284"></a>00284 <span class="comment"> * use this unless you have a very good reason.</span> <a name="l00285"></a>00285 <span class="comment"> */</span> <a name="l00286"></a>00286 <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a1adf1287dba853b95213516bbedbbb62" title="Constructor.">MultiArg</a>( <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& flag, <a name="l00287"></a>00287 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& name, <a name="l00288"></a>00288 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& desc, <a name="l00289"></a>00289 <span class="keywordtype">bool</span> req, <a name="l00290"></a>00290 <a class="code" href="class_t_c_l_a_p_1_1_constraint.html">Constraint<T></a>* constraint, <a name="l00291"></a>00291 <a class="code" href="class_t_c_l_a_p_1_1_cmd_line_interface.html" title="The base class that manages the command line definition and passes along the parsing to the appropria...">CmdLineInterface</a>& parser, <a name="l00292"></a>00292 <a class="code" href="class_t_c_l_a_p_1_1_visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v = NULL ); <a name="l00293"></a>00293 <span class="comment"></span> <a name="l00294"></a>00294 <span class="comment"> /**</span> <a name="l00295"></a>00295 <span class="comment"> * Handles the processing of the argument.</span> <a name="l00296"></a>00296 <span class="comment"> * This re-implements the Arg version of this method to set the</span> <a name="l00297"></a>00297 <span class="comment"> * _value of the argument appropriately. It knows the difference</span> <a name="l00298"></a>00298 <span class="comment"> * between labeled and unlabeled.</span> <a name="l00299"></a>00299 <span class="comment"> * \param i - Pointer the the current argument in the list.</span> <a name="l00300"></a>00300 <span class="comment"> * \param args - Mutable list of strings. Passed from main().</span> <a name="l00301"></a>00301 <span class="comment"> */</span> <a name="l00302"></a>00302 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a357e850e230cf7537c13d776f278c2ef" title="Handles the processing of the argument.">processArg</a>(<span class="keywordtype">int</span>* i, <a class="code" href="classstd_1_1vector.html">std::vector<std::string></a>& args); <a name="l00303"></a>00303 <span class="comment"></span> <a name="l00304"></a>00304 <span class="comment"> /**</span> <a name="l00305"></a>00305 <span class="comment"> * Returns a vector of type T containing the values parsed from</span> <a name="l00306"></a>00306 <span class="comment"> * the command line.</span> <a name="l00307"></a>00307 <span class="comment"> */</span> <a name="l00308"></a>00308 <span class="keyword">const</span> std::vector<T>& <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a4921ee91019d6bbe2bdfb1245b291a06" title="Returns a vector of type T containing the values parsed from the command line.">getValue</a>(); <a name="l00309"></a>00309 <span class="comment"></span> <a name="l00310"></a>00310 <span class="comment"> /**</span> <a name="l00311"></a>00311 <span class="comment"> * Returns the a short id string. Used in the usage. </span> <a name="l00312"></a>00312 <span class="comment"> * \param val - value to be used.</span> <a name="l00313"></a>00313 <span class="comment"> */</span> <a name="l00314"></a>00314 <span class="keyword">virtual</span> std::string <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#abe2ad6623b2959e4236bde1433c10bc2" title="Returns the a short id string.">shortID</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& val=<span class="stringliteral">"val"</span>) <span class="keyword">const</span>; <a name="l00315"></a>00315 <span class="comment"></span> <a name="l00316"></a>00316 <span class="comment"> /**</span> <a name="l00317"></a>00317 <span class="comment"> * Returns the a long id string. Used in the usage. </span> <a name="l00318"></a>00318 <span class="comment"> * \param val - value to be used.</span> <a name="l00319"></a>00319 <span class="comment"> */</span> <a name="l00320"></a>00320 <span class="keyword">virtual</span> std::string <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#ac5d45a5ae312d148e47b01a9e9d8c157" title="Returns the a long id string.">longID</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& val=<span class="stringliteral">"val"</span>) <span class="keyword">const</span>; <a name="l00321"></a>00321 <span class="comment"></span> <a name="l00322"></a>00322 <span class="comment"> /**</span> <a name="l00323"></a>00323 <span class="comment"> * Once we've matched the first value, then the arg is no longer</span> <a name="l00324"></a>00324 <span class="comment"> * required.</span> <a name="l00325"></a>00325 <span class="comment"> */</span> <a name="l00326"></a>00326 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#add0f8021548e5f2a37674f47788af8b0" title="Once we've matched the first value, then the arg is no longer required.">isRequired</a>() <span class="keyword">const</span>; <a name="l00327"></a>00327 <a name="l00328"></a>00328 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#aef3bed723518c4361362c73f37830e82">allowMore</a>(); <a name="l00329"></a>00329 <a name="l00330"></a>00330 }; <a name="l00331"></a>00331 <a name="l00332"></a>00332 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00333"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a1adf1287dba853b95213516bbedbbb62">00333</a> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a1adf1287dba853b95213516bbedbbb62" title="Constructor.">MultiArg<T>::MultiArg</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& flag, <a name="l00334"></a>00334 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& name, <a name="l00335"></a>00335 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& desc, <a name="l00336"></a>00336 <span class="keywordtype">bool</span> req, <a name="l00337"></a>00337 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& typeDesc, <a name="l00338"></a>00338 <a class="code" href="class_t_c_l_a_p_1_1_visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v) <a name="l00339"></a>00339 : <a class="code" href="class_t_c_l_a_p_1_1_arg.html" title="A virtual base class that defines the essential data for all arguments.">Arg</a>( flag, name, desc, req, true, v ), <a name="l00340"></a>00340 _typeDesc( typeDesc ), <a name="l00341"></a>00341 _constraint( NULL ), <a name="l00342"></a>00342 _allowMore(false) <a name="l00343"></a>00343 { <a name="l00344"></a>00344 <a class="code" href="class_t_c_l_a_p_1_1_arg.html#a13130a9a5d22c57a6d42a8883c9b1e0f">_acceptsMultipleValues</a> = <span class="keyword">true</span>; <a name="l00345"></a>00345 } <a name="l00346"></a>00346 <a name="l00347"></a>00347 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00348"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a55406e77b0397566d6e002c8fdb29422">00348</a> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a1adf1287dba853b95213516bbedbbb62" title="Constructor.">MultiArg<T>::MultiArg</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& flag, <a name="l00349"></a>00349 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& name, <a name="l00350"></a>00350 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& desc, <a name="l00351"></a>00351 <span class="keywordtype">bool</span> req, <a name="l00352"></a>00352 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& typeDesc, <a name="l00353"></a>00353 <a class="code" href="class_t_c_l_a_p_1_1_cmd_line_interface.html" title="The base class that manages the command line definition and passes along the parsing to the appropria...">CmdLineInterface</a>& parser, <a name="l00354"></a>00354 <a class="code" href="class_t_c_l_a_p_1_1_visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v) <a name="l00355"></a>00355 : <a class="code" href="class_t_c_l_a_p_1_1_arg.html" title="A virtual base class that defines the essential data for all arguments.">Arg</a>( flag, name, desc, req, true, v ), <a name="l00356"></a>00356 _typeDesc( typeDesc ), <a name="l00357"></a>00357 _constraint( NULL ), <a name="l00358"></a>00358 _allowMore(false) <a name="l00359"></a>00359 { <a name="l00360"></a>00360 parser.<a class="code" href="class_t_c_l_a_p_1_1_cmd_line_interface.html#a13b29ab754c030185e58f779dc355631" title="Adds an argument to the list of arguments to be parsed.">add</a>( <span class="keyword">this</span> ); <a name="l00361"></a>00361 <a class="code" href="class_t_c_l_a_p_1_1_arg.html#a13130a9a5d22c57a6d42a8883c9b1e0f">_acceptsMultipleValues</a> = <span class="keyword">true</span>; <a name="l00362"></a>00362 } <a name="l00363"></a>00363 <span class="comment"></span> <a name="l00364"></a>00364 <span class="comment">/**</span> <a name="l00365"></a>00365 <span class="comment"> *</span> <a name="l00366"></a>00366 <span class="comment"> */</span> <a name="l00367"></a>00367 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00368"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a572fb5f8ffe6a37919b9f836bb81c42d">00368</a> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a1adf1287dba853b95213516bbedbbb62" title="Constructor.">MultiArg<T>::MultiArg</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& flag, <a name="l00369"></a>00369 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& name, <a name="l00370"></a>00370 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& desc, <a name="l00371"></a>00371 <span class="keywordtype">bool</span> req, <a name="l00372"></a>00372 <a class="code" href="class_t_c_l_a_p_1_1_constraint.html">Constraint<T></a>* constraint, <a name="l00373"></a>00373 <a class="code" href="class_t_c_l_a_p_1_1_visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v) <a name="l00374"></a>00374 : <a class="code" href="class_t_c_l_a_p_1_1_arg.html" title="A virtual base class that defines the essential data for all arguments.">Arg</a>( flag, name, desc, req, true, v ), <a name="l00375"></a>00375 _typeDesc( constraint->shortID() ), <a name="l00376"></a>00376 _constraint( constraint ), <a name="l00377"></a>00377 _allowMore(false) <a name="l00378"></a>00378 { <a name="l00379"></a>00379 <a class="code" href="class_t_c_l_a_p_1_1_arg.html#a13130a9a5d22c57a6d42a8883c9b1e0f">_acceptsMultipleValues</a> = <span class="keyword">true</span>; <a name="l00380"></a>00380 } <a name="l00381"></a>00381 <a name="l00382"></a>00382 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00383"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#ac492a414219e65a41054e035997df4d8">00383</a> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a1adf1287dba853b95213516bbedbbb62" title="Constructor.">MultiArg<T>::MultiArg</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& flag, <a name="l00384"></a>00384 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& name, <a name="l00385"></a>00385 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& desc, <a name="l00386"></a>00386 <span class="keywordtype">bool</span> req, <a name="l00387"></a>00387 <a class="code" href="class_t_c_l_a_p_1_1_constraint.html">Constraint<T></a>* constraint, <a name="l00388"></a>00388 <a class="code" href="class_t_c_l_a_p_1_1_cmd_line_interface.html" title="The base class that manages the command line definition and passes along the parsing to the appropria...">CmdLineInterface</a>& parser, <a name="l00389"></a>00389 <a class="code" href="class_t_c_l_a_p_1_1_visitor.html" title="A base class that defines the interface for visitors.">Visitor</a>* v) <a name="l00390"></a>00390 : <a class="code" href="class_t_c_l_a_p_1_1_arg.html" title="A virtual base class that defines the essential data for all arguments.">Arg</a>( flag, name, desc, req, true, v ), <a name="l00391"></a>00391 _typeDesc( constraint->shortID() ), <a name="l00392"></a>00392 _constraint( constraint ), <a name="l00393"></a>00393 _allowMore(false) <a name="l00394"></a>00394 { <a name="l00395"></a>00395 parser.<a class="code" href="class_t_c_l_a_p_1_1_cmd_line_interface.html#a13b29ab754c030185e58f779dc355631" title="Adds an argument to the list of arguments to be parsed.">add</a>( <span class="keyword">this</span> ); <a name="l00396"></a>00396 <a class="code" href="class_t_c_l_a_p_1_1_arg.html#a13130a9a5d22c57a6d42a8883c9b1e0f">_acceptsMultipleValues</a> = <span class="keyword">true</span>; <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="class_t_c_l_a_p_1_1_multi_arg.html#a4921ee91019d6bbe2bdfb1245b291a06">00400</a> <span class="keyword">const</span> std::vector<T>& <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a4921ee91019d6bbe2bdfb1245b291a06" title="Returns a vector of type T containing the values parsed from the command line.">MultiArg<T>::getValue</a>() { <span class="keywordflow">return</span> _values; } <a name="l00401"></a>00401 <a name="l00402"></a>00402 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00403"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a357e850e230cf7537c13d776f278c2ef">00403</a> <span class="keywordtype">bool</span> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html" title="An argument that allows multiple values of type T to be specified.">MultiArg<T>::processArg</a>(<span class="keywordtype">int</span> *i, <a class="code" href="classstd_1_1vector.html">std::vector<std::string></a>& args) <a name="l00404"></a>00404 { <a name="l00405"></a>00405 <span class="keywordflow">if</span> ( _ignoreable && Arg::ignoreRest() ) <a name="l00406"></a>00406 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00407"></a>00407 <a name="l00408"></a>00408 <span class="keywordflow">if</span> ( _hasBlanks( args[*i] ) ) <a name="l00409"></a>00409 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00410"></a>00410 <a name="l00411"></a>00411 std::string flag = args[*i]; <a name="l00412"></a>00412 std::string value = <span class="stringliteral">""</span>; <a name="l00413"></a>00413 <a name="l00414"></a>00414 trimFlag( flag, value ); <a name="l00415"></a>00415 <a name="l00416"></a>00416 <span class="keywordflow">if</span> ( argMatches( flag ) ) <a name="l00417"></a>00417 { <a name="l00418"></a>00418 <span class="keywordflow">if</span> ( Arg::delimiter() != <span class="charliteral">' '</span> && value == <span class="stringliteral">""</span> ) <a name="l00419"></a>00419 <span class="keywordflow">throw</span>( <a class="code" href="class_t_c_l_a_p_1_1_arg_parse_exception.html" title="Thrown from within the child Arg classes when it fails to properly parse the argument it has been pas...">ArgParseException</a>( <a name="l00420"></a>00420 <span class="stringliteral">"Couldn't find delimiter for this argument!"</span>, <a name="l00421"></a>00421 toString() ) ); <a name="l00422"></a>00422 <a name="l00423"></a>00423 <span class="comment">// always take the first one, regardless of start string</span> <a name="l00424"></a>00424 <span class="keywordflow">if</span> ( value == <span class="stringliteral">""</span> ) <a name="l00425"></a>00425 { <a name="l00426"></a>00426 (*i)++; <a name="l00427"></a>00427 <span class="keywordflow">if</span> ( static_cast<unsigned int>(*i) < args.size() ) <a name="l00428"></a>00428 _extractValue( args[*i] ); <a name="l00429"></a>00429 <span class="keywordflow">else</span> <a name="l00430"></a>00430 <span class="keywordflow">throw</span>( <a class="code" href="class_t_c_l_a_p_1_1_arg_parse_exception.html" title="Thrown from within the child Arg classes when it fails to properly parse the argument it has been pas...">ArgParseException</a>(<span class="stringliteral">"Missing a value for this argument!"</span>, <a name="l00431"></a>00431 toString() ) ); <a name="l00432"></a>00432 } <a name="l00433"></a>00433 <span class="keywordflow">else</span> <a name="l00434"></a>00434 _extractValue( value ); <a name="l00435"></a>00435 <a name="l00436"></a>00436 <span class="comment">/*</span> <a name="l00437"></a>00437 <span class="comment"> // continuing taking the args until we hit one with a start string </span> <a name="l00438"></a>00438 <span class="comment"> while ( (unsigned int)(*i)+1 < args.size() &&</span> <a name="l00439"></a>00439 <span class="comment"> args[(*i)+1].find_first_of( Arg::flagStartString() ) != 0 &&</span> <a name="l00440"></a>00440 <span class="comment"> args[(*i)+1].find_first_of( Arg::nameStartString() ) != 0 ) </span> <a name="l00441"></a>00441 <span class="comment"> _extractValue( args[++(*i)] );</span> <a name="l00442"></a>00442 <span class="comment"> */</span> <a name="l00443"></a>00443 <a name="l00444"></a>00444 _alreadySet = <span class="keyword">true</span>; <a name="l00445"></a>00445 _checkWithVisitor(); <a name="l00446"></a>00446 <a name="l00447"></a>00447 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00448"></a>00448 } <a name="l00449"></a>00449 <span class="keywordflow">else</span> <a name="l00450"></a>00450 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00451"></a>00451 } <a name="l00452"></a>00452 <span class="comment"></span> <a name="l00453"></a>00453 <span class="comment">/**</span> <a name="l00454"></a>00454 <span class="comment"> *</span> <a name="l00455"></a>00455 <span class="comment"> */</span> <a name="l00456"></a>00456 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00457"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#abe2ad6623b2959e4236bde1433c10bc2">00457</a> std::string <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html" title="An argument that allows multiple values of type T to be specified.">MultiArg<T>::shortID</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& val)<span class="keyword"> const</span> <a name="l00458"></a>00458 <span class="keyword"></span>{ <a name="l00459"></a>00459 std::string <span class="keywordtype">id</span> = Arg::shortID(_typeDesc) + <span class="stringliteral">" ... "</span>; <a name="l00460"></a>00460 <a name="l00461"></a>00461 <span class="keywordflow">return</span> id; <a name="l00462"></a>00462 } <a name="l00463"></a>00463 <span class="comment"></span> <a name="l00464"></a>00464 <span class="comment">/**</span> <a name="l00465"></a>00465 <span class="comment"> *</span> <a name="l00466"></a>00466 <span class="comment"> */</span> <a name="l00467"></a>00467 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00468"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#ac5d45a5ae312d148e47b01a9e9d8c157">00468</a> std::string <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html" title="An argument that allows multiple values of type T to be specified.">MultiArg<T>::longID</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& val)<span class="keyword"> const</span> <a name="l00469"></a>00469 <span class="keyword"></span>{ <a name="l00470"></a>00470 std::string <span class="keywordtype">id</span> = Arg::longID(_typeDesc) + <span class="stringliteral">" (accepted multiple times)"</span>; <a name="l00471"></a>00471 <a name="l00472"></a>00472 <span class="keywordflow">return</span> id; <a name="l00473"></a>00473 } <a name="l00474"></a>00474 <span class="comment"></span> <a name="l00475"></a>00475 <span class="comment">/**</span> <a name="l00476"></a>00476 <span class="comment"> * Once we've matched the first value, then the arg is no longer</span> <a name="l00477"></a>00477 <span class="comment"> * required.</span> <a name="l00478"></a>00478 <span class="comment"> */</span> <a name="l00479"></a>00479 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00480"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#add0f8021548e5f2a37674f47788af8b0">00480</a> <span class="keywordtype">bool</span> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html" title="An argument that allows multiple values of type T to be specified.">MultiArg<T>::isRequired</a>()<span class="keyword"> const</span> <a name="l00481"></a>00481 <span class="keyword"></span>{ <a name="l00482"></a>00482 <span class="keywordflow">if</span> ( _required ) <a name="l00483"></a>00483 { <a name="l00484"></a>00484 <span class="keywordflow">if</span> ( _values.size() > 1 ) <a name="l00485"></a>00485 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00486"></a>00486 <span class="keywordflow">else</span> <a name="l00487"></a>00487 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00488"></a>00488 } <a name="l00489"></a>00489 <span class="keywordflow">else</span> <a name="l00490"></a>00490 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00491"></a>00491 <a name="l00492"></a>00492 } <a name="l00493"></a>00493 <a name="l00494"></a>00494 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00495"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#a8bed6f0d24f677dfaf4e1bc50c035b50">00495</a> <span class="keywordtype">void</span> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html" title="An argument that allows multiple values of type T to be specified.">MultiArg<T>::_extractValue</a>( <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>& val ) <a name="l00496"></a>00496 { <a name="l00497"></a>00497 MULTI_ARG_HELPER::ValueExtractor<T> ve(_values); <a name="l00498"></a>00498 <a name="l00499"></a>00499 <span class="keywordtype">int</span> err = ve.<a class="code" href="class_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r_1_1_value_extractor.html#a926cf2e3cdb09512334f5f228a81c821" title="Method that will attempt to parse the input stream for values of type T.">extractValue</a>(val); <a name="l00500"></a>00500 <a name="l00501"></a>00501 <span class="keywordflow">if</span> ( err == <a class="code" href="namespace_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r.html#a05e9d7d66a5aebe00a18ed3e642171b8a34e78ac3b2516d88e25b585302d0b583">MULTI_ARG_HELPER::EXTRACT_FAILURE</a> ) <a name="l00502"></a>00502 <span class="keywordflow">throw</span>( <a class="code" href="class_t_c_l_a_p_1_1_arg_parse_exception.html" title="Thrown from within the child Arg classes when it fails to properly parse the argument it has been pas...">ArgParseException</a>(<span class="stringliteral">"Couldn't read argument value "</span> <a name="l00503"></a>00503 <span class="stringliteral">"from string '"</span> + val + <span class="stringliteral">"'"</span>, toString() ) ); <a name="l00504"></a>00504 <a name="l00505"></a>00505 <span class="keywordflow">if</span>(err == <a class="code" href="namespace_t_c_l_a_p_1_1_m_u_l_t_i___a_r_g___h_e_l_p_e_r.html#a05e9d7d66a5aebe00a18ed3e642171b8a3a8b1e6fa3593f61a712dea63322da0d">MULTI_ARG_HELPER::EXTRACT_TOO_MANY</a>) <a name="l00506"></a>00506 <span class="keywordflow">throw</span>( <a class="code" href="class_t_c_l_a_p_1_1_arg_parse_exception.html" title="Thrown from within the child Arg classes when it fails to properly parse the argument it has been pas...">ArgParseException</a>(<span class="stringliteral">"More than one valid value "</span> <a name="l00507"></a>00507 <span class="stringliteral">"parsed from string '"</span> + val + <span class="stringliteral">"'"</span>, <a name="l00508"></a>00508 toString() ) ); <a name="l00509"></a>00509 <span class="keywordflow">if</span> ( _constraint != NULL ) <a name="l00510"></a>00510 <span class="keywordflow">if</span> ( ! _constraint->check( _values.back() ) ) <a name="l00511"></a>00511 <span class="keywordflow">throw</span>( <a class="code" href="class_t_c_l_a_p_1_1_cmd_line_parse_exception.html" title="Thrown from CmdLine when the arguments on the command line are not properly specified, e.g.">CmdLineParseException</a>( <span class="stringliteral">"Value '"</span> + val + <a name="l00512"></a>00512 <span class="stringliteral">"' does not meet constraint: "</span> + <a name="l00513"></a>00513 _constraint->description(), <a name="l00514"></a>00514 toString() ) ); <a name="l00515"></a>00515 } <a name="l00516"></a>00516 <a name="l00517"></a>00517 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00518"></a><a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html#aef3bed723518c4361362c73f37830e82">00518</a> <span class="keywordtype">bool</span> <a class="code" href="class_t_c_l_a_p_1_1_multi_arg.html" title="An argument that allows multiple values of type T to be specified.">MultiArg<T>::allowMore</a>() <a name="l00519"></a>00519 { <a name="l00520"></a>00520 <span class="keywordtype">bool</span> am = _allowMore; <a name="l00521"></a>00521 _allowMore = <span class="keyword">true</span>; <a name="l00522"></a>00522 <span class="keywordflow">return</span> am; <a name="l00523"></a>00523 } <a name="l00524"></a>00524 <a name="l00525"></a>00525 } <span class="comment">// namespace TCLAP</span> <a name="l00526"></a>00526 <a name="l00527"></a>00527 <span class="preprocessor">#endif</span> </pre></div></div> </div> <br><hr><br> <table border="0" width="100%"> <tr> <td> Page generated by <a href="http://www.doxygen.org" target="_blank">Doxygen 1.7.5</a> for MRPT 0.9.5 SVN: at Sun Sep 25 17:20:18 UTC 2011</td><td></td> <td width="100"> </td> <td width="150"> </td></tr> </table> </body></html>