Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

FlushBuffer Class Reference

Inheritance diagram for FlushBuffer:

Buffer List of all members.

Public Member Functions

 this (int size, IConduit conduit)

Protected Member Functions

override void * copy (void *src, uint size)

Private Member Functions

 this (uint capacity=0)
 this (void[] data)
 this (void[] data, uint readable)
IBuffer create ()
void[] getContent ()
IBuffer setValidContent (void[] data)
IBuffer setContent (void[] data, uint readable)
bool grow (uint size)
bool put (void *src, uint size)
void * put (void *src, uint size)
void[] get (uint size, bool eat=true)
IBuffer append (void[] content)
char[] toString ()
bool skip (int size)
uint readable ()
uint writable ()
int write (int(*dg)(void[]))
int read (int(*dg)(void[]))
IBuffer compress ()
void flush ()
IBuffer clear ()
uint getLimit ()
uint getCapacity ()
uint getPosition ()
IConduit getConduit ()
void setConduit (IConduit conduit)

Static Private Member Functions

 this ()

Static Private Attributes

IOException ovf

Detailed Description

Subclass to support automatic flushing. This can be used for Stdout, Stderr, and other related conduits.

Definition at line 656 of file Buffer.d.


Member Function Documentation

this int  size,
IConduit  conduit
[inline]
 

Construct a flushing buffer with the given size upon the provided IConduit

Definition at line 665 of file Buffer.d.

override void* copy void *  src,
uint  size
[inline, protected]
 

Intercept buffer writes so we can flush the new content

Reimplemented from Buffer.

Definition at line 679 of file Buffer.d.

References IConduit::flush(), and Buffer::getConduit().

this  )  [inline, static, inherited]
 

Construct an overflow exception for later use.

Reimplemented in MappedBuffer.

Definition at line 170 of file Buffer.d.

this uint  capacity = 0  )  [inline, inherited]
 

Construct a Buffer with the specified number of bytes.

Reimplemented in GrowableBuffer.

Definition at line 181 of file Buffer.d.

this void[]  data  )  [inline, inherited]
 

Prime buffer with an application-supplied array. There is no readable data present, and writing begins at position 0.

Definition at line 193 of file Buffer.d.

this void[]  data,
uint  readable
[inline, inherited]
 

Prime buffer with an application-supplied array, and indicate how much readable data is already there. A write operation will begin writing immediately after the existing content.

Definition at line 207 of file Buffer.d.

References Buffer::readable(), and Buffer::setContent().

IBuffer create  )  [inline, inherited]
 

Create an instance of an IBuffer. Use this when you don't know anything about the concrete implementation, and have only the IBuffer interface available

Returns a Buffer with no content.

Reimplemented from IBuffer.

Definition at line 222 of file Buffer.d.

void [] getContent  )  [inline, inherited]
 

Return the backing array

Reimplemented from IBuffer.

Definition at line 233 of file Buffer.d.

IBuffer setValidContent void[]  data  )  [inline, inherited]
 

Set the backing array with all content readable. Writing to this will either flush it to an associated conduit, or raise an Eof condition. Use IBuffer.clear() to reset the content (make it all writable).

Reimplemented from IBuffer.

Definition at line 247 of file Buffer.d.

References Buffer::setContent().

Referenced by StartLine::VersionUseTokenizer::parse(), ResponseLine::parse(), testLineRegex(), and FileBucket::Record::write().

IBuffer setContent void[]  data,
uint  readable
[inline, inherited]
 

Set the backing array with some content readable. Writing to this will either flush it to an associated conduit, or raise an Eof condition. Use IBuffer.clear() to reset the content (make it all writable).

Reimplemented from IBuffer.

Definition at line 261 of file Buffer.d.

Referenced by Buffer::put(), FileBucket::Record::read(), Buffer::setValidContent(), and Buffer::this().

bool grow uint  size  )  [inline, protected, inherited]
 

Overridable method to grow the buffer size when it becomes full. Default is to not grow at all.

Reimplemented from IBuffer.

Reimplemented in GrowableBuffer.

Definition at line 280 of file Buffer.d.

Referenced by Buffer::put().

bool put void *  src,
uint  size
[inline, inherited]
 

Write a chunk of data into this buffer, and flush to the conduit as necessary. Returns true if all data was written, false otherwise (indicating eof, or eob).

This is typically used for streaming formatted data. Note that this should ideally have package visibility only, as it should be restricted to Writers etc.

Reimplemented from IBuffer.

Definition at line 312 of file Buffer.d.

References Buffer::copy(), IConduit::flush(), Buffer::grow(), Buffer::setContent(), and Buffer::writable().

Referenced by Buffer::append().

void* put void *  src,
uint  size
[inline, inherited]
 

Write a chunk of data into this buffer, and flush to the conduit as necessary. Returns true if all data was written, false otherwise (indicating eof, or eob).

This is typically used for streaming formatted data. Note that this should ideally have package visibility only, as it should be restricted to Writers etc.

Reimplemented from IBuffer.

Definition at line 354 of file Buffer.d.

References Buffer::copy().

void [] get uint  size,
bool  eat = true
[inline, inherited]
 

Read a chunk of data from the buffer, loading from the conduit as necessary. The specified number of bytes is loaded into the buffer, and marked as having been read when the 'eat' parameter is set true. When 'eat' is set false, the read position is not adjusted.

Returns the corresponding buffer slice when successful, or null if there's not enough data available (Eof; Eob).

Reimplemented from IBuffer.

Definition at line 372 of file Buffer.d.

References Buffer::compress(), Buffer::position, IConduit::read(), and Buffer::readable().

Referenced by Buffer::skip().

IBuffer append void[]  content  )  [inline, inherited]
 

Write an array of data into this buffer, and flush to the conduit as necessary. Returns a chaining reference if all data was written; throws an IOException indicating eof or eob if not.

This is often used in lieu of a Writer.

Reimplemented from IBuffer.

Definition at line 407 of file Buffer.d.

References Buffer::put(), and Buffer::writable().

Referenced by testAppend(), testClient(), testMappedFile(), and FilePath::toString().

char [] toString  )  [inline, inherited]
 

Return a char[] slice of the buffer up to the limit of valid content.

Reimplemented from IBuffer.

Definition at line 423 of file Buffer.d.

References Buffer::limit, and Buffer::position.

Referenced by VirtualCache::put(), and testAppend().

bool skip int  size  )  [inline, inherited]
 

Skip ahead by the specified number of bytes, streaming from the associated conduit as necessary.

Can also reverse the read position by 'size' bytes. This may be used to support lookahead-type operations.

Returns true if successful, false otherwise.

Reimplemented from IBuffer.

Definition at line 440 of file Buffer.d.

References Buffer::get(), and Buffer::position.

uint readable  )  [inline, inherited]
 

Return count of readable bytes remaining in buffer. This is calculated simply as limit() - position()

Reimplemented from IBuffer.

Definition at line 462 of file Buffer.d.

References Buffer::limit, and Buffer::position.

Referenced by Buffer::compress(), Buffer::get(), and Buffer::this().

uint writable  )  [inline, inherited]
 

Return count of writable bytes available in buffer. This is calculated simply as capacity() - limit()

Reimplemented from IBuffer.

Reimplemented in MappedBuffer.

Definition at line 474 of file Buffer.d.

References Buffer::limit.

Referenced by Buffer::append(), and Buffer::put().

int write int(*  dg)(void[])  )  [inline, inherited]
 

Exposes the raw data buffer at the current write position, The delegate is provided with a void[] representing space available within the buffer at the current write position.

The delegate should return the approriate number of bytes if it writes valid content, or IConduit.Eof on error.

Returns whatever the delegate returns.

Reimplemented from IBuffer.

Reimplemented in MappedBuffer.

Definition at line 492 of file Buffer.d.

References Buffer::limit.

int read int(*  dg)(void[])  )  [inline, inherited]
 

Exposes the raw data buffer at the current read position. The delegate is provided with a void[] representing the available data, and should return zero to leave the current read position intact.

If the delegate consumes data, it should return the number of bytes consumed; or IConduit.Eof to indicate an error.

Returns whatever the delegate returns.

Reimplemented from IBuffer.

Definition at line 518 of file Buffer.d.

References Buffer::limit, and Buffer::position.

IBuffer compress  )  [inline, inherited]
 

If we have some data left after an export, move it to front-of-buffer and set position to be just after the remains. This is for supporting certain conduits which choose to write just the initial portion of a request.

Limit is set to the amount of data remaining. Position is always reset to zero.

Reimplemented from IBuffer.

Reimplemented in MappedBuffer.

Definition at line 542 of file Buffer.d.

References Buffer::limit, Buffer::position, and Buffer::readable().

Referenced by Buffer::get().

void flush  )  [inline, inherited]
 

flush the contents of this buffer to the related conduit. Throws an IOException on premature eof.

Reimplemented from IBuffer.

Reimplemented in MappedBuffer, and FileConduit::VersionWin32::Win32MappedBuffer.

Definition at line 562 of file Buffer.d.

References Buffer::clear(), and IConduit::flush().

IBuffer clear  )  [inline, inherited]
 

Reset 'position' and 'limit' to zero

Reimplemented from IBuffer.

Reimplemented in MappedBuffer.

Definition at line 576 of file Buffer.d.

References Buffer::limit, and Buffer::position.

Referenced by Cluster::broadcast(), Buffer::flush(), VirtualCache::put(), HttpMessage::setConduit(), testBuffer(), and testClient().

uint getLimit  )  [inline, inherited]
 

Returns the limit of readable content within this buffer

Reimplemented from IBuffer.

Definition at line 588 of file Buffer.d.

References Buffer::limit.

uint getCapacity  )  [inline, inherited]
 

Returns the total capacity of this buffer

Reimplemented from IBuffer.

Definition at line 599 of file Buffer.d.

uint getPosition  )  [inline, inherited]
 

Returns the current read-position within this buffer

Reimplemented from IBuffer.

Definition at line 610 of file Buffer.d.

References Buffer::position.

Referenced by Cluster::broadcast(), and ResponseLine::parse().

IConduit getConduit  )  [inline, inherited]
 

Returns the conduit associated with this buffer. Returns null if the buffer is purely memory based; that is, it's not backed by some external medium.

Buffers do not require an external conduit to operate, but it can be convenient to associate one. For example, methods read and write use it to import/export content as necessary.

Reimplemented from IBuffer.

Definition at line 627 of file Buffer.d.

Referenced by copy(), and HttpMessage::getConduit().

void setConduit IConduit  conduit  )  [inline, inherited]
 

Sets the external conduit associated with this buffer.

Buffers do not require an external conduit to operate, but it can be convenient to associate one. For example, methods read and write use it to import/export content as necessary.

Reimplemented from IBuffer.

Reimplemented in MappedBuffer.

Definition at line 642 of file Buffer.d.

Referenced by SocketConduit::createBuffer(), HttpMessage::setConduit(), and FileBucket::this().


Member Data Documentation

IOException ovf [static, inherited]
 

Definition at line 148 of file Buffer.d.


The documentation for this class was generated from the following file:
Generated on Sun Nov 7 19:07:02 2004 for Mango by doxygen 1.3.6