Download Source Code

CPipe Class Reference

This class is used to simplify the serialization of data. More...

#include <Pipe.h>

Inheritance diagram for CPipe:

Inheritance graph
[legend]
Collaboration diagram for CPipe:

Collaboration graph
[legend]
List of all members.

Public Member Functions

BOOL Decanonicalize ()
 Decanonicalizes ( URL type decoding ) the internal buffer.
BOOL Canonicalize ()
 Canonicalizes ( URL type decoding ) the internal buffer.
BOOL Allocate (DWORD dwSize)
 Allocates the specified size array.
void Flush ()
 Flushes the internal buffers.
BOOL PumpAll ()
 Forces rx data processing.
BOOL Pump (DWORD bytes)
 Forces rx data processing of the specified number of bytes.
virtual DWORD GetWritePtr ()
 Returns the current write pointer location.
virtual DWORD GetReadPtr ()
 Returns the current read pointer location.
virtual void SetWritePtr (DWORD p)
 Sets the current write pointer location.
virtual void SetReadPtr (DWORD p)
 Sets the current read pointer location.
virtual DWORD GetMaxWrite ()
 Returns the maximum size buffer that can be written to the pipe.
virtual DWORD GetMaxRead ()
 Returns the maximum number of bytes that can be read from the pipe.
BOOL EnableBuffer (BOOL enable)
 Enable / disable data buffering.
BOOL EnableBlocking (BOOL enable)
 Enable / disable blocking operations.
BOOL WaitRead (DWORD timeout=3000)
 Waits for a pending read operation to complete.
BOOL WaitWrite (DWORD timeout=3000)
 Waits for a pending write operation to complete.
virtual BOOL OnWriteComplete (LPVOID buf, DWORD size, LPDWORD written)
 Called when a write operation completes.
virtual BOOL OnReadComplete (LPVOID buf, DWORD size, LPDWORD read)
 Called when a read operation completes.
virtual BOOL ProcessWrite (LPVOID buf, DWORD size, LPDWORD written)
 Called to process a write operation.
virtual BOOL ProcessRead (LPVOID buf, DWORD size, LPDWORD read)
 Called to process a read operation.
virtual BOOL OnWrite (LPVOID buf, DWORD size, LPDWORD written)
 Called before a write operation is started.
virtual BOOL OnRead (LPVOID buf, DWORD size, LPDWORD read)
 Called before a read operation is started.
virtual BOOL Write (LPVOID buf, DWORD size=0, LPDWORD written=NULL)
 Called to initiate a write operation.
virtual BOOL Read (LPVOID buf, DWORD size, LPDWORD read=NULL)
 Called to initiate a read operation.
virtual BOOL InitThread (LPVOID pData)
 Thread initialization.
virtual BOOL DoThread (LPVOID pData)
 Thread function that processes non-blocking data transferes.
virtual BOOL EndThread (LPVOID pData)
 Thread cleanup.
BOOL Write (LPCTSTR str, LPDWORD written=NULL)
 Writes a string to the buffer.
 CPipe ()
 Default constructor.
 CPipe (LPVOID buf, DWORD size=0)
 Constructs a pipe by wrapping the specified buffer.
virtual ~CPipe ()
 Destructor.
void Init ()
 Initializes the pie for use.
BOOL IsBlocking ()
 Returns non-zero if blocking read / write mode is enabled.
BOOL IsBuffered ()
 Returns non-zero if buffered read / write mode is enabled.
DWORD GetReadCount ()
 Returns the number of bytes read from the pipe.
DWORD GetWriteCount ()
 Returns the number of bytes written to the pipe.
void SetReadCount (DWORD c)
 Sets the number of bytes read from the pipe.
void SetWriteCount (DWORD c)
 Sets the number of bytes written to the pipe.
void Attach (CPipe *next)
 Attaches this pipe to another.
void Detach ()
 Detaches from attached pipe.
void SetBuffer (LPVOID buf, DWORD size)
 Wraps the specified buffer.
LPVOID GetReadBuffer ()
 Returns a pointer to the read buffer.
DWORD GetReadBufferSize ()
 Returns the size of the read buffer.
LPVOID GetWriteBuffer ()
 Returns a pointer to the write buffer.
DWORD GetWriteBufferSize ()
 Returns a pointer to the write buffer.
LPVOID GetBuffer ()
 Returns a pointer to the buffered io buffer.
DWORD GetBufferSize ()
 Returns the size of the buffered io buffer.

Detailed Description

This class is used to simplify the serialization of data.

This class is used to simplify the serialization of data.


Constructor & Destructor Documentation

CPipe::CPipe LPVOID  buf,
DWORD  size = 0
 

Constructs a pipe by wrapping the specified buffer.

Parameters:
[in] buf - Buffer
[in] size - Size of buffer in buf


Member Function Documentation

BOOL CPipe::Allocate DWORD  dwSize  ) 
 

Allocates the specified size array.

Parameters:
[in] dwSize - Buffer size
Returns:
Non-zero if success
See also:

void CPipe::Attach CPipe next  )  [inline]
 

Attaches this pipe to another.

Parameters:
[in] next - Pointer to next pipe

BOOL CPipe::Canonicalize  ) 
 

Canonicalizes ( URL type decoding ) the internal buffer.

Returns:
Non-zero if success
See also:

BOOL CPipe::Decanonicalize  ) 
 

Decanonicalizes ( URL type decoding ) the internal buffer.

Returns:
Non-zero if success
See also:

BOOL CPipe::DoThread LPVOID  pData  )  [virtual]
 

Thread function that processes non-blocking data transferes.

Parameters:
[in] pData - Reserved
Returns:
Non-zero to continue thread
See also:

Reimplemented from CThread.

BOOL CPipe::EnableBlocking BOOL  enable  ) 
 

Enable / disable blocking operations.

Parameters:
[in] enable - Non-zero to enable blocking data transfer
If blocking is enabled, read and write operations do not return until the data transfer is complete.

Returns:
Non-zero if success
See also:

BOOL CPipe::EnableBuffer BOOL  enable  ) 
 

Enable / disable data buffering.

Parameters:
[in] enable - Non-zero to enable data buffering
Returns:
Non-zero if success
See also:

BOOL CPipe::EndThread LPVOID  pData  )  [virtual]
 

Thread cleanup.

Parameters:
[in] pData - Reserved
Returns:
Ignored
See also:

Reimplemented from CThread.

BOOL CPipe::InitThread LPVOID  pData  )  [virtual]
 

Thread initialization.

Parameters:
[in] pData - Reserved
Returns:
Non-zero to continue thread
See also:

Reimplemented from CThread.

BOOL CPipe::OnRead LPVOID  buf,
DWORD  size,
LPDWORD  read
[virtual]
 

Called before a read operation is started.

Parameters:
[in] buf - Buffer containing read data
[in] size - Size of buffer in buf
[out] read - Number of bytes read
Returns:
Non-zero if success
See also:

BOOL CPipe::OnReadComplete LPVOID  buf,
DWORD  size,
LPDWORD  read
[virtual]
 

Called when a read operation completes.

Parameters:
[in] buf - Pointer to the read buffer
[in] size - Size of buffer in buf
[in,out] read - Number of bytes read
Returns:
Non-zero if success
See also:

BOOL CPipe::OnWrite LPVOID  buf,
DWORD  size,
LPDWORD  written
[virtual]
 

Called before a write operation is started.

Parameters:
[in] buf - Buffer containing write data
[in] size - Number of bytes in buf
[out] written - Number of bytes written
Returns:
Non-zero if success
See also:

BOOL CPipe::OnWriteComplete LPVOID  buf,
DWORD  size,
LPDWORD  written
[virtual]
 

Called when a write operation completes.

Parameters:
[in] buf - Pointer to the write buffer
[in] size - Number of bytes in buf
[in,out] written - Number of bytes written
Returns:
Non-zero if success
See also:

BOOL CPipe::ProcessRead LPVOID  buf,
DWORD  size,
LPDWORD  read
[virtual]
 

Called to process a read operation.

Parameters:
[in] buf - Buffer containing read data
[in] size - Size of buffer in buf
[out] read - Number of bytes read
Returns:
Non-zero if success
See also:

Reimplemented in CPFile.

BOOL CPipe::ProcessWrite LPVOID  buf,
DWORD  size,
LPDWORD  written
[virtual]
 

Called to process a write operation.

Parameters:
[in] buf - Buffer containing write data
[in] size - Number of bytes in buf
[out] written - Number of bytes written
Returns:
Non-zero if success
See also:

Reimplemented in CPFile.

BOOL CPipe::Pump DWORD  bytes  ) 
 

Forces rx data processing of the specified number of bytes.

Parameters:
[in] bytes - Number of bytes to process
Returns:
Non-zero if success
See also:

BOOL CPipe::PumpAll  ) 
 

Forces rx data processing.

Returns:
Non-zero if success
See also:

BOOL CPipe::Read LPVOID  buf,
DWORD  size,
LPDWORD  read = NULL
[virtual]
 

Called to initiate a read operation.

Parameters:
[in] buf - Buffer containing read data
[in] size - Size of buffer in buf
[out] read - Number of bytes read
Returns:
Non-zero if success
See also:

void CPipe::SetBuffer LPVOID  buf,
DWORD  size
[inline]
 

Wraps the specified buffer.

Parameters:
[in] buf - Buffer pointer
[in] size - Size of buffer in buf

BOOL CPipe::WaitRead DWORD  timeout = 3000  )  [inline]
 

Waits for a pending read operation to complete.

Parameters:
[in] timeout - Time in milli-seconds to wait for a pending read operation to complete
Returns:
Non-zero if operation completed before the timeout

BOOL CPipe::WaitWrite DWORD  timeout = 3000  )  [inline]
 

Waits for a pending write operation to complete.

Parameters:
[in] timeout - Time in milli-seconds to wait for a pending write operation to complete
Returns:
Non-zero if operation completed before the timeout

BOOL CPipe::Write LPCTSTR  str,
LPDWORD  written = NULL
[inline]
 

Writes a string to the buffer.

Parameters:
[in] str - Buffer containing NULL terminated string
[out] written - Receives the number of bytes written
Returns:
Non-zero if success
See also:

BOOL CPipe::Write LPVOID  buf,
DWORD  size = 0,
LPDWORD  written = NULL
[virtual]
 

Called to initiate a write operation.

Parameters:
[in] buf - Buffer containing write data
[in] size - Number of bytes in buf
[out] written - Number of bytes written
Returns:
Non-zero if success
See also:


The documentation for this class was generated from the following files:
  • inc/Pipe.h
  • Pipe.cpp
Copyright Robert Umbehant
This documentation is covered by the LGPL