Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > dc51c7d3f8a5588a609f484ef81504ee > files > 83

libfastcgipp-devel-1.1-2mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>fastcgi++: fcgistream.hpp 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.6 -->
<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>
<h1>fcgistream.hpp</h1><a href="fcgistream_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="comment">/***************************************************************************</span>
<a name="l00003"></a>00003 <span class="comment">* Copyright (C) 2007 Eddie                                                 *</span>
<a name="l00004"></a>00004 <span class="comment">*                                                                          *</span>
<a name="l00005"></a>00005 <span class="comment">* This file is part of fastcgi++.                                          *</span>
<a name="l00006"></a>00006 <span class="comment">*                                                                          *</span>
<a name="l00007"></a>00007 <span class="comment">* fastcgi++ is free software: you can redistribute it and/or modify it     *</span>
<a name="l00008"></a>00008 <span class="comment">* under the terms of the GNU Lesser General Public License as  published   *</span>
<a name="l00009"></a>00009 <span class="comment">* by the Free Software Foundation, either version 3 of the License, or (at *</span>
<a name="l00010"></a>00010 <span class="comment">* your option) any later version.                                          *</span>
<a name="l00011"></a>00011 <span class="comment">*                                                                          *</span>
<a name="l00012"></a>00012 <span class="comment">* fastcgi++ is distributed in the hope that it will be useful, but WITHOUT *</span>
<a name="l00013"></a>00013 <span class="comment">* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    *</span>
<a name="l00014"></a>00014 <span class="comment">* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public     *</span>
<a name="l00015"></a>00015 <span class="comment">* License for more details.                                                *</span>
<a name="l00016"></a>00016 <span class="comment">*                                                                          *</span>
<a name="l00017"></a>00017 <span class="comment">* You should have received a copy of the GNU Lesser General Public License *</span>
<a name="l00018"></a>00018 <span class="comment">* along with fastcgi++.  If not, see &lt;http://www.gnu.org/licenses/&gt;.       *</span>
<a name="l00019"></a>00019 <span class="comment">****************************************************************************/</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;streambuf&gt;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;ostream&gt;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;cstring&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;algorithm&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;ios&gt;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;istream&gt;</span>
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;<a class="code" href="protocol_8hpp.html" title="Defines FastCGI protocol.">fastcgi++/protocol.hpp</a>&gt;</span>
<a name="l00030"></a>00030 
<a name="l00032"></a>00032 <span class="keyword">namespace </span>Fastcgipp
<a name="l00033"></a>00033 {
<a name="l00035"></a>00035 
<a name="l00042"></a>00042    <span class="keyword">template</span> &lt;<span class="keyword">class</span> <span class="keywordtype">char</span>T, <span class="keyword">class</span> traits&gt;
<a name="l00043"></a><a class="code" href="classFastcgipp_1_1Fcgistream.html">00043</a>    <span class="keyword">class </span><a class="code" href="classFastcgipp_1_1Fcgistream.html" title="Stream class for output of client data through FastCGI.">Fcgistream</a>: <span class="keyword">public</span> std::<a class="code" href="classstd_1_1basic__ostream.html">basic_ostream</a>&lt;charT, traits&gt;
<a name="l00044"></a>00044    {
<a name="l00045"></a>00045    <span class="keyword">public</span>:
<a name="l00046"></a><a class="code" href="classFastcgipp_1_1Fcgistream.html#23fa3ab4ecc0d9916d2a780b77b560b6">00046</a>       <a class="code" href="classFastcgipp_1_1Fcgistream.html#23fa3ab4ecc0d9916d2a780b77b560b6">Fcgistream</a>(): std::<a class="code" href="classstd_1_1basic__ostream.html">basic_ostream</a>&lt;charT, traits&gt;(&amp;<a class="code" href="classFastcgipp_1_1Fcgistream.html#292be828144e7aaa73bc4df553b2ac5a" title="Stream buffer object.">buffer</a>) { }
<a name="l00048"></a><a class="code" href="classFastcgipp_1_1Fcgistream.html#2340bdcaab24edbe7f3e97332d98ccab">00048</a>       <span class="keywordtype">void</span> <span class="keyword">set</span>(<a class="code" href="structFastcgipp_1_1Protocol_1_1FullId.html" title="A full ID value for a FastCGI request.">Protocol::FullId</a> id_, <a class="code" href="classFastcgipp_1_1Transceiver.html" title="Handles low level communication with &amp;quot;the other side&amp;quot;.">Transceiver</a>&amp; transceiver_, <a class="code" href="namespaceFastcgipp_1_1Protocol.html#79e41b489a9b2c0374eee108d375b646" title="Defines the types of records within the FastCGI protocol.">Protocol::RecordType</a> type_) { <a class="code" href="classFastcgipp_1_1Fcgistream.html#292be828144e7aaa73bc4df553b2ac5a" title="Stream buffer object.">buffer</a>.<a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#53d7707752aa2f3bb10e6fe27c0b3838" title="After construction constructor.">set</a>(id_, transceiver_, type_); }
<a name="l00049"></a>00049       
<a name="l00051"></a>00051 
<a name="l00059"></a><a class="code" href="classFastcgipp_1_1Fcgistream.html#ccf72ff881e5ef268aaabddae4ffd686">00059</a>       <span class="keywordtype">void</span> <a class="code" href="classFastcgipp_1_1Fcgistream.html#ccf72ff881e5ef268aaabddae4ffd686" title="Dumps raw data directly into the FastCGI protocol.">dump</a>(<span class="keywordtype">char</span>* data, <span class="keywordtype">size_t</span> size) { <a class="code" href="classFastcgipp_1_1Fcgistream.html#292be828144e7aaa73bc4df553b2ac5a" title="Stream buffer object.">buffer</a>.<a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#85e38d044b4309b1a9f50b8dc615f9b0" title="Dumps raw data directly into the FastCGI protocol.">dump</a>(data, size); }
<a name="l00061"></a>00061 
<a name="l00068"></a>00068       <span class="keywordtype">void</span> <a class="code" href="classFastcgipp_1_1Fcgistream.html#ccf72ff881e5ef268aaabddae4ffd686" title="Dumps raw data directly into the FastCGI protocol.">dump</a>(std::basic_istream&lt;char&gt;&amp; stream);
<a name="l00069"></a>00069    <span class="keyword">private</span>:
<a name="l00071"></a>00071 
<a name="l00078"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html">00078</a>       <span class="keyword">class </span><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html" title="Stream buffer class for output of client data through FastCGI.">Fcgibuf</a>: <span class="keyword">public</span> std::basic_streambuf&lt;charT, traits&gt;
<a name="l00079"></a>00079       {
<a name="l00080"></a>00080       <span class="keyword">public</span>:
<a name="l00081"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#45ed431eb16ea93f365b4dc8cad68a9b">00081</a>          <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#45ed431eb16ea93f365b4dc8cad68a9b">Fcgibuf</a>(): <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#d9e6a16339efd32c5f0fe4cf9af457de" title="Size of the data pointed to be dumpPtr.">dumpSize</a>(0), <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#20dbdcb02e25cc4ca637495f0561da88" title="Pointer to the data that needs to be transmitted upon flush.">dumpPtr</a>(0) { setp(<a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#0a8d1d8267a9c865fe8cf23884118e31" title="The buffer.">buffer</a>, <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#0a8d1d8267a9c865fe8cf23884118e31" title="The buffer.">buffer</a>+<a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#58f7246ab5e1cdf6ba7ab8f9a7ebb6dd" title="Size of the internal stream buffer.">buffSize</a>); }
<a name="l00083"></a>00083 
<a name="l00091"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#53d7707752aa2f3bb10e6fe27c0b3838">00091</a>          <span class="keywordtype">void</span> <span class="keyword">set</span>(<a class="code" href="structFastcgipp_1_1Protocol_1_1FullId.html" title="A full ID value for a FastCGI request.">Protocol::FullId</a> id_, <a class="code" href="classFastcgipp_1_1Transceiver.html" title="Handles low level communication with &amp;quot;the other side&amp;quot;.">Transceiver</a>&amp; transceiver_, <a class="code" href="namespaceFastcgipp_1_1Protocol.html#79e41b489a9b2c0374eee108d375b646" title="Defines the types of records within the FastCGI protocol.">Protocol::RecordType</a> type_)
<a name="l00092"></a>00092          {
<a name="l00093"></a>00093             <span class="keywordtype">id</span>=id_;
<a name="l00094"></a>00094             <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#c5ca1c078264b53f4db118beaa3c2f1b" title="Transceiver object to use for transmissio.">transceiver</a>=&amp;transceiver_;
<a name="l00095"></a>00095             <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#08f9b6388619be2d6fc75c06b4162e68" title="Type of output stream (ERR or OUT).">type</a>=type_;
<a name="l00096"></a>00096          }
<a name="l00097"></a>00097 
<a name="l00098"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#7547f7cd3eeff666d9e497f91e1aa4a7">00098</a>          <span class="keyword">virtual</span> <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#7547f7cd3eeff666d9e497f91e1aa4a7">~Fcgibuf</a>() { <span class="keywordflow">try</span>{ <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#f91ac7b97e92dd74bb96ec9630b45147">sync</a>(); } <span class="keywordflow">catch</span>(...){ } }
<a name="l00100"></a>00100 
<a name="l00108"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#85e38d044b4309b1a9f50b8dc615f9b0">00108</a>          <span class="keywordtype">void</span> <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#85e38d044b4309b1a9f50b8dc615f9b0" title="Dumps raw data directly into the FastCGI protocol.">dump</a>(<span class="keywordtype">char</span>* data, <span class="keywordtype">size_t</span> size) { <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#20dbdcb02e25cc4ca637495f0561da88" title="Pointer to the data that needs to be transmitted upon flush.">dumpPtr</a>=data; <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#d9e6a16339efd32c5f0fe4cf9af457de" title="Size of the data pointed to be dumpPtr.">dumpSize</a>=size; <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#f91ac7b97e92dd74bb96ec9630b45147">sync</a>(); }
<a name="l00109"></a>00109 
<a name="l00110"></a>00110       <span class="keyword">private</span>:
<a name="l00111"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#95a06e3f4220b2e7940f137ea5c0eb37">00111</a>          <span class="keyword">typedef</span> <span class="keyword">typename</span> std::basic_streambuf&lt;charT, traits&gt;::int_type <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#95a06e3f4220b2e7940f137ea5c0eb37">int_type</a>;
<a name="l00112"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#303011dcdaa44a311d71276038fdd177">00112</a>          <span class="keyword">typedef</span> <span class="keyword">typename</span> std::basic_streambuf&lt;charT, traits&gt;::traits_type <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#303011dcdaa44a311d71276038fdd177">traits_type</a>;
<a name="l00113"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#2b8cb2c3e2c85525e5e5aa3cd1f70e98">00113</a>          <span class="keyword">typedef</span> <span class="keyword">typename</span> std::basic_streambuf&lt;charT, traits&gt;::char_type <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#2b8cb2c3e2c85525e5e5aa3cd1f70e98">char_type</a>;
<a name="l00114"></a>00114 
<a name="l00115"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#c635e28572f14173bf3149532bd81741">00115</a>          <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#95a06e3f4220b2e7940f137ea5c0eb37">int_type</a> <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#c635e28572f14173bf3149532bd81741">overflow</a>(<a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#95a06e3f4220b2e7940f137ea5c0eb37">int_type</a> c = traits_type::eof())
<a name="l00116"></a>00116          {
<a name="l00117"></a>00117             <span class="keywordflow">if</span>(<a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#7323979677487f217c4ca0f6f2f02706" title="Code converts, packages and transmits all data in the stream buffer along with the...">emptyBuffer</a>() &lt; 0)
<a name="l00118"></a>00118                <span class="keywordflow">return</span> traits_type::eof();
<a name="l00119"></a>00119             <span class="keywordflow">if</span>(!traits_type::eq_int_type(c, traits_type::eof()))
<a name="l00120"></a>00120                <span class="keywordflow">return</span> sputc(c);
<a name="l00121"></a>00121             <span class="keywordflow">else</span>
<a name="l00122"></a>00122                <span class="keywordflow">return</span> traits_type::not_eof(c);
<a name="l00123"></a>00123          }
<a name="l00124"></a>00124 
<a name="l00125"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#f91ac7b97e92dd74bb96ec9630b45147">00125</a>          <span class="keywordtype">int</span> <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#f91ac7b97e92dd74bb96ec9630b45147">sync</a>() { <span class="keywordflow">return</span> <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#7323979677487f217c4ca0f6f2f02706" title="Code converts, packages and transmits all data in the stream buffer along with the...">emptyBuffer</a>(); }
<a name="l00126"></a>00126 
<a name="l00127"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#09a2adf6740017df498532aa893afa28">00127</a>          std::streamsize <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#09a2adf6740017df498532aa893afa28">xsputn</a>(<span class="keyword">const</span> <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#2b8cb2c3e2c85525e5e5aa3cd1f70e98">char_type</a> *s, std::streamsize n)
<a name="l00128"></a>00128          {
<a name="l00129"></a>00129             std::streamsize actual=std::min(n, this-&gt;epptr()-this-&gt;pptr());
<a name="l00130"></a>00130             std::memcpy(this-&gt;pptr(), s, actual*<span class="keyword">sizeof</span>(<a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#2b8cb2c3e2c85525e5e5aa3cd1f70e98">char_type</a>));
<a name="l00131"></a>00131             this-&gt;pbump(actual);
<a name="l00132"></a>00132             <span class="keywordflow">return</span> actual;
<a name="l00133"></a>00133          }
<a name="l00134"></a>00134 
<a name="l00136"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#20dbdcb02e25cc4ca637495f0561da88">00136</a>          <span class="keywordtype">char</span>* <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#20dbdcb02e25cc4ca637495f0561da88" title="Pointer to the data that needs to be transmitted upon flush.">dumpPtr</a>;
<a name="l00138"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#d9e6a16339efd32c5f0fe4cf9af457de">00138</a>          <span class="keywordtype">size_t</span> <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#d9e6a16339efd32c5f0fe4cf9af457de" title="Size of the data pointed to be dumpPtr.">dumpSize</a>;
<a name="l00139"></a>00139 
<a name="l00141"></a>00141          <span class="keywordtype">int</span> <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#7323979677487f217c4ca0f6f2f02706" title="Code converts, packages and transmits all data in the stream buffer along with the...">emptyBuffer</a>();
<a name="l00143"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#c5ca1c078264b53f4db118beaa3c2f1b">00143</a>          <a class="code" href="classFastcgipp_1_1Transceiver.html" title="Handles low level communication with &amp;quot;the other side&amp;quot;.">Transceiver</a>* <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#c5ca1c078264b53f4db118beaa3c2f1b" title="Transceiver object to use for transmissio.">transceiver</a>;
<a name="l00145"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#58f7246ab5e1cdf6ba7ab8f9a7ebb6dd">00145</a>          <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#58f7246ab5e1cdf6ba7ab8f9a7ebb6dd" title="Size of the internal stream buffer.">buffSize</a> = 8192;
<a name="l00147"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#0a8d1d8267a9c865fe8cf23884118e31">00147</a>          <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#2b8cb2c3e2c85525e5e5aa3cd1f70e98">char_type</a> <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#0a8d1d8267a9c865fe8cf23884118e31" title="The buffer.">buffer</a>[<a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#58f7246ab5e1cdf6ba7ab8f9a7ebb6dd" title="Size of the internal stream buffer.">buffSize</a>];
<a name="l00149"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#e4c2486542f2c007d5efbbf33fb6e69e">00149</a>          <a class="code" href="structFastcgipp_1_1Protocol_1_1FullId.html" title="A full ID value for a FastCGI request.">Protocol::FullId</a> <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#e4c2486542f2c007d5efbbf33fb6e69e" title="Complete ID associated with the request.">id</a>;
<a name="l00150"></a>00150 
<a name="l00152"></a><a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#08f9b6388619be2d6fc75c06b4162e68">00152</a>          <a class="code" href="namespaceFastcgipp_1_1Protocol.html#79e41b489a9b2c0374eee108d375b646" title="Defines the types of records within the FastCGI protocol.">Protocol::RecordType</a> <a class="code" href="classFastcgipp_1_1Fcgistream_1_1Fcgibuf.html#08f9b6388619be2d6fc75c06b4162e68" title="Type of output stream (ERR or OUT).">type</a>;
<a name="l00153"></a>00153       };
<a name="l00155"></a><a class="code" href="classFastcgipp_1_1Fcgistream.html#292be828144e7aaa73bc4df553b2ac5a">00155</a>       Fcgibuf <a class="code" href="classFastcgipp_1_1Fcgistream.html#292be828144e7aaa73bc4df553b2ac5a" title="Stream buffer object.">buffer</a>;
<a name="l00156"></a>00156    };
<a name="l00157"></a>00157 }
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 16 15:17:46 2008 for fastcgi++ by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>