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

📄 cryptlib_8h-source.html

📁 著名的密码库Crypto++的文档 C++语言的杰作。程序员必备。
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00168"></a>00168 };<a name="l00169"></a>00169 <span class="comment"></span><a name="l00170"></a>00170 <span class="comment">//! exception thrown by a class when Flush(true) is called but it can't completely flush its buffers</span><a name="l00171"></a><a class="code" href="class_cannot_flush.html">00171</a> <span class="comment"></span><span class="keyword">class </span>CRYPTOPP_DLL CannotFlush : <span class="keyword">public</span> <a class="code" href="class_exception.html" title="base class for all exceptions thrown by Crypto++">Exception</a><a name="l00172"></a>00172 {<a name="l00173"></a>00173 <span class="keyword">public</span>:<a name="l00174"></a><a class="code" href="class_cannot_flush.html#227170bcacb0d250c6ded893b22d4e5c">00174</a>         <span class="keyword">explicit</span> CannotFlush(<span class="keyword">const</span> std::string &amp;s) : <a class="code" href="class_exception.html" title="base class for all exceptions thrown by Crypto++">Exception</a>(CANNOT_FLUSH, s) {}<a name="l00175"></a>00175 };<a name="l00176"></a>00176 <span class="comment"></span><a name="l00177"></a>00177 <span class="comment">//! error reported by the operating system</span><a name="l00178"></a><a class="code" href="class_o_s___error.html">00178</a> <span class="comment"></span><span class="keyword">class </span>CRYPTOPP_DLL OS_Error : <span class="keyword">public</span> <a class="code" href="class_exception.html" title="base class for all exceptions thrown by Crypto++">Exception</a><a name="l00179"></a>00179 {<a name="l00180"></a>00180 <span class="keyword">public</span>:<a name="l00181"></a><a class="code" href="class_o_s___error.html#3a45a94888d38a5fdf6e85e6cf710383">00181</a>         OS_Error(<a class="code" href="class_exception.html#8e53909d979479380e0274807c074c0a" title="error types">ErrorType</a> errorType, <span class="keyword">const</span> std::string &amp;s, <span class="keyword">const</span> std::string&amp; operation, <span class="keywordtype">int</span> errorCode)<a name="l00182"></a>00182                 : <a class="code" href="class_exception.html" title="base class for all exceptions thrown by Crypto++">Exception</a>(errorType, s), m_operation(operation), m_errorCode(errorCode) {}<a name="l00183"></a><a class="code" href="class_o_s___error.html#967d47028c9f01ac6a6a488c872f348e">00183</a>         ~OS_Error() throw() {}<a name="l00184"></a>00184 <a name="l00185"></a>00185         <span class="comment">// the operating system API that reported the error</span><a name="l00186"></a><a class="code" href="class_o_s___error.html#e9e5215431fb6e791a0779dc38bb0faf">00186</a>         <span class="keyword">const</span> std::string &amp; GetOperation()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_operation;}<a name="l00187"></a>00187         <span class="comment">// the error code return by the operating system</span><a name="l00188"></a><a class="code" href="class_o_s___error.html#75ea8501f1009ee75c118e61eb303b0a">00188</a>         <span class="keywordtype">int</span> GetErrorCode()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_errorCode;}<a name="l00189"></a>00189 <a name="l00190"></a>00190 <span class="keyword">protected</span>:<a name="l00191"></a><a class="code" href="class_o_s___error.html#7bc701dd90fc92acb1931db13f0c92e0">00191</a>         std::string m_operation;<a name="l00192"></a><a class="code" href="class_o_s___error.html#46552a032d0ebf14b668070b1cd0e37d">00192</a>         <span class="keywordtype">int</span> m_errorCode;<a name="l00193"></a>00193 };<a name="l00194"></a>00194 <span class="comment"></span><a name="l00195"></a>00195 <span class="comment">//! used to return decoding results</span><a name="l00196"></a><a class="code" href="struct_decoding_result.html">00196</a> <span class="comment"></span><span class="keyword">struct </span>CRYPTOPP_DLL DecodingResult<a name="l00197"></a>00197 {<a name="l00198"></a><a class="code" href="struct_decoding_result.html#9e13518e1116d3a22a349c0ba9152bf3">00198</a>         <span class="keyword">explicit</span> DecodingResult() : isValidCoding(false), messageLength(0) {}<a name="l00199"></a><a class="code" href="struct_decoding_result.html#04f03ea66845fe03fc464de05a816bbb">00199</a>         <span class="keyword">explicit</span> DecodingResult(<span class="keywordtype">size_t</span> len) : isValidCoding(true), messageLength(len) {}<a name="l00200"></a>00200 <a name="l00201"></a><a class="code" href="struct_decoding_result.html#4ff48f3460b4a1a0238c08c97893867c">00201</a>         <span class="keywordtype">bool</span> <a class="code" href="gf2n_8h.html#22c25c181c409600aa2e4bf1067ac47a">operator==</a>(<span class="keyword">const</span> DecodingResult &amp;rhs)<span class="keyword"> const </span>{<span class="keywordflow">return</span> isValidCoding == rhs.<a class="code" href="struct_decoding_result.html#b88062318cd0e68b3061db351d3ba34d">isValidCoding</a> &amp;&amp; messageLength == rhs.<a class="code" href="struct_decoding_result.html#f4496c82e5764175a27e36629e1cded7">messageLength</a>;}<a name="l00202"></a><a class="code" href="struct_decoding_result.html#0d3e59dfd95799e1bd7adbcdd33aedeb">00202</a>         <span class="keywordtype">bool</span> <a class="code" href="gf2n_8h.html#98d9036c415975aa2f0fc09fab285459">operator!=</a>(<span class="keyword">const</span> DecodingResult &amp;rhs)<span class="keyword"> const </span>{<span class="keywordflow">return</span> !<a class="code" href="gf2n_8h.html#22c25c181c409600aa2e4bf1067ac47a">operator==</a>(rhs);}<a name="l00203"></a>00203 <a name="l00204"></a><a class="code" href="struct_decoding_result.html#b88062318cd0e68b3061db351d3ba34d">00204</a>         <span class="keywordtype">bool</span> isValidCoding;<a name="l00205"></a><a class="code" href="struct_decoding_result.html#f4496c82e5764175a27e36629e1cded7">00205</a>         <span class="keywordtype">size_t</span> messageLength;<a name="l00206"></a>00206 <a name="l00207"></a>00207 <span class="preprocessor">#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY</span><a name="l00208"></a>00208 <span class="preprocessor"></span>        operator size_t()<span class="keyword"> const </span>{<span class="keywordflow">return</span> isValidCoding ? messageLength : 0;}<a name="l00209"></a>00209 <span class="preprocessor">#endif</span><a name="l00210"></a>00210 <span class="preprocessor"></span>};<a name="l00211"></a>00211 <span class="comment"></span><a name="l00212"></a>00212 <span class="comment">//! interface for retrieving values given their names</span><a name="l00213"></a>00213 <span class="comment"></span><span class="comment">/*! \note This class is used to safely pass a variable number of arbitrarily typed arguments to functions</span><a name="l00214"></a>00214 <span class="comment">        and to read values from keys and crypto parameters.</span><a name="l00215"></a>00215 <span class="comment">        \note To obtain an object that implements NameValuePairs for the purpose of parameter</span><a name="l00216"></a>00216 <span class="comment">        passing, use the MakeParameters() function.</span><a name="l00217"></a>00217 <span class="comment">        \note To get a value from NameValuePairs, you need to know the name and the type of the value. </span><a name="l00218"></a>00218 <span class="comment">        Call GetValueNames() on a NameValuePairs object to obtain a list of value names that it supports.</span><a name="l00219"></a>00219 <span class="comment">        Then look at the Name namespace documentation to see what the type of each value is, or</span><a name="l00220"></a>00220 <span class="comment">        alternatively, call GetIntValue() with the value name, and if the type is not int, a</span><a name="l00221"></a>00221 <span class="comment">        ValueTypeMismatch exception will be thrown and you can get the actual type from the exception object.</span><a name="l00222"></a>00222 <span class="comment">*/</span><a name="l00223"></a><a class="code" href="class_name_value_pairs.html">00223</a> <span class="keyword">class </span>CRYPTOPP_NO_VTABLE <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a><a name="l00224"></a>00224 {<a name="l00225"></a>00225 <span class="keyword">public</span>:<a name="l00226"></a><a class="code" href="class_name_value_pairs.html#7ab9b908bbcf110bef6c441122696be2">00226</a>         <span class="keyword">virtual</span> ~<a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a>() {}<a name="l00227"></a>00227 <span class="comment"></span><a name="l00228"></a>00228 <span class="comment">        //! exception thrown when trying to retrieve a value using a different type than expected</span><a name="l00229"></a><a class="code" href="class_name_value_pairs_1_1_value_type_mismatch.html">00229</a> <span class="comment"></span>        <span class="keyword">class </span>CRYPTOPP_DLL ValueTypeMismatch : <span class="keyword">public</span> InvalidArgument<a name="l00230"></a>00230         {<a name="l00231"></a>00231         <span class="keyword">public</span>:<a name="l00232"></a><a class="code" href="class_name_value_pairs_1_1_value_type_mismatch.html#2ab530b91ce1f12ec7d7238ac53dc832">00232</a>                 ValueTypeMismatch(<span class="keyword">const</span> std::string &amp;name, <span class="keyword">const</span> std::type_info &amp;stored, <span class="keyword">const</span> std::type_info &amp;retrieving)<a name="l00233"></a>00233                         : InvalidArgument(<span class="stringliteral">"NameValuePairs: type mismatch for '"</span> + name + <span class="stringliteral">"', stored '"</span> + stored.name() + <span class="stringliteral">"', trying to retrieve '"</span> + retrieving.name() + <span class="stringliteral">"'"</span>)<a name="l00234"></a>00234                         , m_stored(stored), m_retrieving(retrieving) {}<a name="l00235"></a>00235 <a name="l00236"></a><a class="code" href="class_name_value_pairs_1_1_value_type_mismatch.html#8f827a7be9e3cec4574c7ecdf7a78156">00236</a>                 <span class="keyword">const</span> std::type_info &amp; GetStoredTypeInfo()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_stored;}<a name="l00237"></a><a class="code" href="class_name_value_pairs_1_1_value_type_mismatch.html#964ee9cba0169db7348a502b1745450c">00237</a>                 <span class="keyword">const</span> std::type_info &amp; GetRetrievingTypeInfo()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_retrieving;}<a name="l00238"></a>00238 <a name="l00239"></a>00239         <span class="keyword">private</span>:<a name="l00240"></a>00240                 <span class="keyword">const</span> std::type_info &amp;m_stored;<a name="l00241"></a>00241                 <span class="keyword">const</span> std::type_info &amp;m_retrieving;<a name="l00242"></a>00242         };<a name="l00243"></a>00243 <span class="comment"></span><a name="l00244"></a>00244 <span class="comment">        //! get a copy of this object or a subobject of it</span><a name="l00245"></a>00245 <span class="comment"></span>        <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;<a name="l00246"></a><a class="code" href="class_name_value_pairs.html#16d9f1685fbb1be3f29a22dbba911142">00246</a>         <span class="keywordtype">bool</span> GetThisObject(T &amp;<span class="keywordtype">object</span>)<span class="keyword"> const</span><a name="l00247"></a>00247 <span class="keyword">        </span>{<a name="l00248"></a>00248                 <span class="keywordflow">return</span> GetValue((std::string(<span class="stringliteral">"ThisObject:"</span>)+<span class="keyword">typeid</span>(T).name()).c_str(), <span class="keywordtype">object</span>);<a name="l00249"></a>00249         }<a name="l00250"></a>00250 <span class="comment"></span><a name="l00251"></a>00251 <span class="comment">        //! get a pointer to this object, as a pointer to T</span><a name="l00252"></a>00252 <span class="comment"></span>        <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;<a name="l00253"></a><a class="code" href="class_name_value_pairs.html#01c64a1e0a5f667898b4c1968a853c0f">00253</a>         <span class="keywordtype">bool</span> GetThisPointer(T *&amp;p)<span class="keyword"> const</span><a name="l00254"></a>00254 <span class="keyword">        </span>{<a name="l00255"></a>00255                 <span class="keywordflow">return</span> GetValue((std::string(<span class="stringliteral">"ThisPointer:"</span>)+<span class="keyword">typeid</span>(T).name()).c_str(), p);<a name="l00256"></a>00256         }<a name="l00257"></a>00257 <span class="comment"></span><a name="l00258"></a>00258 <span class="comment">        //! get a named value, returns true if the name exists</span><a name="l00259"></a>00259 <span class="comment"></span>        <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;<a name="l00260"></a><a class="code" href="class_name_value_pairs.html#96686e9f8d6ce3ab870e516fb72b608e">00260</a>         <span class="keywordtype">bool</span> GetValue(<span class="keyword">const</span> <span class="keywordtype">char</span> *name, T &amp;value)<span class="keyword"> const</span><a name="l00261"></a>00261 <span class="keyword">        </span>{

⌨️ 快捷键说明

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