📄 pstreams.h.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--Syntax highlighting generated by Web C Plus Plus software v0.8.2Webcpp Copyright (C)2001, (C)2002, (C)2003 Jeffrey Bakker under the GNU GPLGet webcpp at http://webcpp.sf.net--><html><head><title>pstreams.h</title><style type="text/css">/*Webcpp v0.8.1 compatible StyleSheethttp://webcpp.sf.netTheme: ide-msvcpp*/body{background-color: #ffffff}.webcpp a:link {color:#000000}.webcpp a:visited {color:#008000}.webcpp a:active {color:#0000ff}.webcpp a:hover {color:#0000ff}.webcpp pre{color: #000000}.webcpp font{font-size:100%}.webcpp .symbols{color: #000000}.webcpp .preproc{color: #0000ff}.webcpp .integer{color: #000000}.webcpp .floatpt{color: #000000}.webcpp .dblquot{color: #000000}.webcpp .sinquot{color: #000000}.webcpp .keyword{color: #0000ff;}.webcpp .keytype{color: #0000ff;}.webcpp .comment{color: #008000;}</style></head><body bgcolor="#FFFFFF" leftmargin="40" marginwidth="40"> <p><a href="../htsrc.html">Index</a><hr noshade></p><div class="webcpp"><pre><font CLASS=preproc>#ifndef</font> __PSTREAMS_H__ <font CLASS=preproc>#define</font> __PSTREAMS_H__ <font CLASS=preproc>#ifndef</font> __PPORT_H__ <font CLASS=preproc>#include</font> <font CLASS=dblquot>"pport.h"</font> <font CLASS=preproc>#endif</font> <font CLASS=preproc>#ifndef</font> __PTYPES_H__ <font CLASS=preproc>#include</font> <font CLASS=dblquot>"ptypes.h"</font> <font CLASS=preproc>#endif</font> <font CLASS=preproc>#ifndef</font> PTYPES_ST <font CLASS=preproc>#</font> ifndef __PASYNC_H__ <font CLASS=preproc>#</font> include <font CLASS=dblquot>"pasync.h"</font> <font CLASS=comment>// for logfile.lock </font><font CLASS=preproc>#</font> endif <font CLASS=preproc>#endif</font> <font CLASS=preproc>#include</font> <stdarg.h> <font CLASS=preproc>#include</font> <errno.h> <font CLASS=preproc>#ifdef</font> WIN32 <font CLASS=preproc>#</font> define _WINSOCKAPI_ <font CLASS=comment>// prevent inclusion of winsock.h, because we need winsock2.h </font><font CLASS=preproc>#</font> include <font CLASS=dblquot>"windows.h"</font> <font CLASS=comment>// for OVERLAPPED </font><font CLASS=preproc>#endif</font> PTYPES_BEGIN<font CLASS=preproc>#ifdef</font> _MSC_VER <font CLASS=preproc>#pragma</font> pack(push, <font CLASS=integer>4</font>) <font CLASS=preproc>#endif</font> <font CLASS=comment>// -------------------------------------------------------------------- //</font><font CLASS=comment>// --- abstract stream i/o classes ----------------------------------- //</font><font CLASS=comment>// -------------------------------------------------------------------- //</font><font CLASS=comment>//</font><font CLASS=comment>// stream exception class</font><font CLASS=comment>//</font><font CLASS=keyword>class</font> iobase;<font CLASS=keyword>class</font> estream: public exception {<font CLASS=preproc><font CLASS=keyword>protected</font>:</font> <font CLASS=keytype>int</font> code; iobase* errstm;<font CLASS=preproc><font CLASS=keyword>public</font>:</font> estream(iobase* ierrstm, <font CLASS=keytype>int</font> icode, <font CLASS=keyword>const</font> <font CLASS=keytype>char</font>* imsg); estream(iobase* ierrstm, <font CLASS=keytype>int</font> icode, <font CLASS=keyword>const</font> string& imsg); <font CLASS=keyword>virtual</font> ~estream(); <font CLASS=keytype>int</font> get_code() { <font CLASS=keyword>return</font> code; } iobase* get_errstm() { <font CLASS=keyword>return</font> errstm; }};<font CLASS=keyword>typedef</font> <font CLASS=keytype>void</font> (*iostatusevent)(iobase* sender, <font CLASS=keytype>int</font> code);<font CLASS=keytype>int</font> unixerrno();<font CLASS=keyword>const</font> <font CLASS=keytype>char</font>* unixerrmsg(<font CLASS=keytype>int</font> code);<font CLASS=comment>// status codes: compatible with WinInet API</font><font CLASS=comment>// additional status codes are defined in pinet.h for ipsocket</font><font CLASS=keyword>const</font> <font CLASS=keytype>int</font> IO_CREATED <font CLASS=symbols>=</font> <font CLASS=integer>1</font>;<font CLASS=keyword>const</font> <font CLASS=keytype>int</font> IO_OPENING <font CLASS=symbols>=</font> <font CLASS=integer>5</font>;<font CLASS=keyword>const</font> <font CLASS=keytype>int</font> IO_OPENED <font CLASS=symbols>=</font> <font CLASS=integer>35</font>;<font CLASS=keyword>const</font> <font CLASS=keytype>int</font> IO_READING <font CLASS=symbols>=</font> <font CLASS=integer>37</font>;<font CLASS=keyword>const</font> <font CLASS=keytype>int</font> IO_WRITING <font CLASS=symbols>=</font> <font CLASS=integer>38</font>;<font CLASS=keyword>const</font> <font CLASS=keytype>int</font> IO_EOF <font CLASS=symbols>=</font> <font CLASS=integer>45</font>;<font CLASS=keyword>const</font> <font CLASS=keytype>int</font> IO_CLOSING <font CLASS=symbols>=</font> <font CLASS=integer>250</font>;<font CLASS=keyword>const</font> <font CLASS=keytype>int</font> IO_CLOSED <font CLASS=symbols>=</font> <font CLASS=integer>253</font>;<font CLASS=comment>//</font><font CLASS=comment>// iobase</font><font CLASS=comment>//</font><font CLASS=keyword>enum</font> ioseekmode { IO_BEGIN, IO_CURRENT, IO_END};<font CLASS=keyword>const</font> <font CLASS=keytype>int</font> invhandle <font CLASS=symbols>=</font> <font CLASS=symbols>-</font><font CLASS=integer>1</font>;<font CLASS=keyword>class</font> iobase: public component { <font CLASS=keyword>friend</font> <font CLASS=keyword>class</font> fdxoutstm;<font CLASS=preproc><font CLASS=keyword>protected</font>:</font> <font CLASS=keytype>bool</font> active; <font CLASS=comment>// active status, changed by open() and close()</font> <font CLASS=keytype>bool</font> cancelled; <font CLASS=comment>// the stream was cancelled by cancel()</font> <font CLASS=keytype>bool</font> eof; <font CLASS=comment>// end of file reached, only for input streams</font> <font CLASS=keytype>int</font> handle; <font CLASS=comment>// used in many derivative classes</font> <font CLASS=keytype>int</font> abspos; <font CLASS=comment>// physical stream position</font> <font CLASS=keytype>int</font> bufsize; <font CLASS=comment>// buffer size, can be changed only when not active</font> <font CLASS=keytype>char</font>* bufdata; <font CLASS=comment>// internal: allocated buffer data</font> <font CLASS=keytype>int</font> bufpos; <font CLASS=comment>// internal: current position</font> <font CLASS=keytype>int</font> bufend; <font CLASS=comment>// internal: current data size in the buffer</font> <font CLASS=keytype>int</font> stmerrno; <font CLASS=comment>// UNIX-compatible error numbers, see comments in piobase.cxx</font> string deferrormsg; <font CLASS=comment>// internal: default error message when an exception is thrown,</font> <font CLASS=keytype>int</font> status; <font CLASS=comment>// stream status code, see IO_xxx constants above</font> iostatusevent onstatus; <font CLASS=comment>// user-defined status change handler</font> <font CLASS=keyword>virtual</font> <font CLASS=keytype>void</font> bufalloc(); <font CLASS=keyword>virtual</font> <font CLASS=keytype>void</font> buffree(); <font CLASS=keytype>void</font> bufclear() { bufpos <font CLASS=symbols>=</font> <font CLASS=integer>0</font>; bufend <font CLASS=symbols>=</font> <font CLASS=integer>0</font>; } <font CLASS=keytype>void</font> errstminactive(); <font CLASS=keytype>void</font> errbufrequired(); <font CLASS=keytype>void</font> requireactive() { <font CLASS=keyword>if</font> (!active) errstminactive(); } <font CLASS=keytype>void</font> requirebuf() { requireactive(); <font CLASS=keyword>if</font> (bufdata <font CLASS=symbols>==</font> <font CLASS=integer>0</font>) errbufrequired(); } <font CLASS=keyword>virtual</font> <font CLASS=keytype>void</font> doopen() <font CLASS=symbols>=</font> <font CLASS=integer>0</font>; <font CLASS=keyword>virtual</font> <font CLASS=keytype>void</font> doclose(); <font CLASS=keyword>virtual</font> <font CLASS=keytype>int</font> doseek(<font CLASS=keytype>int</font> newpos, ioseekmode mode); <font CLASS=keyword>virtual</font> <font CLASS=keytype>void</font> chstat(<font CLASS=keytype>int</font> newstat); <font CLASS=keyword>virtual</font> <font CLASS=keytype>int</font> uerrno();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -