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 VersionMapped::MappedFile List of all members.

Public Member Functions

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

Private Member Functions

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

Static Private Attributes

static char[] overflow = "output buffer overflow"
static char[] underflow = "input buffer underflow"
static char[] eofRead = "end-of-file whilst reading"
static char[] eofWrite = "end-of-file whilst writing"

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


Member Function Documentation

this  )  [inline]
 

Construct an empty MappedBuffer

Definition at line 689 of file Buffer.d.

void close  ) 
 

Close this mapped buffer

void flush  ) 
 

Flush any dirty content out to the drive

Reimplemented from Buffer.

void setPosition uint  position  )  [inline]
 

Set the read/write position

Definition at line 716 of file Buffer.d.

long seek long  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 728 of file Buffer.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 750 of file Buffer.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 762 of file Buffer.d.

int write int(*)(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 781 of file Buffer.d.

References assert().

IBuffer compress  )  [inline]
 

Prohibit compress() from doing anything at all.

Reimplemented from Buffer.

Definition at line 799 of file Buffer.d.

IBuffer clear  )  [inline]
 

Prohibit clear() from doing anything at all.

Reimplemented from Buffer.

Definition at line 810 of file Buffer.d.

void setConduit IConduit  conduit  )  [inline]
 

Prohibit the setting of another IConduit

Reimplemented from Buffer.

Definition at line 821 of file Buffer.d.

References assert().

this uint  capacity = 0  )  [inline, inherited]
 

Construct a Buffer with the specified number of bytes.

Reimplemented in GrowableBuffer.

Definition at line 180 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 192 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 206 of file Buffer.d.

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

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

Throw an exception with the provided message

Definition at line 217 of file Buffer.d.

Referenced by Buffer::append(), Buffer::flush(), and Buffer::get().

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

void [] getContent  )  [inline, inherited]
 

Return the backing array

Reimplemented from IBuffer.

Definition at line 243 of file Buffer.d.

References Buffer::data.

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

References Buffer::setContent().

Referenced by StartLine::VersionUseTokenizer::parse(), ResponseLine::parse(), 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 271 of file Buffer.d.

Referenced by Buffer::append(), 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 290 of file Buffer.d.

Referenced by Buffer::append().

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

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

Referenced by 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 362 of file Buffer.d.

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

Referenced by testAppend(), and testClient().

char [] toString  )  [inline, inherited]
 

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

Reimplemented from IBuffer.

Definition at line 401 of file Buffer.d.

References Buffer::data, 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 418 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 440 of file Buffer.d.

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

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

int read int(*)(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 496 of file Buffer.d.

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

uint getLimit  )  [inline, inherited]
 

Returns the limit of readable content within this buffer

Reimplemented from IBuffer.

Definition at line 567 of file Buffer.d.

References Buffer::limit.

uint getCapacity  )  [inline, inherited]
 

Returns the total capacity of this buffer

Reimplemented from IBuffer.

Definition at line 578 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 589 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 606 of file Buffer.d.

References Buffer::conduit.

Referenced by HttpMessage::getConduit().


Member Data Documentation

char [] overflow = "output buffer overflow" [static, protected, inherited]
 

Definition at line 160 of file Buffer.d.

Referenced by Buffer::append().

char [] underflow = "input buffer underflow" [static, protected, inherited]
 

Definition at line 161 of file Buffer.d.

Referenced by Buffer::get().

char [] eofRead = "end-of-file whilst reading" [static, protected, inherited]
 

Definition at line 162 of file Buffer.d.

Referenced by Buffer::get().

char [] eofWrite = "end-of-file whilst writing" [static, protected, inherited]
 

Definition at line 163 of file Buffer.d.

Referenced by Buffer::flush().


The documentation for this class was generated from the following file:
Generated on Fri May 27 18:12:02 2005 for Mango by  doxygen 1.4.0