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

📄 mqueue_8cpp-source.html

📁 著名的密码库Crypto++的文档 C++语言的杰作。程序员必备。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>Crypto++: mqueue.cpp Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.5.2 --><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="classes.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>mqueue.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// mqueue.cpp - written and placed in the public domain by Wei Dai</span><a name="l00002"></a>00002 <a name="l00003"></a>00003 <span class="preprocessor">#include "pch.h"</span><a name="l00004"></a>00004 <a name="l00005"></a>00005 <span class="preprocessor">#ifndef CRYPTOPP_IMPORTS</span><a name="l00006"></a>00006 <span class="preprocessor"></span><a name="l00007"></a>00007 <span class="preprocessor">#include "mqueue.h"</span><a name="l00008"></a>00008 <a name="l00009"></a>00009 NAMESPACE_BEGIN(CryptoPP)<a name="l00010"></a>00010 <a name="l00011"></a><a class="code" href="class_message_queue.html#99e63c7e22a03a87374a74880f75a586">00011</a> <a class="code" href="class_message_queue.html" title="Message Queue.">MessageQueue</a>::<a class="code" href="class_message_queue.html" title="Message Queue.">MessageQueue</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nodeSize)<a name="l00012"></a>00012         : m_queue(nodeSize), m_lengths(1, 0U), m_messageCounts(1, 0U)<a name="l00013"></a>00013 {<a name="l00014"></a>00014 }<a name="l00015"></a>00015 <a name="l00016"></a><a class="code" href="class_message_queue.html#d5db7457b26710e5485b177148bc32a2">00016</a> <span class="keywordtype">size_t</span> <a class="code" href="class_message_queue.html#d5db7457b26710e5485b177148bc32a2" title="upon return, begin contains the start position of data yet to be finished copying...">MessageQueue::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="l00017"></a>00017 <span class="keyword"></span>{<a name="l00018"></a>00018         <span class="keywordflow">if</span> (begin &gt;= <a class="code" href="class_message_queue.html#fc8f0d4551de7b0a19d7747420015d1c" title="returns number of bytes that is currently ready for retrieval">MaxRetrievable</a>())<a name="l00019"></a>00019                 <span class="keywordflow">return</span> 0;<a name="l00020"></a>00020 <a name="l00021"></a>00021         <span class="keywordflow">return</span> m_queue.<a class="code" href="class_byte_queue.html#2e01511f0b75d85132e5330e234ffbd5" title="upon return, begin contains the start position of data yet to be finished copying...">CopyRangeTo2</a>(target, begin, STDMIN(<a class="code" href="class_message_queue.html#fc8f0d4551de7b0a19d7747420015d1c" title="returns number of bytes that is currently ready for retrieval">MaxRetrievable</a>(), end), channel, blocking);<a name="l00022"></a>00022 }<a name="l00023"></a>00023 <a name="l00024"></a><a class="code" href="class_message_queue.html#65c71bd159403e0a569ecb1eb8b4a2ed">00024</a> <span class="keywordtype">size_t</span> <a class="code" href="class_message_queue.html#65c71bd159403e0a569ecb1eb8b4a2ed" title="upon return, byteCount contains number of bytes that have finished being transfered...">MessageQueue::TransferTo2</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &amp;target, lword &amp;transferBytes, <span class="keyword">const</span> std::string &amp;channel, <span class="keywordtype">bool</span> blocking)<a name="l00025"></a>00025 {<a name="l00026"></a>00026         transferBytes = STDMIN(<a class="code" href="class_message_queue.html#fc8f0d4551de7b0a19d7747420015d1c" title="returns number of bytes that is currently ready for retrieval">MaxRetrievable</a>(), transferBytes);<a name="l00027"></a>00027         <span class="keywordtype">size_t</span> blockedBytes = m_queue.<a class="code" href="class_byte_queue.html#35a4820b4ff8c30479423ac672cd264f" title="upon return, byteCount contains number of bytes that have finished being transfered...">TransferTo2</a>(target, transferBytes, channel, blocking);<a name="l00028"></a>00028         m_lengths.front() -= transferBytes;<a name="l00029"></a>00029         <span class="keywordflow">return</span> blockedBytes;<a name="l00030"></a>00030 }<a name="l00031"></a>00031 <a name="l00032"></a><a class="code" href="class_message_queue.html#540da279953a13541a65c271888e27b7">00032</a> <span class="keywordtype">bool</span> <a class="code" href="class_message_queue.html#540da279953a13541a65c271888e27b7" title="start retrieving the next message">MessageQueue::GetNextMessage</a>()<a name="l00033"></a>00033 {<a name="l00034"></a>00034         <span class="keywordflow">if</span> (<a class="code" href="class_message_queue.html#a4b2a11a888efea5f9ca388d8a730bba" title="number of times MessageEnd() has been received minus messages retrieved or skipped...">NumberOfMessages</a>() &gt; 0 &amp;&amp; !<a class="code" href="class_message_queue.html#1f9ba84c015a1ca041ae7765c423e711" title="returns whether any bytes are currently ready for retrieval">AnyRetrievable</a>())<a name="l00035"></a>00035         {<a name="l00036"></a>00036                 m_lengths.pop_front();<a name="l00037"></a>00037                 <span class="keywordflow">if</span> (m_messageCounts[0] == 0 &amp;&amp; m_messageCounts.size() &gt; 1)<a name="l00038"></a>00038                         m_messageCounts.pop_front();<a name="l00039"></a>00039                 <span class="keywordflow">return</span> <span class="keyword">true</span>;<a name="l00040"></a>00040         }<a name="l00041"></a>00041         <span class="keywordflow">else</span><a name="l00042"></a>00042                 <span class="keywordflow">return</span> <span class="keyword">false</span>;<a name="l00043"></a>00043 }<a name="l00044"></a>00044 <a name="l00045"></a><a class="code" href="class_message_queue.html#67143ef5e88c34f3af8547a9a400af26">00045</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_message_queue.html#67143ef5e88c34f3af8547a9a400af26">MessageQueue::CopyMessagesTo</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &amp;target, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> count, <span class="keyword">const</span> std::string &amp;channel)<span class="keyword"> const</span><a name="l00046"></a>00046 <span class="keyword"></span>{<a name="l00047"></a>00047         <a class="code" href="class_byte_queue_1_1_walker.html">ByteQueue::Walker</a> walker(m_queue);<a name="l00048"></a>00048         std::deque&lt;lword&gt;::const_iterator it = m_lengths.begin();<a name="l00049"></a>00049         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;<a name="l00050"></a>00050         <span class="keywordflow">for</span> (i=0; i&lt;count &amp;&amp; it != --m_lengths.end(); ++i, ++it)<a name="l00051"></a>00051         {<a name="l00052"></a>00052                 walker.<a class="code" href="class_buffered_transformation.html#91c4526148274ae9cb68803bb2d2a2aa" title="move transferMax bytes of the buffered output to target as input">TransferTo</a>(target, *it, channel);<a name="l00053"></a>00053                 <span class="keywordflow">if</span> (<a class="code" href="class_auto_signaling.html#011dc89743a4790bdd2ddefd9f176766">GetAutoSignalPropagation</a>())<a name="l00054"></a>00054                         target.<a class="code" href="class_buffered_transformation.html#e0b37b299c5835083e58b205f9cc25cc">ChannelMessageEnd</a>(channel, <a class="code" href="class_auto_signaling.html#011dc89743a4790bdd2ddefd9f176766">GetAutoSignalPropagation</a>()-1);<a name="l00055"></a>00055         }<a name="l00056"></a>00056         <span class="keywordflow">return</span> i;<a name="l00057"></a>00057 }<a name="l00058"></a>00058 <a name="l00059"></a><a class="code" href="class_message_queue.html#0cf7618db89d28cb81aa7ddfc29b3d85">00059</a> <span class="keywordtype">void</span> <a class="code" href="class_message_queue.html#0cf7618db89d28cb81aa7ddfc29b3d85">MessageQueue::swap</a>(<a class="code" href="class_message_queue.html" title="Message Queue.">MessageQueue</a> &amp;rhs)<a name="l00060"></a>00060 {<a name="l00061"></a>00061         m_queue.<a class="code" href="class_byte_queue.html#dcf03598210a516afc86abfb51ce5eb8">swap</a>(rhs.<a class="code" href="class_message_queue.html#8b5af2b250ac477627a8c0b53086e34e">m_queue</a>);<a name="l00062"></a>00062         m_lengths.swap(rhs.<a class="code" href="class_message_queue.html#6db102cc7dcf86ee6a8e265063a25ef3">m_lengths</a>);<a name="l00063"></a>00063 }<a name="l00064"></a>00064 <a name="l00065"></a><a class="code" href="class_message_queue.html#1ac8683683155bd2d04bb489e1106449">00065</a> <span class="keyword">const</span> byte * <a class="code" href="class_message_queue.html#1ac8683683155bd2d04bb489e1106449">MessageQueue::Spy</a>(<span class="keywordtype">size_t</span> &amp;contiguousSize)<span class="keyword"> const</span><a name="l00066"></a>00066 <span class="keyword"></span>{<a name="l00067"></a>00067         <span class="keyword">const</span> byte *result = m_queue.<a class="code" href="class_byte_queue.html#18f79d62aa125a795cf61444d1076cde">Spy</a>(contiguousSize);<a name="l00068"></a>00068         contiguousSize = UnsignedMin(contiguousSize, <a class="code" href="class_message_queue.html#fc8f0d4551de7b0a19d7747420015d1c" title="returns number of bytes that is currently ready for retrieval">MaxRetrievable</a>());<a name="l00069"></a>00069         <span class="keywordflow">return</span> result;<a name="l00070"></a>00070 }<a name="l00071"></a>00071 <a name="l00072"></a>00072 <span class="comment">// *************************************************************</span><a name="l00073"></a>00073 <a name="l00074"></a>00074 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> EqualityComparisonFilter::MapChannel(<span class="keyword">const</span> std::string &amp;channel)<span class="keyword"> const</span><a name="l00075"></a>00075 <span class="keyword"></span>{<a name="l00076"></a>00076         <span class="keywordflow">if</span> (channel == m_firstChannel)<a name="l00077"></a>00077                 <span class="keywordflow">return</span> 0;<a name="l00078"></a>00078         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (channel == m_secondChannel)<a name="l00079"></a>00079                 <span class="keywordflow">return</span> 1;<a name="l00080"></a>00080         <span class="keywordflow">else</span>

⌨️ 快捷键说明

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