NCBI C++ ToolKit
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
CConn_IOStream Class Reference

Search Toolkit Book for CConn_IOStream

Base class, inherited from "std::iostream", does both input and output, using the specified CONNECTOR. More...

#include <connect/ncbi_conn_stream.hpp>

+ Inheritance diagram for CConn_IOStream:
+ Collaboration diagram for CConn_IOStream:

Classes

class  TConnector
 Helper class to build streams on top of CONNECTOR (internal use only). More...
 

Public Types

enum  { fConn_Untie = fCONN_Untie , fConn_DelayOpen = 2 , fConn_ReadUnbuffered = 4 , fConn_WriteUnbuffered = 8 }
 The values below must be compatible with TCONN_Flags. More...
 
typedef unsigned int TConn_Flags
 bitwise OR of EConn_Flag More...
 
typedef pair< CONNECTOR, EIO_StatusTConnPair
 

Public Member Functions

 CConn_IOStream (CONN conn, bool close=false, const STimeout *timeout=kDefaultTimeout, size_t buf_size=kConn_DefaultBufSize, TConn_Flags flags=0, CT_CHAR_TYPE *ptr=0, size_t size=0)
 Create a stream based on CONN, which is to be closed upon stream dtor but only if "close" parameter is passed as "true". More...
 
virtual ~CConn_IOStream ()
 
string GetType (void) const
 
string GetDescription (void) const
 
EIO_Status SetTimeout (EIO_Event direction, const STimeout *timeout) const
 Set connection timeout for "direction". More...
 
const STimeoutGetTimeout (EIO_Event direction) const
 
EIO_Status Status (EIO_Event direction=eIO_Close) const
 
EIO_Status Fetch (const STimeout *timeout=kDefaultTimeout)
 Flush the stream and fetch the response (w/o extracting any user data) More...
 
virtual EIO_Status Pushback (const CT_CHAR_TYPE *data, streamsize size)
 Push the specified data "data" of size "size" back into the underlying connection CONN (making it look like received yet unread data). More...
 
SOCK GetSOCK (void)
 Get underlying SOCK, if available (e.g. after Fetch()) More...
 
CSocketGetSocket (void)
 Get CSocket, if available (else empty). More...
 
virtual EIO_Status Close (void)
 Close CONNection, free all internal buffers and underlying structures, and render the stream unusable for further I/O. More...
 
EIO_Status SetCanceledCallback (const ICanceled *canceled)
 Cancellation support. More...
 
CONN GetCONN (void) const
 
EIO_Status Wait (EIO_Event event, const STimeout *timeout=&kZeroTimeout)
 Equivalent to CONN_Wait(GetCONN(), event, timeout) More...
 

Public Attributes

enum CConn_IOStream:: { ... }  EConn_Flag
 The values below must be compatible with TCONN_Flags. More...
 

Static Public Attributes

static const STimeout kZeroTimeout = { 0, 0 }
 Polling timeout with the 0.0 time in it. More...
 

Protected Member Functions

 CConn_IOStream (const TConnector &connector, const STimeout *timeout=kDefaultTimeout, size_t buf_size=kConn_DefaultBufSize, TConn_Flags flags=0, CT_CHAR_TYPE *ptr=0, size_t size=0)
 Create a stream based on CONNECTOR – only for internal use in derived classes. More...
 
EIO_Status x_Pushback (const CT_CHAR_TYPE *data, streamsize size, bool push=false)
 
void x_Destroy (void)
 
- Protected Member Functions inherited from CConnIniter
 CConnIniter (void)
 

Protected Attributes

CConn_Streambufm_CSb
 

Private Member Functions

 CConn_IOStream (const CConn_IOStream &)
 
CConn_IOStreamoperator= (const CConn_IOStream &)
 

Static Private Member Functions

static EIO_Status sx_IsCanceled (CONN conn, TCONN_Callback type, void *data)
 

Private Attributes

unique_ptr< CConn_Streambufx_CSb
 
CSocket m_Socket
 
SCONN_Callback m_CB [4]
 
CConstIRef< ICanceledm_Canceled
 

Detailed Description

Base class, inherited from "std::iostream", does both input and output, using the specified CONNECTOR.

The "buf_size" parameter designates the size of the internal I/O buffers, which reside in between the stream and an underlying connector (which in turn may do further buffering, if needed).

By default, all input operations are tied to the output ones, which means that any input attempt first flushes any pending output from the internal buffers. The fConn_Untie flag can be used to untie the I/O directions.

Note
CConn_IOStream implementation utilizes some connection callbacks on the underlying CONN object. Care must be taken when intercepting the callbacks using the native CONN API.
See also
CONN_SetCallback

Definition at line 133 of file ncbi_conn_stream.hpp.


The documentation for this class was generated from the following files:
Modified on Fri Sep 20 14:58:29 2024 by modify_doxy.py rev. 669887