<!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: ArgException.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>ArgException.h</h1><a href="ArgException_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-</span> <a name="l00002"></a>00002 <a name="l00003"></a>00003 <span class="comment">/****************************************************************************** </span> <a name="l00004"></a>00004 <span class="comment"> * </span> <a name="l00005"></a>00005 <span class="comment"> * file: ArgException.h</span> <a name="l00006"></a>00006 <span class="comment"> * </span> <a name="l00007"></a>00007 <span class="comment"> * Copyright (c) 2003, Michael E. Smoot .</span> <a name="l00008"></a>00008 <span class="comment"> * All rights reverved.</span> <a name="l00009"></a>00009 <span class="comment"> * </span> <a name="l00010"></a>00010 <span class="comment"> * See the file COPYING in the top directory of this distribution for</span> <a name="l00011"></a>00011 <span class="comment"> * more information.</span> <a name="l00012"></a>00012 <span class="comment"> * </span> <a name="l00013"></a>00013 <span class="comment"> * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS </span> <a name="l00014"></a>00014 <span class="comment"> * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, </span> <a name="l00015"></a>00015 <span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL </span> <a name="l00016"></a>00016 <span class="comment"> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER </span> <a name="l00017"></a>00017 <span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING </span> <a name="l00018"></a>00018 <span class="comment"> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER </span> <a name="l00019"></a>00019 <span class="comment"> * DEALINGS IN THE SOFTWARE. </span> <a name="l00020"></a>00020 <span class="comment"> * </span> <a name="l00021"></a>00021 <span class="comment"> *****************************************************************************/</span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <a name="l00024"></a>00024 <span class="preprocessor">#ifndef TCLAP_ARG_EXCEPTION_H</span> <a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor">#define TCLAP_ARG_EXCEPTION_H</span> <a name="l00026"></a>00026 <span class="preprocessor"></span> <a name="l00027"></a>00027 <span class="preprocessor">#include <string></span> <a name="l00028"></a>00028 <span class="preprocessor">#include <exception></span> <a name="l00029"></a>00029 <a name="l00030"></a>00030 <span class="keyword">namespace </span>TCLAP { <a name="l00031"></a>00031 <a name="l00036"></a><a class="code" href="classTCLAP_1_1ArgException.html">00036</a> <span class="keyword">class </span><a class="code" href="classTCLAP_1_1ArgException.html" title="A simple class that defines and argument exception.">ArgException</a> : <span class="keyword">public</span> std::exception <a name="l00037"></a>00037 { <a name="l00038"></a>00038 <span class="keyword">public</span>: <a name="l00039"></a>00039 <a name="l00047"></a><a class="code" href="classTCLAP_1_1ArgException.html#a67389912b628e95d530f8bb8de97b309">00047</a> <a class="code" href="classTCLAP_1_1ArgException.html#a67389912b628e95d530f8bb8de97b309" title="Constructor.">ArgException</a>( <span class="keyword">const</span> std::string& text = <span class="stringliteral">"undefined exception"</span>, <a name="l00048"></a>00048 <span class="keyword">const</span> std::string& <span class="keywordtype">id</span> = <span class="stringliteral">"undefined"</span>, <a name="l00049"></a>00049 <span class="keyword">const</span> std::string& td = <span class="stringliteral">"Generic ArgException"</span>) <a name="l00050"></a>00050 : std::exception(), <a name="l00051"></a>00051 _errorText(text), <a name="l00052"></a>00052 _argId( id ), <a name="l00053"></a>00053 _typeDescription(td) <a name="l00054"></a>00054 { } <a name="l00055"></a>00055 <a name="l00059"></a><a class="code" href="classTCLAP_1_1ArgException.html#a5c5df6a814b05c623a01607fb82980f4">00059</a> <span class="keyword">virtual</span> <a class="code" href="classTCLAP_1_1ArgException.html#a5c5df6a814b05c623a01607fb82980f4" title="Destructor.">~ArgException</a>() throw() { } <a name="l00060"></a>00060 <a name="l00064"></a><a class="code" href="classTCLAP_1_1ArgException.html#a0656dab88a7129bc288821bacd653d08">00064</a> std::string <a class="code" href="classTCLAP_1_1ArgException.html#a0656dab88a7129bc288821bacd653d08" title="Returns the error text.">error</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> ( _errorText ); } <a name="l00065"></a>00065 <a name="l00069"></a><a class="code" href="classTCLAP_1_1ArgException.html#a18ffd1ad34c1799865f8e03df4ebdff1">00069</a> std::string <a class="code" href="classTCLAP_1_1ArgException.html#a18ffd1ad34c1799865f8e03df4ebdff1" title="Returns the argument id.">argId</a>()<span class="keyword"> const </span> <a name="l00070"></a>00070 <span class="keyword"> </span>{ <a name="l00071"></a>00071 <span class="keywordflow">if</span> ( _argId == <span class="stringliteral">"undefined"</span> ) <a name="l00072"></a>00072 <span class="keywordflow">return</span> <span class="stringliteral">" "</span>; <a name="l00073"></a>00073 <span class="keywordflow">else</span> <a name="l00074"></a>00074 <span class="keywordflow">return</span> ( <span class="stringliteral">"Argument: "</span> + _argId ); <a name="l00075"></a>00075 } <a name="l00076"></a>00076 <a name="l00080"></a><a class="code" href="classTCLAP_1_1ArgException.html#af51c89da2e4ae54fc9d05038ea484c83">00080</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classTCLAP_1_1ArgException.html#af51c89da2e4ae54fc9d05038ea484c83" title="Returns the arg id and error text.">what</a>() <span class="keyword">const</span> throw() <a name="l00081"></a>00081 { <a name="l00082"></a>00082 <span class="keyword">static</span> std::string ex; <a name="l00083"></a>00083 ex = _argId + <span class="stringliteral">" -- "</span> + _errorText; <a name="l00084"></a>00084 <span class="keywordflow">return</span> ex.c_str(); <a name="l00085"></a>00085 } <a name="l00086"></a>00086 <a name="l00091"></a><a class="code" href="classTCLAP_1_1ArgException.html#abd271955e1b808bb92f8db7a16ea7c95">00091</a> std::string <a class="code" href="classTCLAP_1_1ArgException.html#abd271955e1b808bb92f8db7a16ea7c95" title="Returns the type of the exception.">typeDescription</a>()<span class="keyword"> const</span> <a name="l00092"></a>00092 <span class="keyword"> </span>{ <a name="l00093"></a>00093 <span class="keywordflow">return</span> _typeDescription; <a name="l00094"></a>00094 } <a name="l00095"></a>00095 <a name="l00096"></a>00096 <a name="l00097"></a>00097 <span class="keyword">private</span>: <a name="l00098"></a>00098 <a name="l00102"></a>00102 std::string _errorText; <a name="l00103"></a>00103 <a name="l00107"></a>00107 std::string _argId; <a name="l00108"></a>00108 <a name="l00113"></a>00113 std::string _typeDescription; <a name="l00114"></a>00114 <a name="l00115"></a>00115 }; <a name="l00116"></a>00116 <a name="l00121"></a><a class="code" href="classTCLAP_1_1ArgParseException.html">00121</a> <span class="keyword">class </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="keyword">public</span> <a class="code" href="classTCLAP_1_1ArgException.html" title="A simple class that defines and argument exception.">ArgException</a> <a name="l00122"></a>00122 { <a name="l00123"></a>00123 <span class="keyword">public</span>: <a name="l00130"></a><a class="code" href="classTCLAP_1_1ArgParseException.html#aa9d9531405e505afd506491526733285">00130</a> <a class="code" href="classTCLAP_1_1ArgParseException.html#aa9d9531405e505afd506491526733285" title="Constructor.">ArgParseException</a>( <span class="keyword">const</span> std::string& text = <span class="stringliteral">"undefined exception"</span>, <a name="l00131"></a>00131 <span class="keyword">const</span> std::string& <span class="keywordtype">id</span> = <span class="stringliteral">"undefined"</span> ) <a name="l00132"></a>00132 : <a class="code" href="classTCLAP_1_1ArgException.html" title="A simple class that defines and argument exception.">ArgException</a>( text, <a name="l00133"></a>00133 id, <a name="l00134"></a>00134 std::string( <span class="stringliteral">"Exception found while parsing "</span> ) + <a name="l00135"></a>00135 std::string( <span class="stringliteral">"the value the Arg has been passed."</span> )) <a name="l00136"></a>00136 { } <a name="l00137"></a>00137 }; <a name="l00138"></a>00138 <a name="l00143"></a><a class="code" href="classTCLAP_1_1CmdLineParseException.html">00143</a> <span class="keyword">class </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="keyword">public</span> <a class="code" href="classTCLAP_1_1ArgException.html" title="A simple class that defines and argument exception.">ArgException</a> <a name="l00144"></a>00144 { <a name="l00145"></a>00145 <span class="keyword">public</span>: <a name="l00152"></a><a class="code" href="classTCLAP_1_1CmdLineParseException.html#a3b612ba299dd699845ea108b5eaa3249">00152</a> <a class="code" href="classTCLAP_1_1CmdLineParseException.html#a3b612ba299dd699845ea108b5eaa3249" title="Constructor.">CmdLineParseException</a>( <span class="keyword">const</span> std::string& text = <span class="stringliteral">"undefined exception"</span>, <a name="l00153"></a>00153 <span class="keyword">const</span> std::string& <span class="keywordtype">id</span> = <span class="stringliteral">"undefined"</span> ) <a name="l00154"></a>00154 : <a class="code" href="classTCLAP_1_1ArgException.html" title="A simple class that defines and argument exception.">ArgException</a>( text, <a name="l00155"></a>00155 id, <a name="l00156"></a>00156 std::string( <span class="stringliteral">"Exception found when the values "</span>) + <a name="l00157"></a>00157 std::string( <span class="stringliteral">"on the command line do not meet "</span>) + <a name="l00158"></a>00158 std::string( <span class="stringliteral">"the requirements of the defined "</span>) + <a name="l00159"></a>00159 std::string( <span class="stringliteral">"Args."</span> )) <a name="l00160"></a>00160 { } <a name="l00161"></a>00161 }; <a name="l00162"></a>00162 <a name="l00167"></a><a class="code" href="classTCLAP_1_1SpecificationException.html">00167</a> <span class="keyword">class </span><a class="code" href="classTCLAP_1_1SpecificationException.html" title="Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.">SpecificationException</a> : <span class="keyword">public</span> <a class="code" href="classTCLAP_1_1ArgException.html" title="A simple class that defines and argument exception.">ArgException</a> <a name="l00168"></a>00168 { <a name="l00169"></a>00169 <span class="keyword">public</span>: <a name="l00176"></a><a class="code" href="classTCLAP_1_1SpecificationException.html#ad817016f03ebf4fc371e168636132abd">00176</a> <a class="code" href="classTCLAP_1_1SpecificationException.html#ad817016f03ebf4fc371e168636132abd" title="Constructor.">SpecificationException</a>( <span class="keyword">const</span> std::string& text = <span class="stringliteral">"undefined exception"</span>, <a name="l00177"></a>00177 <span class="keyword">const</span> std::string& <span class="keywordtype">id</span> = <span class="stringliteral">"undefined"</span> ) <a name="l00178"></a>00178 : <a class="code" href="classTCLAP_1_1ArgException.html" title="A simple class that defines and argument exception.">ArgException</a>( text, <a name="l00179"></a>00179 id, <a name="l00180"></a>00180 std::string(<span class="stringliteral">"Exception found when an Arg object "</span>)+ <a name="l00181"></a>00181 std::string(<span class="stringliteral">"is improperly defined by the "</span>) + <a name="l00182"></a>00182 std::string(<span class="stringliteral">"developer."</span> )) <a name="l00183"></a>00183 { } <a name="l00184"></a>00184 <a name="l00185"></a>00185 }; <a name="l00186"></a>00186 <a name="l00187"></a><a class="code" href="classTCLAP_1_1ExitException.html">00187</a> <span class="keyword">class </span><a class="code" href="classTCLAP_1_1ExitException.html">ExitException</a> { <a name="l00188"></a>00188 <span class="keyword">public</span>: <a name="l00189"></a><a class="code" href="classTCLAP_1_1ExitException.html#a03a48ed9da416c8261edbd9cbbf85b27">00189</a> <a class="code" href="classTCLAP_1_1ExitException.html#a03a48ed9da416c8261edbd9cbbf85b27">ExitException</a>(<span class="keywordtype">int</span> estat) : _estat(estat) {} <a name="l00190"></a>00190 <a name="l00191"></a><a class="code" href="classTCLAP_1_1ExitException.html#acf7fd20c9cfb67b5718031ed0debda1c">00191</a> <span class="keywordtype">int</span> <a class="code" href="classTCLAP_1_1ExitException.html#acf7fd20c9cfb67b5718031ed0debda1c">getExitStatus</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _estat; } <a name="l00192"></a>00192 <a name="l00193"></a>00193 <span class="keyword">private</span>: <a name="l00194"></a>00194 <span class="keywordtype">int</span> _estat; <a name="l00195"></a>00195 }; <a name="l00196"></a>00196 <a name="l00197"></a>00197 } <span class="comment">// namespace TCLAP</span> <a name="l00198"></a>00198 <a name="l00199"></a>00199 <span class="preprocessor">#endif</span> <a name="l00200"></a>00200 <span class="preprocessor"></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>