Sophie

Sophie

distrib > Mageia > 1 > i586 > by-pkgid > 64656f00434e190abe8506174ca339ed > files > 653

ucommon-doc-4.3.1-1.mga1.i586.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>ucommon: ucommon/buffer.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.3 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">ucommon</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00179.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<h1>ucommon/buffer.h</h1>  </div>
</div>
<div class="contents">
<a href="a00179.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.</span>
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// This file is part of GNU uCommon C++.</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">// GNU uCommon C++ is free software: you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment">// it under the terms of the GNU Lesser General Public License as published</span>
<a name="l00007"></a>00007 <span class="comment">// by the Free Software Foundation, either version 3 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">// (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// GNU uCommon C++ is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00013"></a>00013 <span class="comment">// GNU Lesser General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// You should have received a copy of the GNU Lesser General Public License</span>
<a name="l00016"></a>00016 <span class="comment">// along with GNU uCommon C++.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<a name="l00017"></a>00017 
<a name="l00023"></a>00023 <span class="preprocessor">#ifndef _UCOMMON_BUFFER_H_</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#define _UCOMMON_BUFFER_H_</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span>
<a name="l00026"></a>00026 <span class="preprocessor">#ifndef _UCOMMON_CONFIG_H_</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#include &lt;ucommon/platform.h&gt;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#endif</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span>
<a name="l00030"></a>00030 <span class="preprocessor">#ifndef _UCOMMON_PROTOCOLS_H_</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span><span class="preprocessor">#include &lt;ucommon/protocols.h&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#endif</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span>
<a name="l00034"></a>00034 <span class="preprocessor">#ifndef _UCOMMON_SOCKET_H_</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span><span class="preprocessor">#include &lt;ucommon/socket.h&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#endif</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span>
<a name="l00038"></a>00038 <span class="preprocessor">#ifndef _UCOMMON_STRING_H_</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span><span class="preprocessor">#include &lt;ucommon/string.h&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#endif</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span>
<a name="l00042"></a>00042 <span class="preprocessor">#ifndef _UCOMMON_FSYS_H_</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#include &lt;ucommon/fsys.h&gt;</span>
<a name="l00044"></a>00044 <span class="preprocessor">#endif</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span>
<a name="l00046"></a>00046 NAMESPACE_UCOMMON
<a name="l00047"></a>00047 
<a name="l00054"></a><a class="code" href="a00048.html">00054</a> <span class="keyword">class </span><a class="code" href="a00048.html" title="A generic file streaming class built from the buffer protocol.">fbuf</a> : <span class="keyword">public</span> <a class="code" href="a00026.html" title="Common buffer protocol class.">BufferProtocol</a>, <span class="keyword">private</span> <a class="code" href="a00050.html" title="A container for generic and o/s portable threadsafe file system functions.">fsys</a>
<a name="l00055"></a>00055 {
<a name="l00056"></a>00056 <span class="keyword">private</span>:
<a name="l00057"></a>00057     <a class="code" href="a00050.html#ae9c080c13d2d885db8f11383c191512d" title="File offset type.">offset_t</a>    inpos, outpos;
<a name="l00058"></a>00058 
<a name="l00059"></a>00059 <span class="keyword">protected</span>:
<a name="l00060"></a>00060     <span class="keywordtype">size_t</span> <a class="code" href="a00048.html#a3cd24d9399a7d3d30ebc7520034fe172" title="Method to push buffer into physical i/o (write).">_push</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00061"></a>00061     <span class="keywordtype">size_t</span> <a class="code" href="a00048.html#a9af22dbe0b543ec8140632d793e77f5b" title="Method to pull buffer from physical i/o (read).">_pull</a>(<span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00062"></a>00062     <span class="keywordtype">int</span> <a class="code" href="a00048.html#a3a42bf2be8e2a425ba249301bd4c2d7c" title="Method to get low level i/o error.">_err</a>(<span class="keywordtype">void</span>) <span class="keyword">const</span>;
<a name="l00063"></a>00063     <span class="keywordtype">void</span> <a class="code" href="a00048.html#af2b14628f612f5ce95ac1852df081eb7" title="Method to clear low level i/o error.">_clear</a>(<span class="keywordtype">void</span>);
<a name="l00064"></a>00064 
<a name="l00065"></a>00065     <span class="keyword">inline</span> fd_t getfile(<span class="keywordtype">void</span>)
<a name="l00066"></a>00066         {<span class="keywordflow">return</span> fd;};
<a name="l00067"></a>00067 
<a name="l00068"></a>00068 <span class="keyword">public</span>:
<a name="l00072"></a>00072     <a class="code" href="a00048.html#a789a3f45cf2b43e56a10b6dd1af85708" title="Construct an unopened file buffer.">fbuf</a>();
<a name="l00073"></a>00073 
<a name="l00077"></a>00077     <a class="code" href="a00048.html#a3ad25a8cca66faa8c1cc921910f5ff22" title="Destroy object and release all resources.">~fbuf</a>();
<a name="l00078"></a>00078 
<a name="l00086"></a>00086     <a class="code" href="a00048.html#a789a3f45cf2b43e56a10b6dd1af85708" title="Construct an unopened file buffer.">fbuf</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <a class="code" href="a00050.html#a8e5c4bcc76ebe5c9b10f79f1999b0a75" title="Enumerated file access modes.">fsys::access_t</a> <a class="code" href="a00050.html#ab6aa1e5ab53f9129934111a52727e4c8" title="Test path access.">access</a>, <span class="keywordtype">unsigned</span> permissions, <span class="keywordtype">size_t</span> size);
<a name="l00087"></a>00087 
<a name="l00094"></a>00094     <a class="code" href="a00048.html#a789a3f45cf2b43e56a10b6dd1af85708" title="Construct an unopened file buffer.">fbuf</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <a class="code" href="a00050.html#a8e5c4bcc76ebe5c9b10f79f1999b0a75" title="Enumerated file access modes.">fsys::access_t</a> access, <span class="keywordtype">size_t</span> size);
<a name="l00095"></a>00095 
<a name="l00104"></a>00104     <span class="keywordtype">void</span> <a class="code" href="a00048.html#adfa8e7306ad34a8a66d98623875d1763" title="Create and open the specified file.">create</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <a class="code" href="a00050.html#a8e5c4bcc76ebe5c9b10f79f1999b0a75" title="Enumerated file access modes.">fsys::access_t</a> access = fsys::ACCESS_APPEND, <span class="keywordtype">unsigned</span> permissions = 0640, <span class="keywordtype">size_t</span> size = 512);
<a name="l00105"></a>00105 
<a name="l00112"></a>00112     <span class="keywordtype">void</span> <a class="code" href="a00048.html#a7f8ef294e37922565d8805f239d673c7" title="Construct a file buffer that opens an existing file.">open</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <a class="code" href="a00050.html#a8e5c4bcc76ebe5c9b10f79f1999b0a75" title="Enumerated file access modes.">fsys::access_t</a> access = fsys::ACCESS_RDWR, <span class="keywordtype">size_t</span> size = 512);
<a name="l00113"></a>00113 
<a name="l00117"></a>00117     <span class="keywordtype">void</span> <a class="code" href="a00048.html#ad6960026ec86779f584200d23588de09" title="Close the file, flush buffers.">close</a>(<span class="keywordtype">void</span>);
<a name="l00118"></a>00118 
<a name="l00126"></a>00126     <span class="keywordtype">bool</span> <a class="code" href="a00048.html#aca37c1f6e6ac835ee8999525184161e4" title="Seek specific offset in open file and reset I/O buffers.">seek</a>(<a class="code" href="a00050.html#ae9c080c13d2d885db8f11383c191512d" title="File offset type.">offset_t</a> offset);
<a name="l00127"></a>00127 
<a name="l00134"></a>00134     <span class="keywordtype">bool</span> <a class="code" href="a00048.html#a9b9499790440dd0bcf00e1657dde5dda" title="Truncate the currently open file to a specific position.">trunc</a>(<a class="code" href="a00050.html#ae9c080c13d2d885db8f11383c191512d" title="File offset type.">offset_t</a> offset);
<a name="l00135"></a>00135 
<a name="l00142"></a>00142     <a class="code" href="a00050.html#ae9c080c13d2d885db8f11383c191512d" title="File offset type.">offset_t</a> <a class="code" href="a00048.html#a679bba092eda500971bad071de5cd118" title="Give the current position in the currently open file.">tell</a>(<span class="keywordtype">void</span>);
<a name="l00143"></a>00143 };
<a name="l00144"></a>00144 
<a name="l00151"></a><a class="code" href="a00153.html">00151</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00153.html" title="A generic tcp socket class that offers i/o buffering.">TCPBuffer</a> : <span class="keyword">public</span> <a class="code" href="a00026.html" title="Common buffer protocol class.">BufferProtocol</a>, <span class="keyword">protected</span> <a class="code" href="a00142.html" title="A generic socket base class.">Socket</a>
<a name="l00152"></a>00152 {
<a name="l00153"></a>00153 <span class="keyword">protected</span>:
<a name="l00154"></a>00154     <span class="keywordtype">void</span> _buffer(<span class="keywordtype">size_t</span> size);
<a name="l00155"></a>00155 
<a name="l00156"></a>00156     <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> <a class="code" href="a00026.html#a1eab001b291a96fe9ef6e018becad29c" title="Method to push buffer into physical i/o (write).">_push</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="a00143.html" title="A generic socket address class.">address</a>, <span class="keywordtype">size_t</span> size);
<a name="l00157"></a>00157     <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> <a class="code" href="a00026.html#ad2c4021277a1302c3e622a168da7a040" title="Method to pull buffer from physical i/o (read).">_pull</a>(<span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00158"></a>00158     <span class="keywordtype">int</span> <a class="code" href="a00026.html#adb9d25e9827e64994be51a3764d220cb" title="Method to get low level i/o error.">_err</a>(<span class="keywordtype">void</span>) <span class="keyword">const</span>;
<a name="l00159"></a>00159     <span class="keywordtype">void</span> <a class="code" href="a00026.html#a942cd46d66c24f57db7bee310766b1f0" title="Method to clear low level i/o error.">_clear</a>(<span class="keywordtype">void</span>);
<a name="l00160"></a>00160     <span class="keywordtype">bool</span> <a class="code" href="a00026.html#ab342f1c577bd6b06bd90d90c22870d0c" title="Return true if blocking.">_blocking</a>(<span class="keywordtype">void</span>);
<a name="l00161"></a>00161 
<a name="l00166"></a><a class="code" href="a00153.html#a5f753fb25ef6eb9f3a232d82982ce9a2">00166</a>     <span class="keyword">inline</span> socket_t getsocket(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00167"></a>00167 <span class="keyword">        </span>{<span class="keywordflow">return</span> so;};
<a name="l00168"></a>00168 
<a name="l00169"></a>00169 <span class="keyword">public</span>:
<a name="l00173"></a>00173     <a class="code" href="a00153.html" title="A generic tcp socket class that offers i/o buffering.">TCPBuffer</a>();
<a name="l00174"></a>00174 
<a name="l00180"></a>00180     <a class="code" href="a00153.html" title="A generic tcp socket class that offers i/o buffering.">TCPBuffer</a>(<span class="keyword">const</span> <a class="code" href="a00154.html" title="A generic tcp server class.">TCPServer</a> *server, <span class="keywordtype">size_t</span> size = 536);
<a name="l00181"></a>00181 
<a name="l00188"></a>00188     <a class="code" href="a00153.html" title="A generic tcp socket class that offers i/o buffering.">TCPBuffer</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *host, <span class="keyword">const</span> <span class="keywordtype">char</span> *service, <span class="keywordtype">size_t</span> size = 536);
<a name="l00189"></a>00189 
<a name="l00193"></a>00193     <span class="keyword">virtual</span> ~<a class="code" href="a00153.html" title="A generic tcp socket class that offers i/o buffering.">TCPBuffer</a>();
<a name="l00194"></a>00194 
<a name="l00201"></a>00201     <span class="keywordtype">void</span> open(<span class="keyword">const</span> <a class="code" href="a00154.html" title="A generic tcp server class.">TCPServer</a> *server, <span class="keywordtype">size_t</span> size = 536);
<a name="l00202"></a>00202 
<a name="l00210"></a>00210     <span class="keywordtype">void</span> open(<span class="keyword">const</span> <span class="keywordtype">char</span> *host, <span class="keyword">const</span> <span class="keywordtype">char</span> *service, <span class="keywordtype">size_t</span> size = 536);
<a name="l00211"></a>00211 
<a name="l00215"></a>00215     <span class="keywordtype">void</span> close(<span class="keywordtype">void</span>);
<a name="l00216"></a>00216 
<a name="l00217"></a>00217 <span class="keyword">protected</span>:
<a name="l00222"></a>00222     <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="a00026.html#a8d2bcc8a640ceaa8adc06ff4201b4bf7" title="Check if data is pending.">_pending</a>(<span class="keywordtype">void</span>);
<a name="l00223"></a>00223 };
<a name="l00224"></a>00224 
<a name="l00228"></a><a class="code" href="a00179.html#a8b3ef14e0f50b9bc6ba614f133e2f281">00228</a> <span class="keyword">typedef</span> <a class="code" href="a00048.html" title="A generic file streaming class built from the buffer protocol.">fbuf</a> <a class="code" href="a00179.html#a8b3ef14e0f50b9bc6ba614f133e2f281" title="Convenience type for buffered file operations.">file_t</a>;
<a name="l00229"></a>00229 
<a name="l00233"></a><a class="code" href="a00179.html#a8ce5b5357c929a6b1ccb0b6f1d0bed7a">00233</a> <span class="keyword">typedef</span> <a class="code" href="a00153.html" title="A generic tcp socket class that offers i/o buffering.">TCPBuffer</a> <a class="code" href="a00179.html#a8ce5b5357c929a6b1ccb0b6f1d0bed7a" title="Convenience type for pure tcp sockets.">tcp_t</a>;
<a name="l00234"></a>00234 
<a name="l00235"></a>00235 END_NAMESPACE
<a name="l00236"></a>00236 
<a name="l00237"></a>00237 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00179.html">buffer.h</a>      </li>
      <li class="footer">Generated on Wed Apr 13 2011 22:39:47 for ucommon by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li>
    </ul>
  </div>

</body>
</html>