Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 39121eaa6e08c828e313b57261e3f286 > files > 56

antlr-C++-doc-2.7.7-15.fc14.noarch.rpm

<!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/xhtml;charset=UTF-8"/>
<title>ANTLR Support Libraries 2.7.1+: antlr/ASTRefCount.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Generated by Doxygen 1.7.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">ANTLR Support Libraries 2.7.1+</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</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 id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<h1>antlr/ASTRefCount.hpp</h1>  </div>
</div>
<div class="contents">
<a href="ASTRefCount_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef INC_ASTRefCount_hpp__</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor"># define INC_ASTRefCount_hpp__</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="comment">/* ANTLR Translator Generator</span>
<a name="l00005"></a>00005 <span class="comment"> * Project led by Terence Parr at http://www.jGuru.com</span>
<a name="l00006"></a>00006 <span class="comment"> * Software rights: http://www.antlr.org/license.html</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/ASTRefCount.hpp#2 $</span>
<a name="l00009"></a>00009 <span class="comment"> */</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="preprocessor"># include &lt;antlr/config.hpp&gt;</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="preprocessor">#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="keyword">namespace </span>antlr {
<a name="l00015"></a>00015 <span class="preprocessor">#endif</span>
<a name="l00016"></a>00016 <span class="preprocessor"></span>
<a name="l00017"></a>00017    <span class="keyword">class </span><a class="code" href="classAST.html">AST</a>;
<a name="l00018"></a>00018 
<a name="l00019"></a><a class="code" href="structASTRef.html">00019</a> <span class="keyword">struct </span><a class="code" href="config_8hpp.html#ad583892c7af76867441115e41aa1ce52">ANTLR_API</a> <a class="code" href="structASTRef.html">ASTRef</a>
<a name="l00020"></a>00020 {
<a name="l00021"></a><a class="code" href="structASTRef.html#a10c3e8f3fc4bae37aba9f6a642583b89">00021</a>    <a class="code" href="classAST.html">AST</a>* <span class="keyword">const</span> <a class="code" href="structASTRef.html#a10c3e8f3fc4bae37aba9f6a642583b89">ptr</a>;
<a name="l00022"></a><a class="code" href="structASTRef.html#a28e52e59a54e707c76f1fdba2ae6cf0f">00022</a>    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structASTRef.html#a28e52e59a54e707c76f1fdba2ae6cf0f">count</a>;
<a name="l00023"></a>00023 
<a name="l00024"></a>00024    <a class="code" href="structASTRef.html">ASTRef</a>(<a class="code" href="classAST.html">AST</a>* p);
<a name="l00025"></a>00025    ~<a class="code" href="structASTRef.html">ASTRef</a>();
<a name="l00026"></a><a class="code" href="structASTRef.html#ada4522ea4201952e6d53e1cb9e656b8e">00026</a>    <a class="code" href="structASTRef.html">ASTRef</a>* increment()
<a name="l00027"></a>00027    {
<a name="l00028"></a>00028       ++count;
<a name="l00029"></a>00029       <span class="keywordflow">return</span> <span class="keyword">this</span>;
<a name="l00030"></a>00030    }
<a name="l00031"></a><a class="code" href="structASTRef.html#a1ce0da7aeab8e05d49bc967befb6951b">00031</a>    <span class="keywordtype">bool</span> decrement()
<a name="l00032"></a>00032    {
<a name="l00033"></a>00033       <span class="keywordflow">return</span> (--count==0);
<a name="l00034"></a>00034    }
<a name="l00035"></a>00035 
<a name="l00036"></a>00036    <span class="keyword">static</span> <a class="code" href="structASTRef.html">ASTRef</a>* getRef(<span class="keyword">const</span> <a class="code" href="classAST.html">AST</a>* p);
<a name="l00037"></a>00037 <span class="keyword">private</span>:
<a name="l00038"></a>00038    <a class="code" href="structASTRef.html">ASTRef</a>( <span class="keyword">const</span> <a class="code" href="structASTRef.html">ASTRef</a>&amp; );
<a name="l00039"></a>00039    <a class="code" href="structASTRef.html">ASTRef</a>&amp; operator=( <span class="keyword">const</span> <a class="code" href="structASTRef.html">ASTRef</a>&amp; );
<a name="l00040"></a>00040 };
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt;
<a name="l00043"></a><a class="code" href="classASTRefCount.html">00043</a>    <span class="keyword">class </span><a class="code" href="config_8hpp.html#ad583892c7af76867441115e41aa1ce52">ANTLR_API</a> <a class="code" href="classASTRefCount.html">ASTRefCount</a>
<a name="l00044"></a>00044 {
<a name="l00045"></a>00045 <span class="keyword">private</span>:
<a name="l00046"></a><a class="code" href="classASTRefCount.html#a57ebfcef5838bff839049d1b2ed16df3">00046</a>    <a class="code" href="structASTRef.html">ASTRef</a>* <a class="code" href="classASTRefCount.html#a57ebfcef5838bff839049d1b2ed16df3">ref</a>;
<a name="l00047"></a>00047 
<a name="l00048"></a>00048 <span class="keyword">public</span>:
<a name="l00049"></a><a class="code" href="classASTRefCount.html#ab7c755df93eda89c550ace2cf4b1dbd5">00049</a>    <a class="code" href="classASTRefCount.html">ASTRefCount</a>(<span class="keyword">const</span> <a class="code" href="classAST.html">AST</a>* p=0)
<a name="l00050"></a>00050    : ref(p ? <a class="code" href="structASTRef.html">ASTRef</a>::getRef(p) : 0)
<a name="l00051"></a>00051    {
<a name="l00052"></a>00052    }
<a name="l00053"></a><a class="code" href="classASTRefCount.html#a1bff3dfd0ee4d153ae64df57e4f196c8">00053</a>    <a class="code" href="classASTRefCount.html">ASTRefCount</a>(<span class="keyword">const</span> <a class="code" href="classASTRefCount.html">ASTRefCount&lt;T&gt;</a>&amp; other)
<a name="l00054"></a>00054    : ref(other.ref ? other.ref-&gt;increment() : 0)
<a name="l00055"></a>00055    {
<a name="l00056"></a>00056    }
<a name="l00057"></a><a class="code" href="classASTRefCount.html#a97eeec4e5a8744a133498be5396e1681">00057</a>    ~<a class="code" href="classASTRefCount.html">ASTRefCount</a>()
<a name="l00058"></a>00058    {
<a name="l00059"></a>00059       <span class="keywordflow">if</span> (ref &amp;&amp; ref-&gt;decrement())
<a name="l00060"></a>00060          <span class="keyword">delete</span> ref;
<a name="l00061"></a>00061    }
<a name="l00062"></a><a class="code" href="classASTRefCount.html#a8bd9efd16d3526a5c922f5bbac83f06c">00062</a>    <a class="code" href="classASTRefCount.html">ASTRefCount&lt;T&gt;</a>&amp; operator=(<a class="code" href="classAST.html">AST</a>* other)
<a name="l00063"></a>00063    {
<a name="l00064"></a>00064       <a class="code" href="structASTRef.html">ASTRef</a>* tmp = <a class="code" href="structASTRef.html#a48fceba6cc8a36ca0bb12e25ed042223">ASTRef::getRef</a>(other);
<a name="l00065"></a>00065 
<a name="l00066"></a>00066       <span class="keywordflow">if</span> (ref &amp;&amp; ref-&gt;decrement())
<a name="l00067"></a>00067          <span class="keyword">delete</span> ref;
<a name="l00068"></a>00068 
<a name="l00069"></a>00069       ref=tmp;
<a name="l00070"></a>00070 
<a name="l00071"></a>00071       <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00072"></a>00072    }
<a name="l00073"></a><a class="code" href="classASTRefCount.html#a75c94d6f80c29a5f2ffc29af4c7a35cb">00073</a>    <a class="code" href="classASTRefCount.html">ASTRefCount&lt;T&gt;</a>&amp; operator=(<span class="keyword">const</span> <a class="code" href="classASTRefCount.html">ASTRefCount&lt;T&gt;</a>&amp; other)
<a name="l00074"></a>00074    {
<a name="l00075"></a>00075       <span class="keywordflow">if</span>( other.<a class="code" href="classASTRefCount.html#a57ebfcef5838bff839049d1b2ed16df3">ref</a> != ref )
<a name="l00076"></a>00076       {
<a name="l00077"></a>00077          <a class="code" href="structASTRef.html">ASTRef</a>* tmp = other.<a class="code" href="classASTRefCount.html#a57ebfcef5838bff839049d1b2ed16df3">ref</a> ? other.<a class="code" href="classASTRefCount.html#a57ebfcef5838bff839049d1b2ed16df3">ref</a>-&gt;<a class="code" href="structASTRef.html#ada4522ea4201952e6d53e1cb9e656b8e">increment</a>() : 0;
<a name="l00078"></a>00078 
<a name="l00079"></a>00079          <span class="keywordflow">if</span> (ref &amp;&amp; ref-&gt;decrement())
<a name="l00080"></a>00080             <span class="keyword">delete</span> ref;
<a name="l00081"></a>00081 
<a name="l00082"></a>00082          ref=tmp;
<a name="l00083"></a>00083       }
<a name="l00084"></a>00084       <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00085"></a>00085    }
<a name="l00086"></a>00086 
<a name="l00087"></a><a class="code" href="classASTRefCount.html#a9de6bd54ae70659df8d6dd2155e7171d">00087</a>    operator T* ()<span class="keyword">  const </span>{ <span class="keywordflow">return</span> ref ? <span class="keyword">static_cast&lt;</span>T*<span class="keyword">&gt;</span>(ref-&gt;ptr) : 0; }
<a name="l00088"></a><a class="code" href="classASTRefCount.html#a48a25dedcd7efb3eac5064e2fdd731fb">00088</a>    T* <a class="code" href="classASTRefCount.html#a48a25dedcd7efb3eac5064e2fdd731fb">operator-&gt;</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> ref ? <span class="keyword">static_cast&lt;</span>T*<span class="keyword">&gt;</span>(ref-&gt;ptr) : 0; }
<a name="l00089"></a><a class="code" href="classASTRefCount.html#a2d120393104100fc4784af680802876d">00089</a>    T* <span class="keyword">get</span>()        <span class="keyword">const</span> { <span class="keywordflow">return</span> ref ? <span class="keyword">static_cast&lt;</span>T*<span class="keyword">&gt;</span>(ref-&gt;ptr) : 0; }
<a name="l00090"></a>00090 };
<a name="l00091"></a>00091 
<a name="l00092"></a><a class="code" href="ASTRefCount_8hpp.html#a25b300faa8730e33c35b83c55afd2596">00092</a> <span class="keyword">typedef</span> <a class="code" href="classASTRefCount.html">ASTRefCount&lt;AST&gt;</a> <a class="code" href="ASTRefCount_8hpp.html#a25b300faa8730e33c35b83c55afd2596">RefAST</a>;
<a name="l00093"></a>00093 
<a name="l00094"></a>00094 <span class="preprocessor">#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE</span>
<a name="l00095"></a>00095 <span class="preprocessor"></span>}
<a name="l00096"></a>00096 <span class="preprocessor">#endif</span>
<a name="l00097"></a>00097 <span class="preprocessor"></span>
<a name="l00098"></a>00098 <span class="preprocessor">#endif //INC_ASTRefCount_hpp__</span>
</pre></div></div>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>Generated on Fri Mar 25 2011 for ANTLR Support Libraries 2.7.1+ by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
</body>
</html>