/usr/share/doc/libucommon-dev/a00206_source.html is in libucommon-doc 3.2.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | <!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/stream.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Data 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 class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<h1>ucommon/stream.h</h1><a href="a00206.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 <http://www.gnu.org/licenses/>.</span>
<a name="l00017"></a>00017
<a name="l00024"></a>00024 <span class="preprocessor">#if defined(OLD_STDCPP) || defined(NEW_STDCPP)</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor">#ifndef _UCOMMON_STREAM_H_</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#define _UCOMMON_STREAM_H_</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span>
<a name="l00028"></a>00028 <span class="preprocessor">#ifndef _UCOMMON_THREAD_H_</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00208.html" title="Thread classes and sychronization objects.">ucommon/thread.h</a>></span>
<a name="l00030"></a>00030 <span class="preprocessor">#endif</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span>
<a name="l00032"></a>00032 <span class="preprocessor">#ifndef _UCOMMON_SOCKET_H_</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00205.html" title="Common socket class and address manipulation.">ucommon/socket.h</a>></span>
<a name="l00034"></a>00034 <span class="preprocessor">#endif</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span>
<a name="l00036"></a>00036 <span class="preprocessor">#ifndef _UCOMMON_FSYS_H_</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00193.html" title="Thread-aware file system manipulation class.">ucommon/fsys.h</a>></span>
<a name="l00038"></a>00038 <span class="preprocessor">#endif</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span>
<a name="l00040"></a>00040 <span class="preprocessor">#include <iostream></span>
<a name="l00041"></a>00041
<a name="l00042"></a>00042 NAMESPACE_UCOMMON
<a name="l00043"></a>00043
<a name="l00052"></a><a class="code" href="a00163.html">00052</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00163.html" title="Streamable tcp connection between client and server.">tcpstream</a> : <span class="keyword">protected</span> std::streambuf, <span class="keyword">public</span> std::iostream
<a name="l00053"></a>00053 {
<a name="l00054"></a>00054 <span class="keyword">private</span>:
<a name="l00055"></a>00055 __LOCAL <span class="keywordtype">void</span> allocate(<span class="keywordtype">unsigned</span> size);
<a name="l00056"></a>00056 __LOCAL <span class="keywordtype">void</span> reset(<span class="keywordtype">void</span>);
<a name="l00057"></a>00057
<a name="l00058"></a>00058 <span class="keyword">protected</span>:
<a name="l00059"></a>00059 socket_t so;
<a name="l00060"></a>00060 <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout;
<a name="l00061"></a>00061 <span class="keywordtype">size_t</span> bufsize;
<a name="l00062"></a>00062 <span class="keywordtype">char</span> *gbuf, *pbuf;
<a name="l00063"></a>00063
<a name="l00067"></a>00067 <span class="keywordtype">void</span> <a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&#39;s protocol.">release</a>(<span class="keywordtype">void</span>);
<a name="l00068"></a>00068
<a name="l00075"></a>00075 <span class="keywordtype">int</span> underflow();
<a name="l00076"></a>00076
<a name="l00085"></a>00085 <span class="keywordtype">int</span> uflow();
<a name="l00086"></a>00086
<a name="l00094"></a>00094 <span class="keywordtype">int</span> overflow(<span class="keywordtype">int</span> ch);
<a name="l00095"></a>00095
<a name="l00096"></a>00096 <span class="keyword">public</span>:
<a name="l00101"></a>00101 <a class="code" href="a00163.html" title="Streamable tcp connection between client and server.">tcpstream</a>(<span class="keyword">const</span> <a class="code" href="a00163.html" title="Streamable tcp connection between client and server.">tcpstream</a>& <a class="code" href="a00214.html#a8370bd49e635d1f1c3aec9135f497cec" title="Convenence function to access object copy.">copy</a>);
<a name="l00102"></a>00102
<a name="l00109"></a>00109 <a class="code" href="a00163.html" title="Streamable tcp connection between client and server.">tcpstream</a>(<a class="code" href="a00070.html" title="A bound socket used to listen for inbound socket connections.">ListenSocket</a>& listener, <span class="keywordtype">unsigned</span> segsize = 536, <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0);
<a name="l00110"></a>00110
<a name="l00116"></a>00116 <a class="code" href="a00163.html" title="Streamable tcp connection between client and server.">tcpstream</a>(<span class="keywordtype">int</span> family = PF_INET, <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0);
<a name="l00117"></a>00117
<a name="l00126"></a>00126 <a class="code" href="a00163.html" title="Streamable tcp connection between client and server.">tcpstream</a>(<a class="code" href="a00152.html" title="A generic socket address class.">Socket::address</a>& address, <span class="keywordtype">unsigned</span> segsize = 536, <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0);
<a name="l00127"></a>00127
<a name="l00131"></a>00131 <span class="keyword">virtual</span> ~<a class="code" href="a00163.html" title="Streamable tcp connection between client and server.">tcpstream</a>();
<a name="l00132"></a>00132
<a name="l00137"></a><a class="code" href="a00163.html#a4b03c21b2ab19230e21ac0047981112d">00137</a> <span class="keyword">inline</span> operator bool()<span class="keyword"> const</span>
<a name="l00138"></a>00138 <span class="keyword"> </span>{<span class="keywordflow">return</span> so != INVALID_SOCKET && bufsize > 0;};
<a name="l00139"></a>00139
<a name="l00144"></a><a class="code" href="a00163.html#a5f2aafe32f75eb98ef2bb72092d20fc1">00144</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator!()<span class="keyword"> const</span>
<a name="l00145"></a>00145 <span class="keyword"> </span>{<span class="keywordflow">return</span> so == INVALID_SOCKET || bufsize == 0;};
<a name="l00146"></a>00146
<a name="l00152"></a>00152 <span class="keywordtype">void</span> open(<a class="code" href="a00152.html" title="A generic socket address class.">Socket::address</a>& address, <span class="keywordtype">unsigned</span> segment = 536);
<a name="l00153"></a>00153
<a name="l00158"></a>00158 <span class="keywordtype">void</span> close(<span class="keywordtype">void</span>);
<a name="l00159"></a>00159
<a name="l00164"></a>00164 <span class="keywordtype">int</span> sync(<span class="keywordtype">void</span>);
<a name="l00165"></a>00165 };
<a name="l00166"></a>00166
<a name="l00175"></a><a class="code" href="a00108.html">00175</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00108.html" title="Streamable tcp connection between client and server.">pipestream</a> : <span class="keyword">protected</span> std::streambuf, <span class="keyword">public</span> std::iostream
<a name="l00176"></a>00176 {
<a name="l00177"></a>00177 <span class="keyword">public</span>:
<a name="l00178"></a>00178 <span class="keyword">typedef</span> <span class="keyword">enum</span> {
<a name="l00179"></a>00179 RDONLY,
<a name="l00180"></a>00180 WRONLY,
<a name="l00181"></a>00181 RDWR
<a name="l00182"></a>00182 } access_t;
<a name="l00183"></a>00183
<a name="l00184"></a>00184 <span class="keyword">private</span>:
<a name="l00185"></a>00185 __LOCAL <span class="keywordtype">void</span> allocate(<span class="keywordtype">size_t</span> size, access_t mode);
<a name="l00186"></a>00186
<a name="l00187"></a>00187 <span class="keyword">protected</span>:
<a name="l00188"></a>00188 <a class="code" href="a00056.html" title="A container for generic and o/s portable threadsafe file system functions.">fsys_t</a> rd, wr;
<a name="l00189"></a>00189 pid_t pid;
<a name="l00190"></a>00190 <span class="keywordtype">size_t</span> bufsize;
<a name="l00191"></a>00191 <span class="keywordtype">char</span> *gbuf, *pbuf;
<a name="l00192"></a>00192
<a name="l00196"></a>00196 <span class="keywordtype">void</span> <a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&#39;s protocol.">release</a>(<span class="keywordtype">void</span>);
<a name="l00197"></a>00197
<a name="l00204"></a>00204 <span class="keywordtype">int</span> underflow();
<a name="l00205"></a>00205
<a name="l00214"></a>00214 <span class="keywordtype">int</span> uflow();
<a name="l00215"></a>00215
<a name="l00223"></a>00223 <span class="keywordtype">int</span> overflow(<span class="keywordtype">int</span> ch);
<a name="l00224"></a>00224
<a name="l00225"></a>00225 <span class="keyword">public</span>:
<a name="l00229"></a>00229 <a class="code" href="a00108.html" title="Streamable tcp connection between client and server.">pipestream</a>();
<a name="l00230"></a>00230
<a name="l00238"></a>00238 <a class="code" href="a00108.html" title="Streamable tcp connection between client and server.">pipestream</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *command, access_t <a class="code" href="a00214.html#ad6378c2aa4e17197d8e936674e5b2687" title="Convenience function to access (lock) shared object through it&#39;s protocol.">access</a>, <span class="keyword">const</span> <span class="keywordtype">char</span> **env = NULL, <span class="keywordtype">size_t</span> size = 512);
<a name="l00239"></a>00239
<a name="l00243"></a>00243 <span class="keyword">virtual</span> ~<a class="code" href="a00108.html" title="Streamable tcp connection between client and server.">pipestream</a>();
<a name="l00244"></a>00244
<a name="l00249"></a><a class="code" href="a00108.html#a1268849236bbee3f9130484e10b26077">00249</a> <span class="keyword">inline</span> operator bool()<span class="keyword"> const</span>
<a name="l00250"></a>00250 <span class="keyword"> </span>{<span class="keywordflow">return</span> (bufsize > 0);};
<a name="l00251"></a>00251
<a name="l00256"></a><a class="code" href="a00108.html#a12deb1a1902af1a7fa8ad396d953bdf6">00256</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator!()<span class="keyword"> const</span>
<a name="l00257"></a>00257 <span class="keyword"> </span>{<span class="keywordflow">return</span> bufsize == 0;};
<a name="l00258"></a>00258
<a name="l00266"></a>00266 <span class="keywordtype">void</span> open(<span class="keyword">const</span> <span class="keywordtype">char</span> *command, access_t access, <span class="keyword">const</span> <span class="keywordtype">char</span> **env = NULL, <span class="keywordtype">size_t</span> buffering = 512);
<a name="l00267"></a>00267
<a name="l00272"></a>00272 <span class="keywordtype">void</span> close(<span class="keywordtype">void</span>);
<a name="l00273"></a>00273
<a name="l00277"></a>00277 <span class="keywordtype">void</span> terminate(<span class="keywordtype">void</span>);
<a name="l00278"></a>00278
<a name="l00283"></a>00283 <span class="keywordtype">int</span> sync(<span class="keywordtype">void</span>);
<a name="l00284"></a>00284 };
<a name="l00285"></a>00285
<a name="l00294"></a><a class="code" href="a00055.html">00294</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00055.html" title="Streamable tcp connection between client and server.">filestream</a> : <span class="keyword">protected</span> std::streambuf, <span class="keyword">public</span> std::iostream
<a name="l00295"></a>00295 {
<a name="l00296"></a>00296 <span class="keyword">public</span>:
<a name="l00297"></a>00297 <span class="keyword">typedef</span> <span class="keyword">enum</span> {
<a name="l00298"></a>00298 RDONLY,
<a name="l00299"></a>00299 WRONLY,
<a name="l00300"></a>00300 RDWR
<a name="l00301"></a>00301 } access_t;
<a name="l00302"></a>00302
<a name="l00303"></a>00303 <span class="keyword">private</span>:
<a name="l00304"></a>00304 __LOCAL <span class="keywordtype">void</span> allocate(<span class="keywordtype">size_t</span> size, <a class="code" href="a00056.html#a5e886a4f005b2a2948d2a3fb4e9f0deb" title="Enumerated file access modes.">fsys::access_t</a> mode);
<a name="l00305"></a>00305
<a name="l00306"></a>00306 <span class="keyword">protected</span>:
<a name="l00307"></a>00307 <a class="code" href="a00056.html" title="A container for generic and o/s portable threadsafe file system functions.">fsys_t</a> fd;
<a name="l00308"></a>00308 <a class="code" href="a00056.html#a5e886a4f005b2a2948d2a3fb4e9f0deb" title="Enumerated file access modes.">fsys::access_t</a> ac;
<a name="l00309"></a>00309 <span class="keywordtype">size_t</span> bufsize;
<a name="l00310"></a>00310 <span class="keywordtype">char</span> *gbuf, *pbuf;
<a name="l00311"></a>00311
<a name="l00318"></a>00318 <span class="keywordtype">int</span> underflow();
<a name="l00319"></a>00319
<a name="l00328"></a>00328 <span class="keywordtype">int</span> uflow();
<a name="l00329"></a>00329
<a name="l00337"></a>00337 <span class="keywordtype">int</span> overflow(<span class="keywordtype">int</span> ch);
<a name="l00338"></a>00338
<a name="l00339"></a>00339 <span class="keyword">public</span>:
<a name="l00343"></a>00343 <a class="code" href="a00055.html" title="Streamable tcp connection between client and server.">filestream</a>();
<a name="l00344"></a>00344
<a name="l00348"></a>00348 <a class="code" href="a00055.html" title="Streamable tcp connection between client and server.">filestream</a>(<span class="keyword">const</span> <a class="code" href="a00055.html" title="Streamable tcp connection between client and server.">filestream</a>& <a class="code" href="a00214.html#a8370bd49e635d1f1c3aec9135f497cec" title="Convenence function to access object copy.">copy</a>);
<a name="l00349"></a>00349
<a name="l00353"></a>00353 <a class="code" href="a00055.html" title="Streamable tcp connection between client and server.">filestream</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <a class="code" href="a00056.html#a5e886a4f005b2a2948d2a3fb4e9f0deb" title="Enumerated file access modes.">fsys::access_t</a> <a class="code" href="a00214.html#ad6378c2aa4e17197d8e936674e5b2687" title="Convenience function to access (lock) shared object through it&#39;s protocol.">access</a>, <span class="keywordtype">unsigned</span> mode, <span class="keywordtype">size_t</span> bufsize);
<a name="l00354"></a>00354
<a name="l00358"></a>00358 <a class="code" href="a00055.html" title="Streamable tcp connection between client and server.">filestream</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <a class="code" href="a00056.html#a5e886a4f005b2a2948d2a3fb4e9f0deb" title="Enumerated file access modes.">fsys::access_t</a> access, <span class="keywordtype">size_t</span> bufsize);
<a name="l00359"></a>00359
<a name="l00363"></a>00363 <span class="keyword">virtual</span> ~<a class="code" href="a00055.html" title="Streamable tcp connection between client and server.">filestream</a>();
<a name="l00364"></a>00364
<a name="l00369"></a><a class="code" href="a00055.html#a1a53903e3d6a1366302a092967423ab0">00369</a> <span class="keyword">inline</span> operator bool()<span class="keyword"> const</span>
<a name="l00370"></a>00370 <span class="keyword"> </span>{<span class="keywordflow">return</span> (bufsize > 0);};
<a name="l00371"></a>00371
<a name="l00376"></a><a class="code" href="a00055.html#a94847b740ad9edbe14aea7dc88d24c72">00376</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator!()<span class="keyword"> const</span>
<a name="l00377"></a>00377 <span class="keyword"> </span>{<span class="keywordflow">return</span> bufsize == 0;};
<a name="l00378"></a>00378
<a name="l00382"></a>00382 <span class="keywordtype">void</span> open(<span class="keyword">const</span> <span class="keywordtype">char</span> *filename, <a class="code" href="a00056.html#a5e886a4f005b2a2948d2a3fb4e9f0deb" title="Enumerated file access modes.">fsys::access_t</a> access, <span class="keywordtype">size_t</span> buffering = 512);
<a name="l00383"></a>00383
<a name="l00387"></a>00387 <span class="keywordtype">void</span> create(<span class="keyword">const</span> <span class="keywordtype">char</span> *filename, <a class="code" href="a00056.html#a5e886a4f005b2a2948d2a3fb4e9f0deb" title="Enumerated file access modes.">fsys::access_t</a> access, <span class="keywordtype">unsigned</span> mode, <span class="keywordtype">size_t</span> buffering = 512);
<a name="l00388"></a>00388
<a name="l00392"></a>00392 <span class="keywordtype">void</span> close(<span class="keywordtype">void</span>);
<a name="l00393"></a>00393
<a name="l00397"></a>00397 <span class="keywordtype">void</span> seek(<a class="code" href="a00056.html#acd8d82ddbf77b2c44371f3bf19746f60" title="File offset type.">fsys::offset_t</a> offset);
<a name="l00398"></a>00398
<a name="l00403"></a>00403 <span class="keywordtype">int</span> sync(<span class="keywordtype">void</span>);
<a name="l00404"></a>00404
<a name="l00409"></a><a class="code" href="a00055.html#ad879c0dbf22fe8acf0accd8a5317e2fb">00409</a> <span class="keyword">inline</span> <span class="keywordtype">int</span> error(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00410"></a>00410 <span class="keyword"> </span>{<span class="keywordflow">return</span> fd.getError();};
<a name="l00411"></a>00411 };
<a name="l00412"></a>00412
<a name="l00413"></a>00413 END_NAMESPACE
<a name="l00414"></a>00414
<a name="l00415"></a>00415 <span class="preprocessor">#endif</span>
<a name="l00416"></a>00416 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Tue Jul 6 08:22:01 2010 for UCommon by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>
|