Sophie

Sophie

distrib > Fedora > 13 > i386 > media > os > by-pkgid > 07dfcfe50d66c9a48a3c5e6c1693f12a > files > 1878

cryptopp-doc-5.6.1-0.1.svn479.fc13.i686.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>Crypto++: queue.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.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;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&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>queue.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// specification file for an unlimited queue for storing bytes</span>
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="preprocessor">#ifndef CRYPTOPP_QUEUE_H</span>
<a name="l00004"></a>00004 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_QUEUE_H</span>
<a name="l00005"></a>00005 <span class="preprocessor"></span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &quot;<a class="code" href="simple_8h.html">simple.h</a>&quot;</span>
<a name="l00007"></a>00007 <span class="comment">//#include &lt;algorithm&gt;</span>
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 NAMESPACE_BEGIN(CryptoPP)
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="comment">/** The queue is implemented as a linked list of byte arrays, but you don&apos;t need to</span>
<a name="l00012"></a>00012 <span class="comment">    know about that.  So just ignore this next line. :) */</span>
<a name="l00013"></a>00013 class <a class="code" href="class_byte_queue_node.html">ByteQueueNode</a>;
<a name="l00014"></a>00014 <span class="comment"></span>
<a name="l00015"></a>00015 <span class="comment">//! Byte Queue</span>
<a name="l00016"></a><a class="code" href="class_byte_queue.html">00016</a> <span class="comment"></span>class CRYPTOPP_DLL <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> : public <a class="code" href="class_bufferless.html" title="_">Bufferless</a>&lt;<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a>&gt;
<a name="l00017"></a>00017 {
<a name="l00018"></a>00018 <span class="keyword">public</span>:
<a name="l00019"></a>00019         <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a>(<span class="keywordtype">size_t</span> nodeSize=0);
<a name="l00020"></a>00020         <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a>(<span class="keyword">const</span> <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;copy);
<a name="l00021"></a>00021         ~<a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a>();
<a name="l00022"></a>00022 
<a name="l00023"></a><a class="code" href="class_byte_queue.html#a56f851da4a1e9518c2b7005807aecab8">00023</a>         lword MaxRetrievable()<span class="keyword"> const</span>
<a name="l00024"></a>00024 <span class="keyword">                </span>{<span class="keywordflow">return</span> CurrentSize();}
<a name="l00025"></a><a class="code" href="class_byte_queue.html#a9f509e02fb4b1f1587d6b5a001ff43f7">00025</a>         <span class="keywordtype">bool</span> AnyRetrievable()<span class="keyword"> const</span>
<a name="l00026"></a>00026 <span class="keyword">                </span>{<span class="keywordflow">return</span> !IsEmpty();}
<a name="l00027"></a>00027 
<a name="l00028"></a>00028         <span class="keywordtype">void</span> IsolatedInitialize(<span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a> &amp;parameters);
<a name="l00029"></a>00029         byte * CreatePutSpace(<span class="keywordtype">size_t</span> &amp;size);
<a name="l00030"></a>00030         <span class="keywordtype">size_t</span> Put2(<span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> length, <span class="keywordtype">int</span> messageEnd, <span class="keywordtype">bool</span> blocking);
<a name="l00031"></a>00031 
<a name="l00032"></a>00032         <span class="keywordtype">size_t</span> Get(byte &amp;outByte);
<a name="l00033"></a>00033         <span class="keywordtype">size_t</span> Get(byte *outString, <span class="keywordtype">size_t</span> getMax);
<a name="l00034"></a>00034 
<a name="l00035"></a>00035         <span class="keywordtype">size_t</span> Peek(byte &amp;outByte) <span class="keyword">const</span>;
<a name="l00036"></a>00036         <span class="keywordtype">size_t</span> Peek(byte *outString, <span class="keywordtype">size_t</span> peekMax) <span class="keyword">const</span>;
<a name="l00037"></a>00037 
<a name="l00038"></a>00038         <span class="keywordtype">size_t</span> TransferTo2(BufferedTransformation &amp;target, lword &amp;transferBytes, <span class="keyword">const</span> std::string &amp;channel=DEFAULT_CHANNEL, <span class="keywordtype">bool</span> blocking=<span class="keyword">true</span>);
<a name="l00039"></a>00039         <span class="keywordtype">size_t</span> CopyRangeTo2(BufferedTransformation &amp;target, lword &amp;begin, lword end=LWORD_MAX, <span class="keyword">const</span> std::string &amp;channel=DEFAULT_CHANNEL, <span class="keywordtype">bool</span> blocking=<span class="keyword">true</span>) <span class="keyword">const</span>;
<a name="l00040"></a>00040 
<a name="l00041"></a>00041         <span class="comment">// these member functions are not inherited</span>
<a name="l00042"></a>00042         <span class="keywordtype">void</span> SetNodeSize(<span class="keywordtype">size_t</span> nodeSize);
<a name="l00043"></a>00043 
<a name="l00044"></a>00044         lword CurrentSize() <span class="keyword">const</span>;
<a name="l00045"></a>00045         <span class="keywordtype">bool</span> IsEmpty() <span class="keyword">const</span>;
<a name="l00046"></a>00046 
<a name="l00047"></a>00047         <span class="keywordtype">void</span> Clear();
<a name="l00048"></a>00048 
<a name="l00049"></a>00049         <span class="keywordtype">void</span> Unget(byte inByte);
<a name="l00050"></a>00050         <span class="keywordtype">void</span> Unget(<span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> length);
<a name="l00051"></a>00051 
<a name="l00052"></a>00052         <span class="keyword">const</span> byte * Spy(<span class="keywordtype">size_t</span> &amp;contiguousSize) <span class="keyword">const</span>;
<a name="l00053"></a>00053 
<a name="l00054"></a>00054         <span class="keywordtype">void</span> LazyPut(<span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> size);
<a name="l00055"></a>00055         <span class="keywordtype">void</span> LazyPutModifiable(byte *inString, <span class="keywordtype">size_t</span> size);
<a name="l00056"></a>00056         <span class="keywordtype">void</span> UndoLazyPut(<span class="keywordtype">size_t</span> size);
<a name="l00057"></a>00057         <span class="keywordtype">void</span> FinalizeLazyPut();
<a name="l00058"></a>00058 
<a name="l00059"></a>00059         <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp; operator=(<span class="keyword">const</span> <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;rhs);
<a name="l00060"></a>00060         <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;rhs) <span class="keyword">const</span>;
<a name="l00061"></a>00061         byte operator[](lword i) <span class="keyword">const</span>;
<a name="l00062"></a>00062         <span class="keywordtype">void</span> swap(<a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;rhs);
<a name="l00063"></a>00063 
<a name="l00064"></a><a class="code" href="class_byte_queue_1_1_walker.html">00064</a>         <span class="keyword">class </span><a class="code" href="class_byte_queue_1_1_walker.html">Walker</a> : <span class="keyword">public</span> <a class="code" href="class_input_rejecting.html" title="_">InputRejecting</a>&lt;BufferedTransformation&gt;
<a name="l00065"></a>00065         {
<a name="l00066"></a>00066         <span class="keyword">public</span>:
<a name="l00067"></a>00067                 <a class="code" href="class_byte_queue_1_1_walker.html">Walker</a>(<span class="keyword">const</span> <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;queue)
<a name="l00068"></a>00068                         : m_queue(queue) {Initialize();}
<a name="l00069"></a>00069 
<a name="l00070"></a>00070                 lword GetCurrentPosition() {<span class="keywordflow">return</span> m_position;}
<a name="l00071"></a>00071 
<a name="l00072"></a><a class="code" href="class_byte_queue_1_1_walker.html#a3c69dce9261b937f265bae9e8c26479f">00072</a>                 lword MaxRetrievable()<span class="keyword"> const</span>
<a name="l00073"></a>00073 <span class="keyword">                        </span>{<span class="keywordflow">return</span> m_queue.CurrentSize() - m_position;}
<a name="l00074"></a>00074 
<a name="l00075"></a>00075                 <span class="keywordtype">void</span> IsolatedInitialize(<span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a> &amp;parameters);
<a name="l00076"></a>00076 
<a name="l00077"></a>00077                 <span class="keywordtype">size_t</span> Get(byte &amp;outByte);
<a name="l00078"></a>00078                 <span class="keywordtype">size_t</span> Get(byte *outString, <span class="keywordtype">size_t</span> getMax);
<a name="l00079"></a>00079 
<a name="l00080"></a>00080                 <span class="keywordtype">size_t</span> Peek(byte &amp;outByte) <span class="keyword">const</span>;
<a name="l00081"></a>00081                 <span class="keywordtype">size_t</span> Peek(byte *outString, <span class="keywordtype">size_t</span> peekMax) <span class="keyword">const</span>;
<a name="l00082"></a>00082 
<a name="l00083"></a>00083                 <span class="keywordtype">size_t</span> TransferTo2(BufferedTransformation &amp;target, lword &amp;transferBytes, <span class="keyword">const</span> std::string &amp;channel=DEFAULT_CHANNEL, <span class="keywordtype">bool</span> blocking=<span class="keyword">true</span>);
<a name="l00084"></a>00084                 <span class="keywordtype">size_t</span> CopyRangeTo2(BufferedTransformation &amp;target, lword &amp;begin, lword end=LWORD_MAX, <span class="keyword">const</span> std::string &amp;channel=DEFAULT_CHANNEL, <span class="keywordtype">bool</span> blocking=<span class="keyword">true</span>) <span class="keyword">const</span>;
<a name="l00085"></a>00085 
<a name="l00086"></a>00086         <span class="keyword">private</span>:
<a name="l00087"></a>00087                 <span class="keyword">const</span> <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;m_queue;
<a name="l00088"></a>00088                 <span class="keyword">const</span> ByteQueueNode *m_node;
<a name="l00089"></a>00089                 lword m_position;
<a name="l00090"></a>00090                 <span class="keywordtype">size_t</span> m_offset;
<a name="l00091"></a>00091                 <span class="keyword">const</span> byte *m_lazyString;
<a name="l00092"></a>00092                 <span class="keywordtype">size_t</span> m_lazyLength;
<a name="l00093"></a>00093         };
<a name="l00094"></a>00094 
<a name="l00095"></a>00095         <span class="keyword">friend</span> <span class="keyword">class </span>Walker;
<a name="l00096"></a>00096 
<a name="l00097"></a>00097 <span class="keyword">private</span>:
<a name="l00098"></a>00098         <span class="keywordtype">void</span> CleanupUsedNodes();
<a name="l00099"></a>00099         <span class="keywordtype">void</span> CopyFrom(<span class="keyword">const</span> <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;copy);
<a name="l00100"></a>00100         <span class="keywordtype">void</span> Destroy();
<a name="l00101"></a>00101 
<a name="l00102"></a>00102         <span class="keywordtype">bool</span> m_autoNodeSize;
<a name="l00103"></a>00103         <span class="keywordtype">size_t</span> m_nodeSize;
<a name="l00104"></a>00104         ByteQueueNode *m_head, *m_tail;
<a name="l00105"></a>00105         byte *m_lazyString;
<a name="l00106"></a>00106         <span class="keywordtype">size_t</span> m_lazyLength;
<a name="l00107"></a>00107         <span class="keywordtype">bool</span> m_lazyStringModifiable;
<a name="l00108"></a>00108 };
<a name="l00109"></a>00109 <span class="comment"></span>
<a name="l00110"></a>00110 <span class="comment">//! use this to make sure LazyPut is finalized in event of exception</span>
<a name="l00111"></a><a class="code" href="class_lazy_putter.html">00111</a> <span class="comment"></span><span class="keyword">class </span>CRYPTOPP_DLL <a class="code" href="class_lazy_putter.html" title="use this to make sure LazyPut is finalized in event of exception">LazyPutter</a>
<a name="l00112"></a>00112 {
<a name="l00113"></a>00113 <span class="keyword">public</span>:
<a name="l00114"></a>00114         <a class="code" href="class_lazy_putter.html" title="use this to make sure LazyPut is finalized in event of exception">LazyPutter</a>(<a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;bq, <span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> size)
<a name="l00115"></a>00115                 : m_bq(bq) {bq.LazyPut(inString, size);}
<a name="l00116"></a>00116         ~<a class="code" href="class_lazy_putter.html" title="use this to make sure LazyPut is finalized in event of exception">LazyPutter</a>()
<a name="l00117"></a>00117                 {<span class="keywordflow">try</span> {m_bq.FinalizeLazyPut();} <span class="keywordflow">catch</span>(...) {}}
<a name="l00118"></a>00118 <span class="keyword">protected</span>:
<a name="l00119"></a>00119         <a class="code" href="class_lazy_putter.html" title="use this to make sure LazyPut is finalized in event of exception">LazyPutter</a>(<a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;bq) : m_bq(bq) {}
<a name="l00120"></a>00120 <span class="keyword">private</span>:
<a name="l00121"></a>00121         <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;m_bq;
<a name="l00122"></a>00122 };
<a name="l00123"></a>00123 <span class="comment"></span>
<a name="l00124"></a>00124 <span class="comment">//! like LazyPutter, but does a LazyPutModifiable instead</span>
<a name="l00125"></a><a class="code" href="class_lazy_putter_modifiable.html">00125</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="class_lazy_putter_modifiable.html" title="like LazyPutter, but does a LazyPutModifiable instead">LazyPutterModifiable</a> : <span class="keyword">public</span> <a class="code" href="class_lazy_putter.html" title="use this to make sure LazyPut is finalized in event of exception">LazyPutter</a>
<a name="l00126"></a>00126 {
<a name="l00127"></a>00127 <span class="keyword">public</span>:
<a name="l00128"></a>00128         <a class="code" href="class_lazy_putter_modifiable.html" title="like LazyPutter, but does a LazyPutModifiable instead">LazyPutterModifiable</a>(<a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;bq, byte *inString, <span class="keywordtype">size_t</span> size)
<a name="l00129"></a>00129                 : <a class="code" href="class_lazy_putter.html" title="use this to make sure LazyPut is finalized in event of exception">LazyPutter</a>(bq) {bq.LazyPutModifiable(inString, size);}
<a name="l00130"></a>00130 };
<a name="l00131"></a>00131 
<a name="l00132"></a>00132 NAMESPACE_END
<a name="l00133"></a>00133 
<a name="l00134"></a>00134 <span class="preprocessor">#ifndef __BORLANDC__</span>
<a name="l00135"></a>00135 <span class="preprocessor"></span>NAMESPACE_BEGIN(std)
<a name="l00136"></a>00136 template&lt;&gt; inline <span class="keywordtype">void</span> swap(CryptoPP::<a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;a, CryptoPP::<a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;b)
<a name="l00137"></a>00137 {
<a name="l00138"></a>00138         a.swap(b);
<a name="l00139"></a>00139 }
<a name="l00140"></a>00140 NAMESPACE_END
<a name="l00141"></a>00141 <span class="preprocessor">#endif</span>
<a name="l00142"></a>00142 <span class="preprocessor"></span>
<a name="l00143"></a>00143 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 9 Dec 2009 for Crypto++ by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>