Click here to Skip to main content
15,881,687 members
Articles / Programming Languages / C#

An extensible math expression parser with plug-ins

Rate me:
Please Sign up or sign in to vote.
4.92/5 (147 votes)
13 Mar 2008CPOL51 min read 1.4M   29K   364  
Design and code for an extensible, maintainable, robust, and easy to use math parser.
<!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>MTParserLib: MTDetailedException&lt; TExcepData &gt; Class Template Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.4 -->
<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div>
<h1>MTDetailedException&lt; TExcepData &gt; Class Template Reference</h1><!-- doxytag: class="MTDetailedException" --><code>#include &lt;<a class="el" href="MTException_8h-source.html">MTException.h</a>&gt;</code>
<p>
<a href="classMTDetailedException-members.html">List of all members.</a><hr><a name="_details"></a><h2>Detailed Description</h2>
<h3>template&lt;class TExcepData&gt;<br>
 class MTDetailedException&lt; TExcepData &gt;</h3>

Exception template. 
<p>
Represents one exception.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>TExcepData</em>&nbsp;</td><td>A customizable type for supplementary exception's information</td></tr>
  </table>
</dl>

<p>

<p>
Definition at line <a class="el" href="MTException_8h-source.html#l00087">87</a> of file <a class="el" href="MTException_8h-source.html">MTException.h</a>.<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a0"></a><!-- doxytag: member="MTDetailedException::MTDetailedException" ref="a0" args="()" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMTDetailedException.html#a0">MTDetailedException</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMTDetailedException.html#a1">MTDetailedException</a> (long line, const MTCHAR *file, long level, const TExcepData &amp;data, const MTCHAR *description)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Construct an exception.  <a href="#a1"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMTDetailedException.html#a2">MTDetailedException</a> (const <a class="el" href="classMTDetailedException.html">MTDetailedException</a> &amp;obj)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Copy an existing exception.  <a href="#a2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classMTDetailedException.html">MTDetailedException</a> &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMTDetailedException.html#a3">operator=</a> (const <a class="el" href="classMTDetailedException.html">MTDetailedException</a> &amp;obj)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Copy and existing exception.  <a href="#a3"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">long&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMTDetailedException.html#a4">getLine</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the source code line where the exception occured.  <a href="#a4"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const MTCHAR *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMTDetailedException.html#a5">getFile</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the filename where the exception occured.  <a href="#a5"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">long&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMTDetailedException.html#a6">getLevel</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get exception's level.  <a href="#a6"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">TExcepData&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMTDetailedException.html#a7">getData</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get data associated with the exception.  <a href="#a7"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const MTCHAR *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMTDetailedException.html#a8">getDescription</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the default text description.  <a href="#a8"></a><br></td></tr>
</table>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="a1"></a><!-- doxytag: member="MTDetailedException::MTDetailedException" ref="a1" args="(long line, const MTCHAR *file, long level, const TExcepData &amp;data, const MTCHAR *description)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="mdPrefix" colspan="4">
template&lt;class TExcepData&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"><a class="el" href="classMTDetailedException.html">MTDetailedException</a>&lt; TExcepData &gt;::<a class="el" href="classMTDetailedException.html">MTDetailedException</a>           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">long&nbsp;</td>
          <td class="mdname" nowrap> <em>line</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>const MTCHAR *&nbsp;</td>
          <td class="mdname" nowrap> <em>file</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>long&nbsp;</td>
          <td class="mdname" nowrap> <em>level</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>const TExcepData &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>data</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>const MTCHAR *&nbsp;</td>
          <td class="mdname" nowrap> <em>description</em></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [inline]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Construct an exception. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>line</em>&nbsp;</td><td>The line in the source code where the exception occured. Use the __LINE__ macro to automatically obtained the line number. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>file</em>&nbsp;</td><td>The file where the exception occured. Use the __FILE__ macro to automatically obtained the file name. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>level</em>&nbsp;</td><td>A user-defined value used to determine if the exception is relevant </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>User-defined data giving a detailled exception's description </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>description</em>&nbsp;</td><td>A default exception's text description</td></tr>
  </table>
</dl>

<p>
Definition at line <a class="el" href="MTException_8h-source.html#l00102">102</a> of file <a class="el" href="MTException_8h-source.html">MTException.h</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a2"></a><!-- doxytag: member="MTDetailedException::MTDetailedException" ref="a2" args="(const MTDetailedException &amp;obj)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="mdPrefix" colspan="4">
template&lt;class TExcepData&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"><a class="el" href="classMTDetailedException.html">MTDetailedException</a>&lt; TExcepData &gt;::<a class="el" href="classMTDetailedException.html">MTDetailedException</a>           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="classMTDetailedException.html">MTDetailedException</a>&lt; TExcepData &gt; &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>obj</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Copy an existing exception. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>obj</em>&nbsp;</td><td>Exception object</td></tr>
  </table>
</dl>

<p>
Definition at line <a class="el" href="MTException_8h-source.html#l00114">114</a> of file <a class="el" href="MTException_8h-source.html">MTException.h</a>.
<p>
References <a class="el" href="MTException_8h-source.html#l00122">MTDetailedException&lt; TExcepData &gt;::operator=()</a>.    </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="a7"></a><!-- doxytag: member="MTDetailedException::getData" ref="a7" args="() const " --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="mdPrefix" colspan="4">
template&lt;class TExcepData&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top">TExcepData <a class="el" href="classMTDetailedException.html">MTDetailedException</a>&lt; TExcepData &gt;::getData           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Get data associated with the exception. 
<p>
<dl compact><dt><b>Returns:</b></dt><dd>The data</dd></dl>

<p>
Definition at line <a class="el" href="MTException_8h-source.html#l00150">150</a> of file <a class="el" href="MTException_8h-source.html">MTException.h</a>.
<p>
Referenced by <a class="el" href="MTException_8h-source.html#l00238">MTChainedExceptions&lt; TExcepData &gt;::add()</a>, and <a class="el" href="MTException_8h-source.html#l00122">MTDetailedException&lt; TExcepData &gt;::operator=()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a8"></a><!-- doxytag: member="MTDetailedException::getDescription" ref="a8" args="() const " --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="mdPrefix" colspan="4">
template&lt;class TExcepData&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top">const MTCHAR* <a class="el" href="classMTDetailedException.html">MTDetailedException</a>&lt; TExcepData &gt;::getDescription           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Get the default text description. 
<p>
<dl compact><dt><b>Returns:</b></dt><dd>A text description</dd></dl>

<p>
Definition at line <a class="el" href="MTException_8h-source.html#l00155">155</a> of file <a class="el" href="MTException_8h-source.html">MTException.h</a>.
<p>
References <a class="el" href="MTGlobalString_8h-source.html#l00060">MTGlobalString::c_str()</a>.
<p>
Referenced by <a class="el" href="MTException_8h-source.html#l00238">MTChainedExceptions&lt; TExcepData &gt;::add()</a>, and <a class="el" href="MTException_8h-source.html#l00122">MTDetailedException&lt; TExcepData &gt;::operator=()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a5"></a><!-- doxytag: member="MTDetailedException::getFile" ref="a5" args="() const " --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="mdPrefix" colspan="4">
template&lt;class TExcepData&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top">const MTCHAR* <a class="el" href="classMTDetailedException.html">MTDetailedException</a>&lt; TExcepData &gt;::getFile           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Get the filename where the exception occured. 
<p>
<dl compact><dt><b>Returns:</b></dt><dd>The filename</dd></dl>

<p>
Definition at line <a class="el" href="MTException_8h-source.html#l00140">140</a> of file <a class="el" href="MTException_8h-source.html">MTException.h</a>.
<p>
References <a class="el" href="MTGlobalString_8h-source.html#l00060">MTGlobalString::c_str()</a>.
<p>
Referenced by <a class="el" href="MTException_8h-source.html#l00238">MTChainedExceptions&lt; TExcepData &gt;::add()</a>, and <a class="el" href="MTException_8h-source.html#l00122">MTDetailedException&lt; TExcepData &gt;::operator=()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a6"></a><!-- doxytag: member="MTDetailedException::getLevel" ref="a6" args="() const " --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="mdPrefix" colspan="4">
template&lt;class TExcepData&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top">long <a class="el" href="classMTDetailedException.html">MTDetailedException</a>&lt; TExcepData &gt;::getLevel           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Get exception's level. 
<p>
<dl compact><dt><b>Returns:</b></dt><dd>The exception's level</dd></dl>

<p>
Definition at line <a class="el" href="MTException_8h-source.html#l00145">145</a> of file <a class="el" href="MTException_8h-source.html">MTException.h</a>.
<p>
Referenced by <a class="el" href="MTException_8h-source.html#l00238">MTChainedExceptions&lt; TExcepData &gt;::add()</a>, and <a class="el" href="MTException_8h-source.html#l00122">MTDetailedException&lt; TExcepData &gt;::operator=()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a4"></a><!-- doxytag: member="MTDetailedException::getLine" ref="a4" args="() const " --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="mdPrefix" colspan="4">
template&lt;class TExcepData&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top">long <a class="el" href="classMTDetailedException.html">MTDetailedException</a>&lt; TExcepData &gt;::getLine           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Get the source code line where the exception occured. 
<p>
<dl compact><dt><b>Returns:</b></dt><dd>The source code line</dd></dl>

<p>
Definition at line <a class="el" href="MTException_8h-source.html#l00135">135</a> of file <a class="el" href="MTException_8h-source.html">MTException.h</a>.
<p>
Referenced by <a class="el" href="MTException_8h-source.html#l00238">MTChainedExceptions&lt; TExcepData &gt;::add()</a>, and <a class="el" href="MTException_8h-source.html#l00122">MTDetailedException&lt; TExcepData &gt;::operator=()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a3"></a><!-- doxytag: member="MTDetailedException::operator=" ref="a3" args="(const MTDetailedException &amp;obj)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="mdPrefix" colspan="4">
template&lt;class TExcepData&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"><a class="el" href="classMTDetailedException.html">MTDetailedException</a>&amp; <a class="el" href="classMTDetailedException.html">MTDetailedException</a>&lt; TExcepData &gt;::operator=           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="classMTDetailedException.html">MTDetailedException</a>&lt; TExcepData &gt; &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>obj</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Copy and existing exception. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>obj</em>&nbsp;</td><td>Exception object</td></tr>
  </table>
</dl>

<p>
Definition at line <a class="el" href="MTException_8h-source.html#l00122">122</a> of file <a class="el" href="MTException_8h-source.html">MTException.h</a>.
<p>
References <a class="el" href="MTException_8h-source.html#l00150">MTDetailedException&lt; TExcepData &gt;::getData()</a>, <a class="el" href="MTException_8h-source.html#l00155">MTDetailedException&lt; TExcepData &gt;::getDescription()</a>, <a class="el" href="MTException_8h-source.html#l00140">MTDetailedException&lt; TExcepData &gt;::getFile()</a>, <a class="el" href="MTException_8h-source.html#l00145">MTDetailedException&lt; TExcepData &gt;::getLevel()</a>, and <a class="el" href="MTException_8h-source.html#l00135">MTDetailedException&lt; TExcepData &gt;::getLine()</a>.
<p>
Referenced by <a class="el" href="MTException_8h-source.html#l00114">MTDetailedException&lt; TExcepData &gt;::MTDetailedException()</a>.    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="MTException_8h-source.html">MTException.h</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Sun Mar 9 17:39:36 2008 for MTParserLib by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.4 </small></address>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Canada Canada
Software Engineer working at a fun and smart startup company

Comments and Discussions