<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Flex Bison C++ Example: src/expression.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.5.9 -->
<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>src/expression.h</h1><a href="expression_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// $Id: expression.h 48 2009-09-05 08:07:10Z tb $</span>
<a name="l00004"></a>00004 <span class="comment"></span><span class="preprocessor">#ifndef EXPRESSION_H</span>
<a name="l00005"></a>00005 <span class="preprocessor"></span><span class="preprocessor">#define EXPRESSION_H</span>
<a name="l00006"></a>00006 <span class="preprocessor"></span>
<a name="l00007"></a>00007 <span class="preprocessor">#include <map></span>
<a name="l00008"></a>00008 <span class="preprocessor">#include <vector></span>
<a name="l00009"></a>00009 <span class="preprocessor">#include <ostream></span>
<a name="l00010"></a>00010 <span class="preprocessor">#include <stdexcept></span>
<a name="l00011"></a>00011 <span class="preprocessor">#include <cmath></span>
<a name="l00012"></a>00012
<a name="l00015"></a><a class="code" href="classCalcNode.html">00015</a> <span class="keyword">class </span><a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>
<a name="l00016"></a>00016 {
<a name="l00017"></a>00017 <span class="keyword">public</span>:
<a name="l00020"></a><a class="code" href="classCalcNode.html#d277e8092667f224a6f7f607885a3a4d">00020</a> <span class="keyword">virtual</span> <a class="code" href="classCalcNode.html#d277e8092667f224a6f7f607885a3a4d" title="required for virtual functions.">~CalcNode</a>()
<a name="l00021"></a>00021 {
<a name="l00022"></a>00022 }
<a name="l00023"></a>00023
<a name="l00026"></a>00026 <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>() <span class="keyword">const</span> = 0;
<a name="l00027"></a>00027
<a name="l00030"></a>00030 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(std::ostream &os, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> depth=0) <span class="keyword">const</span> = 0;
<a name="l00031"></a>00031
<a name="l00033"></a><a class="code" href="classCalcNode.html#605eaaacf8c3d3367c722bf7787fc4d2">00033</a> <span class="keyword">static</span> <span class="keyword">inline</span> std::string <a class="code" href="classCalcNode.html#605eaaacf8c3d3367c722bf7787fc4d2" title="helper function for print() which makes the indention string">indent</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> d)
<a name="l00034"></a>00034 {
<a name="l00035"></a>00035 <span class="keywordflow">return</span> std::string(d * 2, <span class="charliteral">' '</span>);
<a name="l00036"></a>00036 }
<a name="l00037"></a>00037 };
<a name="l00038"></a>00038
<a name="l00040"></a><a class="code" href="classCNConstant.html">00040</a> <span class="keyword">class </span><a class="code" href="classCNConstant.html" title="Calculation node always returning a constant value.">CNConstant</a> : <span class="keyword">public</span> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>
<a name="l00041"></a>00041 {
<a name="l00043"></a><a class="code" href="classCNConstant.html#f0fd01f3efa73470cf585510a927340e">00043</a> <span class="keywordtype">double</span> <a class="code" href="classCNConstant.html#f0fd01f3efa73470cf585510a927340e" title="the constant value returned">value</a>;
<a name="l00044"></a>00044
<a name="l00045"></a>00045 <span class="keyword">public</span>:
<a name="l00047"></a><a class="code" href="classCNConstant.html#0cf39e7ec935e90a472f8bf4fd784fa2">00047</a> <span class="keyword">explicit</span> <a class="code" href="classCNConstant.html#0cf39e7ec935e90a472f8bf4fd784fa2" title="construct a constant calculation node from a value">CNConstant</a>(<span class="keywordtype">double</span> _value)
<a name="l00048"></a>00048 : <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>(), <a class="code" href="classCNConstant.html#f0fd01f3efa73470cf585510a927340e" title="the constant value returned">value</a>(_value)
<a name="l00049"></a>00049 {
<a name="l00050"></a>00050 }
<a name="l00051"></a>00051
<a name="l00052"></a><a class="code" href="classCNConstant.html#f8f9ed8124c661e1dd31df7e6eed94c3">00052</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classCNConstant.html#f8f9ed8124c661e1dd31df7e6eed94c3" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>()<span class="keyword"> const</span>
<a name="l00053"></a>00053 <span class="keyword"> </span>{
<a name="l00054"></a>00054 <span class="keywordflow">return</span> <a class="code" href="classCNConstant.html#f0fd01f3efa73470cf585510a927340e" title="the constant value returned">value</a>;
<a name="l00055"></a>00055 }
<a name="l00056"></a>00056
<a name="l00057"></a><a class="code" href="classCNConstant.html#cacd0c4f899f52b2ec29ad102fc17d9a">00057</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCNConstant.html#cacd0c4f899f52b2ec29ad102fc17d9a" title="output the calculation tree to the given stream.">print</a>(std::ostream &os, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> depth)<span class="keyword"> const</span>
<a name="l00058"></a>00058 <span class="keyword"> </span>{
<a name="l00059"></a>00059 os << <a class="code" href="classCalcNode.html#605eaaacf8c3d3367c722bf7787fc4d2" title="helper function for print() which makes the indention string">indent</a>(depth) << <a class="code" href="classCNConstant.html#f0fd01f3efa73470cf585510a927340e" title="the constant value returned">value</a> << std::endl;
<a name="l00060"></a>00060 }
<a name="l00061"></a>00061 };
<a name="l00062"></a>00062
<a name="l00064"></a><a class="code" href="classCNNegate.html">00064</a> <span class="keyword">class </span><a class="code" href="classCNNegate.html" title="Calculation node negating the value of the operand subtree.">CNNegate</a> : <span class="keyword">public</span> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>
<a name="l00065"></a>00065 {
<a name="l00067"></a><a class="code" href="classCNNegate.html#deff251957fcba501fd99da3797392c7">00067</a> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* <a class="code" href="classCNNegate.html#deff251957fcba501fd99da3797392c7" title="calculation subtree">node</a>;
<a name="l00068"></a>00068
<a name="l00069"></a>00069 <span class="keyword">public</span>:
<a name="l00070"></a><a class="code" href="classCNNegate.html#2b714898f5ad0c1baa22ac0d13e8d9f5">00070</a> <span class="keyword">explicit</span> <a class="code" href="classCNNegate.html#2b714898f5ad0c1baa22ac0d13e8d9f5">CNNegate</a>(<a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* _node)
<a name="l00071"></a>00071 : <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>(), <a class="code" href="classCNNegate.html#deff251957fcba501fd99da3797392c7" title="calculation subtree">node</a>(_node)
<a name="l00072"></a>00072 {
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074
<a name="l00075"></a><a class="code" href="classCNNegate.html#262567bfb009ab31cbe3dc482a0e6294">00075</a> <span class="keyword">virtual</span> <a class="code" href="classCNNegate.html#262567bfb009ab31cbe3dc482a0e6294">~CNNegate</a>()
<a name="l00076"></a>00076 {
<a name="l00077"></a>00077 <span class="keyword">delete</span> <a class="code" href="classCNNegate.html#deff251957fcba501fd99da3797392c7" title="calculation subtree">node</a>;
<a name="l00078"></a>00078 }
<a name="l00079"></a>00079
<a name="l00080"></a><a class="code" href="classCNNegate.html#d8742ef807da75fea0d512467d5331cd">00080</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classCNNegate.html#d8742ef807da75fea0d512467d5331cd" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>()<span class="keyword"> const</span>
<a name="l00081"></a>00081 <span class="keyword"> </span>{
<a name="l00082"></a>00082 <span class="keywordflow">return</span> - <a class="code" href="classCNNegate.html#deff251957fcba501fd99da3797392c7" title="calculation subtree">node</a>-><a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>();
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084
<a name="l00085"></a><a class="code" href="classCNNegate.html#05186ba465d67b4c7d82775aff6bfcc7">00085</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCNNegate.html#05186ba465d67b4c7d82775aff6bfcc7" title="output the calculation tree to the given stream.">print</a>(std::ostream &os, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> depth)<span class="keyword"> const</span>
<a name="l00086"></a>00086 <span class="keyword"> </span>{
<a name="l00087"></a>00087 os << <a class="code" href="classCalcNode.html#605eaaacf8c3d3367c722bf7787fc4d2" title="helper function for print() which makes the indention string">indent</a>(depth) << <span class="stringliteral">"- negate"</span> << std::endl;
<a name="l00088"></a>00088 <a class="code" href="classCNNegate.html#deff251957fcba501fd99da3797392c7" title="calculation subtree">node</a>-><a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(os, depth+1);
<a name="l00089"></a>00089 }
<a name="l00090"></a>00090 };
<a name="l00091"></a>00091
<a name="l00093"></a><a class="code" href="classCNAdd.html">00093</a> <span class="keyword">class </span><a class="code" href="classCNAdd.html" title="Calculation node adding two operand nodes.">CNAdd</a> : <span class="keyword">public</span> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>
<a name="l00094"></a>00094 {
<a name="l00096"></a><a class="code" href="classCNAdd.html#0949aa44dd993be41a1c4e76fbc679c0">00096</a> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* <a class="code" href="classCNAdd.html#0949aa44dd993be41a1c4e76fbc679c0" title="left calculation operand">left</a>;
<a name="l00097"></a>00097
<a name="l00099"></a><a class="code" href="classCNAdd.html#7564c6da723eb9591a17a84d95c44545">00099</a> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* <a class="code" href="classCNAdd.html#7564c6da723eb9591a17a84d95c44545" title="right calculation operand">right</a>;
<a name="l00100"></a>00100
<a name="l00101"></a>00101 <span class="keyword">public</span>:
<a name="l00102"></a><a class="code" href="classCNAdd.html#d58db4fc6c78bb0d83695d9d14cae862">00102</a> <span class="keyword">explicit</span> <a class="code" href="classCNAdd.html#d58db4fc6c78bb0d83695d9d14cae862">CNAdd</a>(<a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* _left, <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* _right)
<a name="l00103"></a>00103 : <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>(), <a class="code" href="classCNAdd.html#0949aa44dd993be41a1c4e76fbc679c0" title="left calculation operand">left</a>(_left), <a class="code" href="classCNAdd.html#7564c6da723eb9591a17a84d95c44545" title="right calculation operand">right</a>(_right)
<a name="l00104"></a>00104 {
<a name="l00105"></a>00105 }
<a name="l00106"></a>00106
<a name="l00107"></a><a class="code" href="classCNAdd.html#7ec540d57c20f7c3d3fa7e7f674cb2cc">00107</a> <span class="keyword">virtual</span> <a class="code" href="classCNAdd.html#7ec540d57c20f7c3d3fa7e7f674cb2cc">~CNAdd</a>()
<a name="l00108"></a>00108 {
<a name="l00109"></a>00109 <span class="keyword">delete</span> <a class="code" href="classCNAdd.html#0949aa44dd993be41a1c4e76fbc679c0" title="left calculation operand">left</a>;
<a name="l00110"></a>00110 <span class="keyword">delete</span> <a class="code" href="classCNAdd.html#7564c6da723eb9591a17a84d95c44545" title="right calculation operand">right</a>;
<a name="l00111"></a>00111 }
<a name="l00112"></a>00112
<a name="l00113"></a><a class="code" href="classCNAdd.html#5b558f1853ec5555c1ff3503f44b30e7">00113</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classCNAdd.html#5b558f1853ec5555c1ff3503f44b30e7" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>()<span class="keyword"> const</span>
<a name="l00114"></a>00114 <span class="keyword"> </span>{
<a name="l00115"></a>00115 <span class="keywordflow">return</span> <a class="code" href="classCNAdd.html#0949aa44dd993be41a1c4e76fbc679c0" title="left calculation operand">left</a>-><a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>() + <a class="code" href="classCNAdd.html#7564c6da723eb9591a17a84d95c44545" title="right calculation operand">right</a>-><a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>();
<a name="l00116"></a>00116 }
<a name="l00117"></a>00117
<a name="l00118"></a><a class="code" href="classCNAdd.html#73128b63182541df1e0d8797c1c3f4a9">00118</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCNAdd.html#73128b63182541df1e0d8797c1c3f4a9" title="output the calculation tree to the given stream.">print</a>(std::ostream &os, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> depth)<span class="keyword"> const</span>
<a name="l00119"></a>00119 <span class="keyword"> </span>{
<a name="l00120"></a>00120 os << <a class="code" href="classCalcNode.html#605eaaacf8c3d3367c722bf7787fc4d2" title="helper function for print() which makes the indention string">indent</a>(depth) << <span class="stringliteral">"+ add"</span> << std::endl;
<a name="l00121"></a>00121 <a class="code" href="classCNAdd.html#0949aa44dd993be41a1c4e76fbc679c0" title="left calculation operand">left</a>-><a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(os, depth+1);
<a name="l00122"></a>00122 <a class="code" href="classCNAdd.html#7564c6da723eb9591a17a84d95c44545" title="right calculation operand">right</a>-><a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(os, depth+1);
<a name="l00123"></a>00123 }
<a name="l00124"></a>00124 };
<a name="l00125"></a>00125
<a name="l00127"></a><a class="code" href="classCNSubtract.html">00127</a> <span class="keyword">class </span><a class="code" href="classCNSubtract.html" title="Calculation node subtracting two operand nodes.">CNSubtract</a> : <span class="keyword">public</span> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>
<a name="l00128"></a>00128 {
<a name="l00130"></a><a class="code" href="classCNSubtract.html#b4aa836a22c9730826ab44d366cc8f70">00130</a> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* <a class="code" href="classCNSubtract.html#b4aa836a22c9730826ab44d366cc8f70" title="left calculation operand">left</a>;
<a name="l00131"></a>00131
<a name="l00133"></a><a class="code" href="classCNSubtract.html#bce59678bb0944c74ceae3b1591acc9e">00133</a> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* <a class="code" href="classCNSubtract.html#bce59678bb0944c74ceae3b1591acc9e" title="right calculation operand">right</a>;
<a name="l00134"></a>00134
<a name="l00135"></a>00135 <span class="keyword">public</span>:
<a name="l00136"></a><a class="code" href="classCNSubtract.html#0541ebca50cf7ee87951b58e0e471f9e">00136</a> <span class="keyword">explicit</span> <a class="code" href="classCNSubtract.html#0541ebca50cf7ee87951b58e0e471f9e">CNSubtract</a>(<a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* _left, <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* _right)
<a name="l00137"></a>00137 : <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>(), <a class="code" href="classCNSubtract.html#b4aa836a22c9730826ab44d366cc8f70" title="left calculation operand">left</a>(_left), <a class="code" href="classCNSubtract.html#bce59678bb0944c74ceae3b1591acc9e" title="right calculation operand">right</a>(_right)
<a name="l00138"></a>00138 {
<a name="l00139"></a>00139 }
<a name="l00140"></a>00140
<a name="l00141"></a><a class="code" href="classCNSubtract.html#4981aae33a05d8e8c53aa0bb14d4dc47">00141</a> <span class="keyword">virtual</span> <a class="code" href="classCNSubtract.html#4981aae33a05d8e8c53aa0bb14d4dc47">~CNSubtract</a>()
<a name="l00142"></a>00142 {
<a name="l00143"></a>00143 <span class="keyword">delete</span> <a class="code" href="classCNSubtract.html#b4aa836a22c9730826ab44d366cc8f70" title="left calculation operand">left</a>;
<a name="l00144"></a>00144 <span class="keyword">delete</span> <a class="code" href="classCNSubtract.html#bce59678bb0944c74ceae3b1591acc9e" title="right calculation operand">right</a>;
<a name="l00145"></a>00145 }
<a name="l00146"></a>00146
<a name="l00147"></a><a class="code" href="classCNSubtract.html#e57879411a77bf2a5b16f28aa488a3d6">00147</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classCNSubtract.html#e57879411a77bf2a5b16f28aa488a3d6" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>()<span class="keyword"> const</span>
<a name="l00148"></a>00148 <span class="keyword"> </span>{
<a name="l00149"></a>00149 <span class="keywordflow">return</span> <a class="code" href="classCNSubtract.html#b4aa836a22c9730826ab44d366cc8f70" title="left calculation operand">left</a>-><a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>() - <a class="code" href="classCNSubtract.html#bce59678bb0944c74ceae3b1591acc9e" title="right calculation operand">right</a>-><a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>();
<a name="l00150"></a>00150 }
<a name="l00151"></a>00151
<a name="l00152"></a><a class="code" href="classCNSubtract.html#2a1f71490f4492af059f80ebd862a442">00152</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCNSubtract.html#2a1f71490f4492af059f80ebd862a442" title="output the calculation tree to the given stream.">print</a>(std::ostream &os, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> depth)<span class="keyword"> const</span>
<a name="l00153"></a>00153 <span class="keyword"> </span>{
<a name="l00154"></a>00154 os << <a class="code" href="classCalcNode.html#605eaaacf8c3d3367c722bf7787fc4d2" title="helper function for print() which makes the indention string">indent</a>(depth) << <span class="stringliteral">"- subtract"</span> << std::endl;
<a name="l00155"></a>00155 <a class="code" href="classCNSubtract.html#b4aa836a22c9730826ab44d366cc8f70" title="left calculation operand">left</a>-><a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(os, depth+1);
<a name="l00156"></a>00156 <a class="code" href="classCNSubtract.html#bce59678bb0944c74ceae3b1591acc9e" title="right calculation operand">right</a>-><a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(os, depth+1);
<a name="l00157"></a>00157 }
<a name="l00158"></a>00158 };
<a name="l00159"></a>00159
<a name="l00161"></a><a class="code" href="classCNMultiply.html">00161</a> <span class="keyword">class </span><a class="code" href="classCNMultiply.html" title="Calculation node multiplying two operand nodes.">CNMultiply</a> : <span class="keyword">public</span> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>
<a name="l00162"></a>00162 {
<a name="l00164"></a><a class="code" href="classCNMultiply.html#f0f84841318e0ffef4e022de1fff7c15">00164</a> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* <a class="code" href="classCNMultiply.html#f0f84841318e0ffef4e022de1fff7c15" title="left calculation operand">left</a>;
<a name="l00165"></a>00165
<a name="l00167"></a><a class="code" href="classCNMultiply.html#bd46e680b03fef7e3e303eb57b850499">00167</a> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* <a class="code" href="classCNMultiply.html#bd46e680b03fef7e3e303eb57b850499" title="right calculation operand">right</a>;
<a name="l00168"></a>00168
<a name="l00169"></a>00169 <span class="keyword">public</span>:
<a name="l00170"></a><a class="code" href="classCNMultiply.html#4f7198f154058adf9f9239dde52a6fee">00170</a> <span class="keyword">explicit</span> <a class="code" href="classCNMultiply.html#4f7198f154058adf9f9239dde52a6fee">CNMultiply</a>(<a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* _left, <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* _right)
<a name="l00171"></a>00171 : <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>(), <a class="code" href="classCNMultiply.html#f0f84841318e0ffef4e022de1fff7c15" title="left calculation operand">left</a>(_left), <a class="code" href="classCNMultiply.html#bd46e680b03fef7e3e303eb57b850499" title="right calculation operand">right</a>(_right)
<a name="l00172"></a>00172 {
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174
<a name="l00175"></a><a class="code" href="classCNMultiply.html#77cb77c51a83f12cd9db8b7dc63e9597">00175</a> <span class="keyword">virtual</span> <a class="code" href="classCNMultiply.html#77cb77c51a83f12cd9db8b7dc63e9597">~CNMultiply</a>()
<a name="l00176"></a>00176 {
<a name="l00177"></a>00177 <span class="keyword">delete</span> <a class="code" href="classCNMultiply.html#f0f84841318e0ffef4e022de1fff7c15" title="left calculation operand">left</a>;
<a name="l00178"></a>00178 <span class="keyword">delete</span> <a class="code" href="classCNMultiply.html#bd46e680b03fef7e3e303eb57b850499" title="right calculation operand">right</a>;
<a name="l00179"></a>00179 }
<a name="l00180"></a>00180
<a name="l00181"></a><a class="code" href="classCNMultiply.html#51ce205165bfa5842002721332c14f5c">00181</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classCNMultiply.html#51ce205165bfa5842002721332c14f5c" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>()<span class="keyword"> const</span>
<a name="l00182"></a>00182 <span class="keyword"> </span>{
<a name="l00183"></a>00183 <span class="keywordflow">return</span> <a class="code" href="classCNMultiply.html#f0f84841318e0ffef4e022de1fff7c15" title="left calculation operand">left</a>-><a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>() * <a class="code" href="classCNMultiply.html#bd46e680b03fef7e3e303eb57b850499" title="right calculation operand">right</a>-><a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>();
<a name="l00184"></a>00184 }
<a name="l00185"></a>00185
<a name="l00186"></a><a class="code" href="classCNMultiply.html#a97ab488dd08e3c3248df351465e0d1d">00186</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCNMultiply.html#a97ab488dd08e3c3248df351465e0d1d" title="output the calculation tree to the given stream.">print</a>(std::ostream &os, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> depth)<span class="keyword"> const</span>
<a name="l00187"></a>00187 <span class="keyword"> </span>{
<a name="l00188"></a>00188 os << <a class="code" href="classCalcNode.html#605eaaacf8c3d3367c722bf7787fc4d2" title="helper function for print() which makes the indention string">indent</a>(depth) << <span class="stringliteral">"* multiply"</span> << std::endl;
<a name="l00189"></a>00189 <a class="code" href="classCNMultiply.html#f0f84841318e0ffef4e022de1fff7c15" title="left calculation operand">left</a>-><a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(os, depth+1);
<a name="l00190"></a>00190 <a class="code" href="classCNMultiply.html#bd46e680b03fef7e3e303eb57b850499" title="right calculation operand">right</a>-><a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(os, depth+1);
<a name="l00191"></a>00191 }
<a name="l00192"></a>00192 };
<a name="l00193"></a>00193
<a name="l00195"></a><a class="code" href="classCNDivide.html">00195</a> <span class="keyword">class </span><a class="code" href="classCNDivide.html" title="Calculation node dividing two operand nodes.">CNDivide</a> : <span class="keyword">public</span> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>
<a name="l00196"></a>00196 {
<a name="l00198"></a><a class="code" href="classCNDivide.html#5f0e8a8f8064a12f0aa7ffdcd215c299">00198</a> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* <a class="code" href="classCNDivide.html#5f0e8a8f8064a12f0aa7ffdcd215c299" title="left calculation operand">left</a>;
<a name="l00199"></a>00199
<a name="l00201"></a><a class="code" href="classCNDivide.html#fd13d8db1b59e465f72e5aa5b58622b5">00201</a> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* <a class="code" href="classCNDivide.html#fd13d8db1b59e465f72e5aa5b58622b5" title="right calculation operand">right</a>;
<a name="l00202"></a>00202
<a name="l00203"></a>00203 <span class="keyword">public</span>:
<a name="l00204"></a><a class="code" href="classCNDivide.html#8c68f6caaf698379e4d3092aca0cfd96">00204</a> <span class="keyword">explicit</span> <a class="code" href="classCNDivide.html#8c68f6caaf698379e4d3092aca0cfd96">CNDivide</a>(<a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* _left, <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* _right)
<a name="l00205"></a>00205 : <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>(), <a class="code" href="classCNDivide.html#5f0e8a8f8064a12f0aa7ffdcd215c299" title="left calculation operand">left</a>(_left), <a class="code" href="classCNDivide.html#fd13d8db1b59e465f72e5aa5b58622b5" title="right calculation operand">right</a>(_right)
<a name="l00206"></a>00206 {
<a name="l00207"></a>00207 }
<a name="l00208"></a>00208
<a name="l00209"></a><a class="code" href="classCNDivide.html#c5b75878d687dd69e3c870ff57a030f2">00209</a> <span class="keyword">virtual</span> <a class="code" href="classCNDivide.html#c5b75878d687dd69e3c870ff57a030f2">~CNDivide</a>()
<a name="l00210"></a>00210 {
<a name="l00211"></a>00211 <span class="keyword">delete</span> <a class="code" href="classCNDivide.html#5f0e8a8f8064a12f0aa7ffdcd215c299" title="left calculation operand">left</a>;
<a name="l00212"></a>00212 <span class="keyword">delete</span> <a class="code" href="classCNDivide.html#fd13d8db1b59e465f72e5aa5b58622b5" title="right calculation operand">right</a>;
<a name="l00213"></a>00213 }
<a name="l00214"></a>00214
<a name="l00215"></a><a class="code" href="classCNDivide.html#416c36cec11a481a20bbe3409c1e42db">00215</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classCNDivide.html#416c36cec11a481a20bbe3409c1e42db" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>()<span class="keyword"> const</span>
<a name="l00216"></a>00216 <span class="keyword"> </span>{
<a name="l00217"></a>00217 <span class="keywordflow">return</span> <a class="code" href="classCNDivide.html#5f0e8a8f8064a12f0aa7ffdcd215c299" title="left calculation operand">left</a>-><a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>() / <a class="code" href="classCNDivide.html#fd13d8db1b59e465f72e5aa5b58622b5" title="right calculation operand">right</a>-><a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>();
<a name="l00218"></a>00218 }
<a name="l00219"></a>00219
<a name="l00220"></a><a class="code" href="classCNDivide.html#0126b757dde799c062ce16abfeda197d">00220</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCNDivide.html#0126b757dde799c062ce16abfeda197d" title="output the calculation tree to the given stream.">print</a>(std::ostream &os, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> depth)<span class="keyword"> const</span>
<a name="l00221"></a>00221 <span class="keyword"> </span>{
<a name="l00222"></a>00222 os << <a class="code" href="classCalcNode.html#605eaaacf8c3d3367c722bf7787fc4d2" title="helper function for print() which makes the indention string">indent</a>(depth) << <span class="stringliteral">"/ divide"</span> << std::endl;
<a name="l00223"></a>00223 <a class="code" href="classCNDivide.html#5f0e8a8f8064a12f0aa7ffdcd215c299" title="left calculation operand">left</a>-><a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(os, depth+1);
<a name="l00224"></a>00224 <a class="code" href="classCNDivide.html#fd13d8db1b59e465f72e5aa5b58622b5" title="right calculation operand">right</a>-><a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(os, depth+1);
<a name="l00225"></a>00225 }
<a name="l00226"></a>00226 };
<a name="l00227"></a>00227
<a name="l00230"></a><a class="code" href="classCNModulo.html">00230</a> <span class="keyword">class </span><a class="code" href="classCNModulo.html" title="Calculation node calculating the remainder of an integer division of two operand...">CNModulo</a> : <span class="keyword">public</span> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>
<a name="l00231"></a>00231 {
<a name="l00233"></a><a class="code" href="classCNModulo.html#dabc12aa55361f56212fef3dec01edba">00233</a> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* <a class="code" href="classCNModulo.html#dabc12aa55361f56212fef3dec01edba" title="left calculation operand">left</a>;
<a name="l00234"></a>00234
<a name="l00236"></a><a class="code" href="classCNModulo.html#a1f57ca59c172e1fd12faf08a53bcae8">00236</a> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* <a class="code" href="classCNModulo.html#a1f57ca59c172e1fd12faf08a53bcae8" title="right calculation operand">right</a>;
<a name="l00237"></a>00237
<a name="l00238"></a>00238 <span class="keyword">public</span>:
<a name="l00239"></a><a class="code" href="classCNModulo.html#8e6c9022db2a053c3411e9758b672383">00239</a> <span class="keyword">explicit</span> <a class="code" href="classCNModulo.html#8e6c9022db2a053c3411e9758b672383">CNModulo</a>(<a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* _left, <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* _right)
<a name="l00240"></a>00240 : <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>(), <a class="code" href="classCNModulo.html#dabc12aa55361f56212fef3dec01edba" title="left calculation operand">left</a>(_left), <a class="code" href="classCNModulo.html#a1f57ca59c172e1fd12faf08a53bcae8" title="right calculation operand">right</a>(_right)
<a name="l00241"></a>00241 {
<a name="l00242"></a>00242 }
<a name="l00243"></a>00243
<a name="l00244"></a><a class="code" href="classCNModulo.html#365e8bb7a46b9b3cb0dcf8393ea52072">00244</a> <span class="keyword">virtual</span> <a class="code" href="classCNModulo.html#365e8bb7a46b9b3cb0dcf8393ea52072">~CNModulo</a>()
<a name="l00245"></a>00245 {
<a name="l00246"></a>00246 <span class="keyword">delete</span> <a class="code" href="classCNModulo.html#dabc12aa55361f56212fef3dec01edba" title="left calculation operand">left</a>;
<a name="l00247"></a>00247 <span class="keyword">delete</span> <a class="code" href="classCNModulo.html#a1f57ca59c172e1fd12faf08a53bcae8" title="right calculation operand">right</a>;
<a name="l00248"></a>00248 }
<a name="l00249"></a>00249
<a name="l00250"></a><a class="code" href="classCNModulo.html#ea0edc20d0feeaded4e44182039f8396">00250</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classCNModulo.html#ea0edc20d0feeaded4e44182039f8396" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>()<span class="keyword"> const</span>
<a name="l00251"></a>00251 <span class="keyword"> </span>{
<a name="l00252"></a>00252 <span class="keywordflow">return</span> std::fmod(<a class="code" href="classCNModulo.html#dabc12aa55361f56212fef3dec01edba" title="left calculation operand">left</a>-><a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>(), <a class="code" href="classCNModulo.html#a1f57ca59c172e1fd12faf08a53bcae8" title="right calculation operand">right</a>-><a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>());
<a name="l00253"></a>00253 }
<a name="l00254"></a>00254
<a name="l00255"></a><a class="code" href="classCNModulo.html#9dbb4fee67eb934535924e6ee8ffc810">00255</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCNModulo.html#9dbb4fee67eb934535924e6ee8ffc810" title="output the calculation tree to the given stream.">print</a>(std::ostream &os, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> depth)<span class="keyword"> const</span>
<a name="l00256"></a>00256 <span class="keyword"> </span>{
<a name="l00257"></a>00257 os << <a class="code" href="classCalcNode.html#605eaaacf8c3d3367c722bf7787fc4d2" title="helper function for print() which makes the indention string">indent</a>(depth) << <span class="stringliteral">"% modulo"</span> << std::endl;
<a name="l00258"></a>00258 <a class="code" href="classCNModulo.html#dabc12aa55361f56212fef3dec01edba" title="left calculation operand">left</a>-><a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(os, depth+1);
<a name="l00259"></a>00259 <a class="code" href="classCNModulo.html#a1f57ca59c172e1fd12faf08a53bcae8" title="right calculation operand">right</a>-><a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(os, depth+1);
<a name="l00260"></a>00260 }
<a name="l00261"></a>00261 };
<a name="l00262"></a>00262
<a name="l00264"></a><a class="code" href="classCNPower.html">00264</a> <span class="keyword">class </span><a class="code" href="classCNPower.html" title="Calculation node raising one operand to the power of the second.">CNPower</a> : <span class="keyword">public</span> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>
<a name="l00265"></a>00265 {
<a name="l00267"></a><a class="code" href="classCNPower.html#339ba16c04b2b7a7d95657a8ecc1d667">00267</a> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* <a class="code" href="classCNPower.html#339ba16c04b2b7a7d95657a8ecc1d667" title="left calculation operand">left</a>;
<a name="l00268"></a>00268
<a name="l00270"></a><a class="code" href="classCNPower.html#6e8994ac1a958623135ca1925ee71bb1">00270</a> <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* <a class="code" href="classCNPower.html#6e8994ac1a958623135ca1925ee71bb1" title="right calculation operand">right</a>;
<a name="l00271"></a>00271
<a name="l00272"></a>00272 <span class="keyword">public</span>:
<a name="l00273"></a><a class="code" href="classCNPower.html#19cc4d9436407d694ec1671fd146834a">00273</a> <span class="keyword">explicit</span> <a class="code" href="classCNPower.html#19cc4d9436407d694ec1671fd146834a">CNPower</a>(<a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* _left, <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>* _right)
<a name="l00274"></a>00274 : <a class="code" href="classCalcNode.html" title="CalcNode is the abstract base class for calculation nodes.">CalcNode</a>(), <a class="code" href="classCNPower.html#339ba16c04b2b7a7d95657a8ecc1d667" title="left calculation operand">left</a>(_left), <a class="code" href="classCNPower.html#6e8994ac1a958623135ca1925ee71bb1" title="right calculation operand">right</a>(_right)
<a name="l00275"></a>00275 {
<a name="l00276"></a>00276 }
<a name="l00277"></a>00277
<a name="l00278"></a><a class="code" href="classCNPower.html#2cbc6cdd3ea0a40f6a5cc1bc505cc075">00278</a> <span class="keyword">virtual</span> <a class="code" href="classCNPower.html#2cbc6cdd3ea0a40f6a5cc1bc505cc075">~CNPower</a>()
<a name="l00279"></a>00279 {
<a name="l00280"></a>00280 <span class="keyword">delete</span> <a class="code" href="classCNPower.html#339ba16c04b2b7a7d95657a8ecc1d667" title="left calculation operand">left</a>;
<a name="l00281"></a>00281 <span class="keyword">delete</span> <a class="code" href="classCNPower.html#6e8994ac1a958623135ca1925ee71bb1" title="right calculation operand">right</a>;
<a name="l00282"></a>00282 }
<a name="l00283"></a>00283
<a name="l00284"></a><a class="code" href="classCNPower.html#9461646cf8e9fc0cb54318e04d73ed72">00284</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classCNPower.html#9461646cf8e9fc0cb54318e04d73ed72" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>()<span class="keyword"> const</span>
<a name="l00285"></a>00285 <span class="keyword"> </span>{
<a name="l00286"></a>00286 <span class="keywordflow">return</span> std::pow(<a class="code" href="classCNPower.html#339ba16c04b2b7a7d95657a8ecc1d667" title="left calculation operand">left</a>-><a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>(), <a class="code" href="classCNPower.html#6e8994ac1a958623135ca1925ee71bb1" title="right calculation operand">right</a>-><a class="code" href="classCalcNode.html#0c036b9e80266101e155bf76da1b868a" title="evaluate the complete calculation tree and return the floating point result value...">evaluate</a>());
<a name="l00287"></a>00287 }
<a name="l00288"></a>00288
<a name="l00289"></a><a class="code" href="classCNPower.html#23b22f144f66e242794826719eb4a47a">00289</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCNPower.html#23b22f144f66e242794826719eb4a47a" title="output the calculation tree to the given stream.">print</a>(std::ostream &os, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> depth)<span class="keyword"> const</span>
<a name="l00290"></a>00290 <span class="keyword"> </span>{
<a name="l00291"></a>00291 os << <a class="code" href="classCalcNode.html#605eaaacf8c3d3367c722bf7787fc4d2" title="helper function for print() which makes the indention string">indent</a>(depth) << <span class="stringliteral">"^ power"</span> << std::endl;
<a name="l00292"></a>00292 <a class="code" href="classCNPower.html#339ba16c04b2b7a7d95657a8ecc1d667" title="left calculation operand">left</a>-><a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(os, depth+1);
<a name="l00293"></a>00293 <a class="code" href="classCNPower.html#6e8994ac1a958623135ca1925ee71bb1" title="right calculation operand">right</a>-><a class="code" href="classCalcNode.html#ce46c07f593f0b4727faa46cbeb8f6e8" title="output the calculation tree to the given stream.">print</a>(os, depth+1);
<a name="l00294"></a>00294 }
<a name="l00295"></a>00295 };
<a name="l00296"></a>00296
<a name="l00300"></a><a class="code" href="classCalcContext.html">00300</a> <span class="keyword">class </span><a class="code" href="classCalcContext.html" title="Calculator context used to save the parsed expressions.">CalcContext</a>
<a name="l00301"></a>00301 {
<a name="l00302"></a>00302 <span class="keyword">public</span>:
<a name="l00303"></a>00303
<a name="l00305"></a><a class="code" href="classCalcContext.html#55c16653543d059519c07c94249a63a0">00305</a> <span class="keyword">typedef</span> std::map<std::string, double> <a class="code" href="classCalcContext.html#55c16653543d059519c07c94249a63a0" title="type of the variable storage">variablemap_type</a>;
<a name="l00306"></a>00306
<a name="l00308"></a><a class="code" href="classCalcContext.html#c725ebcd1dcc4a480155a6943e5ac957">00308</a> <a class="code" href="classCalcContext.html#55c16653543d059519c07c94249a63a0" title="type of the variable storage">variablemap_type</a> <a class="code" href="classCalcContext.html#c725ebcd1dcc4a480155a6943e5ac957" title="variable storage. maps variable string to doubles">variables</a>;
<a name="l00309"></a>00309
<a name="l00312"></a><a class="code" href="classCalcContext.html#b1847ab7be9ec42a7e448d49c1fe8c6b">00312</a> std::vector<CalcNode*> <a class="code" href="classCalcContext.html#b1847ab7be9ec42a7e448d49c1fe8c6b" title="array of unassigned expressions found by the parser.">expressions</a>;
<a name="l00313"></a>00313
<a name="l00315"></a><a class="code" href="classCalcContext.html#26fdce262f6eb86aeabdccf3081efd5f">00315</a> <a class="code" href="classCalcContext.html#26fdce262f6eb86aeabdccf3081efd5f" title="free the saved expression trees">~CalcContext</a>()
<a name="l00316"></a>00316 {
<a name="l00317"></a>00317 <a class="code" href="classCalcContext.html#8121847568350b2eb3073c64f15696cc" title="free all saved expression trees">clearExpressions</a>();
<a name="l00318"></a>00318 }
<a name="l00319"></a>00319
<a name="l00321"></a><a class="code" href="classCalcContext.html#8121847568350b2eb3073c64f15696cc">00321</a> <span class="keywordtype">void</span> <a class="code" href="classCalcContext.html#8121847568350b2eb3073c64f15696cc" title="free all saved expression trees">clearExpressions</a>()
<a name="l00322"></a>00322 {
<a name="l00323"></a>00323 <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classCalcContext.html#b1847ab7be9ec42a7e448d49c1fe8c6b" title="array of unassigned expressions found by the parser.">expressions</a>.size(); ++i)
<a name="l00324"></a>00324 {
<a name="l00325"></a>00325 <span class="keyword">delete</span> <a class="code" href="classCalcContext.html#b1847ab7be9ec42a7e448d49c1fe8c6b" title="array of unassigned expressions found by the parser.">expressions</a>[i];
<a name="l00326"></a>00326 }
<a name="l00327"></a>00327 <a class="code" href="classCalcContext.html#b1847ab7be9ec42a7e448d49c1fe8c6b" title="array of unassigned expressions found by the parser.">expressions</a>.clear();
<a name="l00328"></a>00328 }
<a name="l00329"></a>00329
<a name="l00331"></a><a class="code" href="classCalcContext.html#12ebfc0a7e6801f14162db3a6d2669fa">00331</a> <span class="keywordtype">bool</span> <a class="code" href="classCalcContext.html#12ebfc0a7e6801f14162db3a6d2669fa" title="check if the given variable name exists in the storage">existsVariable</a>(<span class="keyword">const</span> std::string &varname)<span class="keyword"> const</span>
<a name="l00332"></a>00332 <span class="keyword"> </span>{
<a name="l00333"></a>00333 <span class="keywordflow">return</span> <a class="code" href="classCalcContext.html#c725ebcd1dcc4a480155a6943e5ac957" title="variable storage. maps variable string to doubles">variables</a>.find(varname) != <a class="code" href="classCalcContext.html#c725ebcd1dcc4a480155a6943e5ac957" title="variable storage. maps variable string to doubles">variables</a>.end();
<a name="l00334"></a>00334 }
<a name="l00335"></a>00335
<a name="l00338"></a><a class="code" href="classCalcContext.html#3edc55c1b8bcec46399d835a09052f87">00338</a> <span class="keywordtype">double</span> <a class="code" href="classCalcContext.html#3edc55c1b8bcec46399d835a09052f87" title="return the given variable from the storage.">getVariable</a>(<span class="keyword">const</span> std::string &varname)<span class="keyword"> const</span>
<a name="l00339"></a>00339 <span class="keyword"> </span>{
<a name="l00340"></a>00340 variablemap_type::const_iterator vi = <a class="code" href="classCalcContext.html#c725ebcd1dcc4a480155a6943e5ac957" title="variable storage. maps variable string to doubles">variables</a>.find(varname);
<a name="l00341"></a>00341 <span class="keywordflow">if</span> (vi == <a class="code" href="classCalcContext.html#c725ebcd1dcc4a480155a6943e5ac957" title="variable storage. maps variable string to doubles">variables</a>.end())
<a name="l00342"></a>00342 <span class="keywordflow">throw</span>(std::runtime_error(<span class="stringliteral">"Unknown variable."</span>));
<a name="l00343"></a>00343 <span class="keywordflow">else</span>
<a name="l00344"></a>00344 <span class="keywordflow">return</span> vi->second;
<a name="l00345"></a>00345 }
<a name="l00346"></a>00346 };
<a name="l00347"></a>00347
<a name="l00348"></a>00348 <span class="preprocessor">#endif // EXPRESSION_H</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>