⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 queue_8cpp-source.html

📁 著名的密码库Crypto++的文档 C++语言的杰作。程序员必备。
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00337"></a>00337         <span class="keywordflow">if</span> (blocking)<a name="l00338"></a>00338         {<a name="l00339"></a>00339                 lword bytesLeft = transferBytes;<a name="l00340"></a>00340                 <span class="keywordflow">for</span> (<a class="code" href="class_byte_queue_node.html">ByteQueueNode</a> *current=m_head; bytesLeft &amp;&amp; current; current=current-&gt;<a class="code" href="class_byte_queue_node.html#ee1bdb525b2dd8c5d98de76949a85b1a">next</a>)<a name="l00341"></a>00341                         bytesLeft -= current-&gt;TransferTo(target, bytesLeft, channel);<a name="l00342"></a>00342                 CleanupUsedNodes();<a name="l00343"></a>00343 <a name="l00344"></a>00344                 <span class="keywordtype">size_t</span> len = (size_t)STDMIN(bytesLeft, (lword)m_lazyLength);<a name="l00345"></a>00345                 <span class="keywordflow">if</span> (len)<a name="l00346"></a>00346                 {<a name="l00347"></a>00347                         <span class="keywordflow">if</span> (m_lazyStringModifiable)<a name="l00348"></a>00348                                 target.<a class="code" href="class_buffered_transformation.html#3dc27692b14108ed057beb4db67fed2f">ChannelPutModifiable</a>(channel, m_lazyString, len);<a name="l00349"></a>00349                         <span class="keywordflow">else</span><a name="l00350"></a>00350                                 target.<a class="code" href="class_buffered_transformation.html#97a60b54fafdb3df59e1457ef629fc5f">ChannelPut</a>(channel, m_lazyString, len);<a name="l00351"></a>00351                         m_lazyString += len;<a name="l00352"></a>00352                         m_lazyLength -= len;<a name="l00353"></a>00353                         bytesLeft -= len;<a name="l00354"></a>00354                 }<a name="l00355"></a>00355                 transferBytes -= bytesLeft;<a name="l00356"></a>00356                 <span class="keywordflow">return</span> 0;<a name="l00357"></a>00357         }<a name="l00358"></a>00358         <span class="keywordflow">else</span><a name="l00359"></a>00359         {<a name="l00360"></a>00360                 <a class="code" href="class_byte_queue_1_1_walker.html">Walker</a> walker(*<span class="keyword">this</span>);<a name="l00361"></a>00361                 <span class="keywordtype">size_t</span> blockedBytes = walker.<a class="code" href="class_byte_queue_1_1_walker.html#b5d6312affb66b46b7fbcd7f95e0ec4d" title="upon return, byteCount contains number of bytes that have finished being transfered...">TransferTo2</a>(target, transferBytes, channel, blocking);<a name="l00362"></a>00362                 <a class="code" href="class_buffered_transformation.html#0c25529ded99db20ad35ccef3f7234e6" title="discard skipMax bytes from the output buffer">Skip</a>(transferBytes);<a name="l00363"></a>00363                 <span class="keywordflow">return</span> blockedBytes;<a name="l00364"></a>00364         }<a name="l00365"></a>00365 }<a name="l00366"></a>00366 <a name="l00367"></a><a class="code" href="class_byte_queue.html#2e01511f0b75d85132e5330e234ffbd5">00367</a> <span class="keywordtype">size_t</span> <a class="code" href="class_byte_queue.html#2e01511f0b75d85132e5330e234ffbd5" title="upon return, begin contains the start position of data yet to be finished copying...">ByteQueue::CopyRangeTo2</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &amp;target, lword &amp;begin, lword end, <span class="keyword">const</span> std::string &amp;channel, <span class="keywordtype">bool</span> blocking)<span class="keyword"> const</span><a name="l00368"></a>00368 <span class="keyword"></span>{<a name="l00369"></a>00369         <a class="code" href="class_byte_queue_1_1_walker.html">Walker</a> walker(*<span class="keyword">this</span>);<a name="l00370"></a>00370         walker.<a class="code" href="class_buffered_transformation.html#0c25529ded99db20ad35ccef3f7234e6" title="discard skipMax bytes from the output buffer">Skip</a>(begin);<a name="l00371"></a>00371         lword transferBytes = end-begin;<a name="l00372"></a>00372         <span class="keywordtype">size_t</span> blockedBytes = walker.<a class="code" href="class_byte_queue_1_1_walker.html#b5d6312affb66b46b7fbcd7f95e0ec4d" title="upon return, byteCount contains number of bytes that have finished being transfered...">TransferTo2</a>(target, transferBytes, channel, blocking);<a name="l00373"></a>00373         begin += transferBytes;<a name="l00374"></a>00374         <span class="keywordflow">return</span> blockedBytes;<a name="l00375"></a>00375 }<a name="l00376"></a>00376 <a name="l00377"></a><a class="code" href="class_byte_queue.html#bdc94324169d07db16a246259c5ef86b">00377</a> <span class="keywordtype">void</span> <a class="code" href="class_byte_queue.html#bdc94324169d07db16a246259c5ef86b">ByteQueue::Unget</a>(byte inByte)<a name="l00378"></a>00378 {<a name="l00379"></a>00379         <a class="code" href="class_byte_queue.html#bdc94324169d07db16a246259c5ef86b">Unget</a>(&amp;inByte, 1);<a name="l00380"></a>00380 }<a name="l00381"></a>00381 <a name="l00382"></a><a class="code" href="class_byte_queue.html#2d72210af03aea4ca132ed46d91b67e1">00382</a> <span class="keywordtype">void</span> <a class="code" href="class_byte_queue.html#bdc94324169d07db16a246259c5ef86b">ByteQueue::Unget</a>(<span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> length)<a name="l00383"></a>00383 {<a name="l00384"></a>00384         <span class="keywordtype">size_t</span> len = STDMIN(length, m_head-&gt;<a class="code" href="class_byte_queue_node.html#9e6ccb37abf190e3cb70dbda47cf4f02">m_head</a>);<a name="l00385"></a>00385         length -= len;<a name="l00386"></a>00386         m_head-&gt;<a class="code" href="class_byte_queue_node.html#9e6ccb37abf190e3cb70dbda47cf4f02">m_head</a> -= len;<a name="l00387"></a>00387         memcpy(m_head-&gt;<a class="code" href="class_byte_queue_node.html#1872d9ce267ef28d540e3353d0bf6ce9">buf</a> + m_head-&gt;<a class="code" href="class_byte_queue_node.html#9e6ccb37abf190e3cb70dbda47cf4f02">m_head</a>, inString + length, len);<a name="l00388"></a>00388 <a name="l00389"></a>00389         <span class="keywordflow">if</span> (length &gt; 0)<a name="l00390"></a>00390         {<a name="l00391"></a>00391                 <a class="code" href="class_byte_queue_node.html">ByteQueueNode</a> *newHead = <span class="keyword">new</span> <a class="code" href="class_byte_queue_node.html">ByteQueueNode</a>(length);<a name="l00392"></a>00392                 newHead-&gt;<a class="code" href="class_byte_queue_node.html#ee1bdb525b2dd8c5d98de76949a85b1a">next</a> = m_head;<a name="l00393"></a>00393                 m_head = newHead;<a name="l00394"></a>00394                 m_head-&gt;<a class="code" href="class_byte_queue_node.html#b27aedd63e91d00402d892a908842d6e">Put</a>(inString, length);<a name="l00395"></a>00395         }<a name="l00396"></a>00396 }<a name="l00397"></a>00397 <a name="l00398"></a><a class="code" href="class_byte_queue.html#18f79d62aa125a795cf61444d1076cde">00398</a> <span class="keyword">const</span> byte * <a class="code" href="class_byte_queue.html#18f79d62aa125a795cf61444d1076cde">ByteQueue::Spy</a>(<span class="keywordtype">size_t</span> &amp;contiguousSize)<span class="keyword"> const</span><a name="l00399"></a>00399 <span class="keyword"></span>{<a name="l00400"></a>00400         contiguousSize = m_head-&gt;<a class="code" href="class_byte_queue_node.html#fac0e8466bd492fb761f3cd6409c9077">m_tail</a> - m_head-&gt;<a class="code" href="class_byte_queue_node.html#9e6ccb37abf190e3cb70dbda47cf4f02">m_head</a>;<a name="l00401"></a>00401         <span class="keywordflow">if</span> (contiguousSize == 0 &amp;&amp; m_lazyLength &gt; 0)<a name="l00402"></a>00402         {<a name="l00403"></a>00403                 contiguousSize = m_lazyLength;<a name="l00404"></a>00404                 <span class="keywordflow">return</span> m_lazyString;<a name="l00405"></a>00405         }<a name="l00406"></a>00406         <span class="keywordflow">else</span><a name="l00407"></a>00407                 <span class="keywordflow">return</span> m_head-&gt;<a class="code" href="class_byte_queue_node.html#1872d9ce267ef28d540e3353d0bf6ce9">buf</a> + m_head-&gt;<a class="code" href="class_byte_queue_node.html#9e6ccb37abf190e3cb70dbda47cf4f02">m_head</a>;<a name="l00408"></a>00408 }<a name="l00409"></a>00409 <a name="l00410"></a><a class="code" href="class_byte_queue.html#e6b49917c3217c5e3b8dd71d40498e5f">00410</a> byte * <a class="code" href="class_byte_queue.html#e6b49917c3217c5e3b8dd71d40498e5f" title="request space which can be written into by the caller, and then used as input to...">ByteQueue::CreatePutSpace</a>(<span class="keywordtype">size_t</span> &amp;size)<a name="l00411"></a>00411 {<a name="l00412"></a>00412         <span class="keywordflow">if</span> (m_lazyLength &gt; 0)<a name="l00413"></a>00413                 <a class="code" href="class_byte_queue.html#6d004338c41f8e04a723c7adab5d0895">FinalizeLazyPut</a>();<a name="l00414"></a>00414 <a name="l00415"></a>00415         <span class="keywordflow">if</span> (m_tail-&gt;<a class="code" href="class_byte_queue_node.html#fac0e8466bd492fb761f3cd6409c9077">m_tail</a> == m_tail-&gt;<a class="code" href="class_byte_queue_node.html#cc8554e4c27e116a3fcd3bb2dc8d1480">MaxSize</a>())<a name="l00416"></a>00416         {<a name="l00417"></a>00417                 m_tail-&gt;<a class="code" href="class_byte_queue_node.html#ee1bdb525b2dd8c5d98de76949a85b1a">next</a> = <span class="keyword">new</span> <a class="code" href="class_byte_queue_node.html">ByteQueueNode</a>(STDMAX(m_nodeSize, size));<a name="l00418"></a>00418                 m_tail = m_tail-&gt;<a class="code" href="class_byte_queue_node.html#ee1bdb525b2dd8c5d98de76949a85b1a">next</a>;<a name="l00419"></a>00419         }<a name="l00420"></a>00420 <a name="l00421"></a>00421         size = m_tail-&gt;<a class="code" href="class_byte_queue_node.html#cc8554e4c27e116a3fcd3bb2dc8d1480">MaxSize</a>() - m_tail-&gt;<a class="code" href="class_byte_queue_node.html#fac0e8466bd492fb761f3cd6409c9077">m_tail</a>;<a name="l00422"></a>00422         <span class="keywordflow">return</span> m_tail-&gt;<a class="code" href="class_byte_queue_node.html#1872d9ce267ef28d540e3353d0bf6ce9">buf</a> + m_tail-&gt;<a class="code" href="class_byte_queue_node.html#fac0e8466bd492fb761f3cd6409c9077">m_tail</a>;<a name="l00423"></a>00423 }<a name="l00424"></a>00424 <a name="l00425"></a><a class="code" href="class_byte_queue.html#710873753ebe1fe0c1690ad09f42dadf">00425</a> <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp; <a class="code" href="class_byte_queue.html#710873753ebe1fe0c1690ad09f42dadf">ByteQueue::operator=</a>(<span class="keyword">const</span> <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> &amp;rhs)<a name="l00426"></a>00426 {<a name="l00427"></a>00427         Destroy();<a name="l00428"></a>00428         CopyFrom(rhs);<a name="l00429"></a>00429         <span class="keywordflow">return</span> *<span class="keyword">this</span>;<a name="l00430"></a>00430 }<a name="l00431"></a>00431 <a name="l00432"></a><a class="code" href="class_byte_queue.html#81690c024725d924c0dd9d0b7f8a689b">00432</a> <span class="keywordtype">bool</span> <a class="code" href="class_byte_queue.html#81690c024725d924c0dd9d0b7f8a689b">ByteQueue::operator==</a>(<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="l00433"></a>00433 <span class="keyword"></span>{<a name="l00434"></a>00434         <span class="keyword">const</span> lword currentSize = <a class="code" href="class_byte_queue.html#003ce4b0f9525589327800d0a14b455f">CurrentSize</a>();<a name="l00435"></a>00435 <a name="l00436"></a>00436         <span class="keywordflow">if</span> (currentSize != rhs.<a class="code" href="class_byte_queue.html#003ce4b0f9525589327800d0a14b455f">CurrentSize</a>())<a name="l00437"></a>00437                 <span class="keywordflow">return</span> <span class="keyword">false</span>;<a name="l00438"></a>00438 <a name="l00439"></a>00439         <a class="code" href="class_byte_queue_1_1_walker.html">Walker</a> walker1(*<span class="keyword">this</span>), walker2(rhs);<a name="l00440"></a>00440         byte b1, b2;<a name="l00441"></a>00441 <a name="l00442"></a>00442         <span class="keywordflow">while</span> (walker1.Get(b1) &amp;&amp; walker2.<a class="code" href="class_byte_queue_1_1_walker.html#1577996016d4fc5e644b86eb1a4f1660" title="try to retrieve a single byte">Get</a>(b2))<a name="l00443"></a>00443                 <span class="keywordflow">if</span> (b1 != b2)<a name="l00444"></a>00444                         <span class="keywordflow">return</span> <span class="keyword">false</span>;<a name="l00445"></a>00445 <a name="l00446"></a>00446         <span class="keywordflow">return</span> <span class="keyword">true</span>;<a name="l00447"></a>00447 }<a name="l00448"></a>00448 <a name="l00449"></a><a class="code" href="class_byte_queue.html#cf5572e6f21b61a8ceaddeae75f9a370">00449</a> byte <a class="code" href="class_byte_queue.html#cf5572e6f21b61a8ceaddeae75f9a370">ByteQueue::operator[]</a>(lword i)<span class="keyword"> const</span><a name="l00450"></a>00450 <span class="keyword"></span>{<a name="l00451"></a>00451         <span class="keywordflow">for</span> (<a class="code" href="class_byte_queue_node.html">ByteQueueNode</a> *current=m_head; current; current=current-&gt;<a class="code" href="class_byte_queue_node.html#ee1bdb525b2dd8c5d98de76949a85b1a">next</a>)<a name="l00452"></a>00452         {<a name="l00453"></a>00453                 <span class="keywordflow">if</span> (i &lt; current-&gt;<a class="code" href="class_byte_queue.html#003ce4b0f9525589327800d0a14b455f">CurrentSize</a>())<a name="l00454"></a>00454                         <span class="keywordflow">return</span> (*current)[(<span class="keywordtype">size_t</span>)i];<a name="l00455"></a>00455                 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -