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

MappedBuffer Class Reference

Inheritance diagram for MappedBuffer:

Buffer List of all members.

Public Member Functions

 ~this ()
void setPosition (uint position)
uint seek (uint offset, ISeekable.SeekAnchor anchor)
uint writable ()
protected void copy (void *src, uint size)
uint write (uint(*dg)(void[]))
IBuffer compress ()
IBuffer clear ()
void setConduit (IConduit conduit)

Private Member Functions

 this (IConduit conduit)
 this (uint capacity=0)
 this (void[] data)
 this (void[] data, uint readable)
void error (char[] msg)
void[] getContent ()
Style getStyle ()
IBuffer setValidContent (void[] data)
IBuffer setContent (void[] data, uint readable=0)
bool grow (uint size)
void[] get (uint size, bool eat=true)
IBuffer append (void[] src)
char[] toString ()
bool skip (int size)
uint readable ()
uint read (uint(*dg)(void[]))
uint fill ()
uint fill (IConduit conduit)
void makeRoom (int space)
uint drain ()
void flush ()
uint getLimit ()
uint getCapacity ()
uint getPosition ()
IConduit getConduit ()

Private Attributes

FileConduit host
void[] data
Style style
uint limit
uint capacity
uint position
IConduit conduit

Classes

class  VersionPosix
class  VersionWin32

Detailed Description

Subclass to treat the buffer as a seekable entity, where all capacity is available for reading and/or writing. To achieve this we must effectively disable the 'limit' watermark, and locate write operations around 'position' instead.

Definition at line 76 of file MappedBuffer.d.


Constructor & Destructor Documentation

~this  )  [inline]
 

Ensure this is closed when GC'd

Definition at line 178 of file MappedBuffer.d.


Member Function Documentation

void setPosition uint  position  )  [inline]
 

Set the read/write position

Definition at line 189 of file MappedBuffer.d.

uint seek uint  offset,
ISeekable.SeekAnchor  anchor
[inline]
 

Seek to the specified position within the buffer, and return the byte offset of the new location (relative to zero).

Definition at line 201 of file MappedBuffer.d.

uint writable  )  [inline]
 

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

Reimplemented from Buffer.

Definition at line 223 of file MappedBuffer.d.

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

Bulk copy of data from 'src'. Position is adjusted by 'size' bytes.

Reimplemented from Buffer.

Definition at line 235 of file MappedBuffer.d.

uint write uint(*)(void[])  dg  )  [inline]
 

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 appropriate number of bytes if it writes valid content, or IConduit.Eof on error.

Returns whatever the delegate returns.

Reimplemented from Buffer.

Definition at line 254 of file MappedBuffer.d.

References assert().

IBuffer compress  )  [inline]
 

Prohibit compress() from doing anything at all.

Reimplemented from Buffer.

Definition at line 272 of file MappedBuffer.d.

IBuffer clear  )  [inline]
 

Prohibit clear() from doing anything at all.

Reimplemented from Buffer.

Definition at line 283 of file MappedBuffer.d.

void setConduit IConduit  conduit  )  [inline]
 

Prohibit the setting of another IConduit

Reimplemented from Buffer.

Definition at line 294 of file MappedBuffer.d.

this IConduit  conduit  )  [inline, inherited]
 

Construct a Buffer upon the provided conduit

Definition at line 233 of file Buffer.d.

References IConduit::bufferSize(), Buffer::conduit, IConduit::isTextual(), and Buffer::setConduit().

this uint  capacity = 0  )  [inline, inherited]
 

Construct a Buffer with the specified number of bytes.

Reimplemented in GrowBuffer.

Definition at line 246 of file Buffer.d.

References Buffer::capacity.

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 258 of file Buffer.d.

References Buffer::data.

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 272 of file Buffer.d.

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

void error char[]  msg  )  [inline, inherited]
 

Throw an exception with the provided message

Reimplemented from IBuffer.

Definition at line 283 of file Buffer.d.

Referenced by Buffer::append(), Buffer::drain(), RawCodec1::exporter(), Buffer::fill(), Buffer::flush(), Buffer::get(), and Buffer::makeRoom().

void [] getContent  )  [inline, protected, inherited]
 

Return the backing array

Reimplemented from IBuffer.

Definition at line 294 of file Buffer.d.

References Buffer::data.

Style getStyle  )  [inline, inherited]
 

Return style of buffer

Reimplemented from IBuffer.

Definition at line 305 of file Buffer.d.

References Buffer::style.

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 319 of file Buffer.d.

References Buffer::setContent().

Referenced by StartLine::VersionUseTokenizer::parse(), ResponseLine::parse(), and MappedBuffer::VersionWin32::this().

IBuffer setContent void[]  data,
uint  readable = 0
[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 333 of file Buffer.d.

References Buffer::readable().

Referenced by Buffer::setValidContent(), and Buffer::this().

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

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

Reimplemented from IBuffer.

Reimplemented in GrowBuffer.

Definition at line 352 of file Buffer.d.

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

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 383 of file Buffer.d.

References Buffer::capacity, Buffer::compress(), Buffer::conduit, Buffer::data, Buffer::eofRead, Buffer::error(), Buffer::fill(), Buffer::position, Buffer::readable(), Buffer::underflow, and Buffer::writable().

Referenced by RawCodec1::exporter(), Console::Input::opCall(), and Buffer::skip().

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

Append an array of data to 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 424 of file Buffer.d.

References Buffer::capacity, Buffer::conduit, Buffer::copy(), Buffer::error(), IConduit::flush(), Buffer::flush(), Buffer::grow(), Buffer::overflow, and Buffer::writable().

Referenced by RawCodec1::importer(), and Console::Output::opCall().

char [] toString  )  [inline, inherited]
 

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

Reimplemented from IBuffer.

Definition at line 457 of file Buffer.d.

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

Referenced by VirtualCache::put(), and HttpClient::read().

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 474 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 496 of file Buffer.d.

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

Referenced by Buffer::compress(), RawCodec1::exporter(), Buffer::fill(), Buffer::get(), Console::Input::opCall(), HttpClient::open(), HttpClient::read(), Buffer::setContent(), and Buffer::this().

uint read uint(*)(void[])  dg  )  [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 552 of file Buffer.d.

References assert(), Buffer::data, Buffer::limit, and Buffer::position.

Referenced by Buffer::drain(), and RawCodec1::exporter1().

uint fill  )  [inline, inherited]
 

Try to fill the available buffer with content from the specified conduit. In particular, we will never ask to read less than 32 bytes. This permits conduit-filters to operate within a known environment.

Returns the number of bytes read, or throws an underflow error if there nowhere to read from

Reimplemented from IBuffer.

Definition at line 602 of file Buffer.d.

References Buffer::conduit, Buffer::error(), and Buffer::underflow.

Referenced by RawCodec1::exporter(), RawCodec1::exporter1(), Buffer::get(), Console::Input::opCall(), and HttpClient::read().

uint fill IConduit  conduit  )  [inline, inherited]
 

Try to fill the available buffer with content from the specified conduit. In particular, we will never ask to read less than 32 bytes ~ this permits conduit-filters to operate within a known environment. We also try to read as much as possible by clearing the buffer when all current content has been eaten.

Returns the number of bytes read, or Conduit.Eof

Reimplemented from IBuffer.

Definition at line 622 of file Buffer.d.

References Buffer::clear(), Buffer::compress(), Buffer::error(), IConduit::read(), Buffer::readable(), Buffer::writable(), and Buffer::write().

void makeRoom int  space  )  [inline, inherited]
 

make some room in the buffer

Reimplemented from IBuffer.

Definition at line 640 of file Buffer.d.

References Buffer::conduit, Buffer::drain(), Buffer::error(), Buffer::grow(), and Buffer::overflow.

Referenced by RawCodec1::importer1().

uint drain  )  [inline, inherited]
 

Write as much of the buffer that the associated conduit can consume.

Returns the number of bytes written, or Conduit.Eof

Reimplemented from IBuffer.

Definition at line 658 of file Buffer.d.

References Buffer::compress(), Buffer::conduit, IConduit::Eof, Buffer::eofWrite, Buffer::error(), Buffer::read(), and IConduit::write().

Referenced by Buffer::makeRoom().

void flush  )  [inline, inherited]
 

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

Reimplemented from IBuffer.

Definition at line 675 of file Buffer.d.

References Buffer::clear(), Buffer::conduit, Buffer::data, Buffer::eofWrite, Buffer::error(), IConduit::flush(), Buffer::limit, and Buffer::position.

Referenced by Buffer::append(), Console::Output::opCall(), and ClusterThread::run().

uint getLimit  )  [inline, inherited]
 

Returns the limit of readable content within this buffer

Reimplemented from IBuffer.

Definition at line 702 of file Buffer.d.

References Buffer::limit.

uint getCapacity  )  [inline, inherited]
 

Returns the total capacity of this buffer

Reimplemented from IBuffer.

Definition at line 713 of file Buffer.d.

References Buffer::capacity.

uint getPosition  )  [inline, inherited]
 

Returns the current read-position within this buffer

Reimplemented from IBuffer.

Definition at line 724 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 fill() & drain() use it to import/export content as necessary.

Reimplemented from IBuffer.

Definition at line 741 of file Buffer.d.

References Buffer::conduit.

Referenced by HttpMessage::getConduit(), and ClusterThread::run().


Member Data Documentation

FileConduit host [private]
 

Definition at line 78 of file MappedBuffer.d.

Referenced by MappedBuffer::VersionWin32::flush(), and MappedBuffer::VersionWin32::this().

void [] data [protected, inherited]
 

Definition at line 207 of file Buffer.d.

Referenced by Buffer::compress(), Buffer::copy(), Buffer::flush(), Buffer::get(), Buffer::getContent(), Buffer::read(), Buffer::this(), Buffer::toString(), and Buffer::write().

Style style [protected, inherited]
 

Definition at line 208 of file Buffer.d.

Referenced by Buffer::getStyle().

uint limit [protected, inherited]
 

Definition at line 209 of file Buffer.d.

Referenced by Buffer::clear(), Buffer::compress(), Buffer::copy(), Buffer::flush(), Buffer::getLimit(), Buffer::read(), Buffer::readable(), Buffer::toString(), Buffer::writable(), and Buffer::write().

uint capacity [protected, inherited]
 

Definition at line 210 of file Buffer.d.

Referenced by Buffer::append(), Buffer::get(), Buffer::getCapacity(), Buffer::this(), Buffer::writable(), and Buffer::write().

uint position [protected, inherited]
 

Definition at line 211 of file Buffer.d.

Referenced by Buffer::clear(), Buffer::compress(), Buffer::flush(), Buffer::get(), Buffer::getPosition(), Buffer::read(), Buffer::readable(), Buffer::skip(), and Buffer::toString().

IConduit conduit [protected, inherited]
 

Reimplemented in Console::Input, Console::Output, Console::Input, and Console::Output.

Definition at line 212 of file Buffer.d.

Referenced by Buffer::append(), Buffer::drain(), Buffer::fill(), Buffer::flush(), Buffer::get(), Buffer::getConduit(), Buffer::makeRoom(), and Buffer::this().


The documentation for this class was generated from the following file:
Generated on Sat Dec 24 17:28:40 2005 for Mango by  doxygen 1.4.0