Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages
more::io::buffer Class Template Reference
A stream buffer with arbitary lookahead.
More...
#include <more/io/buffer.h>
Inheritance diagram for more::io::buffer:
[legend]Collaboration diagram for more::io::buffer:
[legend]List of all members.Public Types
Public Methods
Protected Methods
Detailed Description
template<typename T>
class more::io::buffer< T >
A stream buffer with arbitary lookahead.
The main purpose of this class is to provide arbitrary lookahead. This is done by a mechanism similar to the std::vector implementation, namely the buffer space is at least doubled each time it need to be expanded, in order to provide amortized constant operations. This buffer can be used for both input and output, though usually not at the same time. An exception could be duplex sound, since in that case, the length of the output is the same as that of the input. Due to the buffering, the overhead of having both input and output when only one is used is negligible.
Member Typedef Documentation
template<typename T> |
typedef std::ptrdiff_t more::io::buffer::difference
|
|
template<typename T> |
typedef std::size_t more::io::buffer::size_type
|
|
template<typename T> |
typedef T more::io::buffer::value_type
|
|
Constructor & Destructor Documentation
template<typename T> |
more::io::buffer< T >::buffer |
( |
driver * |
drv = 0, |
|
|
bool |
is_interactive = false |
|
) |
[inline, explicit] |
|
|
Construct an optionally install a driver.
If is_interactive is true, the buffer will not read more characters from the driver than strictly requested. |
template<typename T> |
more::io::buffer< T >::~buffer |
( |
|
) |
[inline] |
|
Member Function Documentation
template<typename T> |
T const& more::io::buffer< T >::at |
( |
size_type |
n |
) |
const [inline] |
|
template<typename T> |
T& more::io::buffer< T >::at |
( |
size_type |
n |
) |
[inline] |
|
|
Returns a reference to item number n counting from the current position, with no checks.
-
Precondition:
-
There is at least n+1 items lookahead.
|
template<typename T> |
T* more::io::buffer< T >::data |
( |
size_type |
n |
) |
[inline] |
|
|
Returns an array of at least n items starting at the current item.
-
Precondition:
-
There is at least n items left in the input sequence.
|
template<typename T> |
T const* more::io::buffer< T >::data |
( |
|
) |
const [inline] |
|
template<typename T> |
T* more::io::buffer< T >::data |
( |
|
) |
[inline] |
|
|
Returns a pointer to the current buffer position, with no checks.
It is valid to dereference any element within the current lookahead. The pointer is invalidated by a call to any non-const method which is not also overloaded with a const method. |
template<typename T> |
T& more::io::buffer< T >::get |
( |
|
) |
[inline] |
|
|
Increment the current position and return reference to the new previous item.
-
Precondition:
-
!is_eof()
-
Postcondition:
-
It is guaranteed to be one character lookahead so that peek() is valid, unless is_eof().
|
template<typename T> |
T* more::io::buffer< T >::get_n |
( |
size_type |
n |
) |
[inline] |
|
|
Get n items in the form of an array.
That is, advance the current position with n, and return a pointer to the start of the region advanced over. -
Precondition:
-
There is at least n items left in the input sequence.
-
Postcondition:
-
there is at least 1 item lookahead unless
is_eof() . |
template<typename T> |
driver* more::io::buffer< T >::install |
( |
driver * |
b |
) |
[inline] |
|
|
Sync and clears the buffer and ties the buffer to the given driver.
The remaining output sequence is first written, and any unread input is discarded as the buffer is reset. Then the old driver is returns and must be deleted by the callee, and the new driver installed. |
template<typename T> |
bool more::io::buffer< T >::is_eof |
( |
|
) |
[inline] |
|
|
Returns true if the buffer is tied to an input function, and there is no more input.
|
template<typename T> |
bool more::io::buffer< T >::is_error |
( |
|
) |
[inline] |
|
|
Attemt to assure at least n items lookahead, returns the actual number.
|
template<typename T> |
T const& more::io::buffer< T >::peek |
( |
|
) |
const [inline] |
|
template<typename T> |
T& more::io::buffer< T >::peek |
( |
|
) |
[inline] |
|
|
Returns a reference to the current item without incrementing it.
-
Precondition:
-
is_eof() is false.
|
template<typename T> |
void more::io::buffer< T >::set_fixed |
( |
T * |
first, |
|
|
T * |
end, |
|
|
bool |
have_eof = false |
|
) |
[inline, protected] |
|
|
Set a fixed buffer.
If the buffer provides input, it is assumed that the range provided already contains a bufferfull of data. |
template<typename T> |
void more::io::buffer< T >::swap |
( |
buffer< T > & |
b |
) |
[inline] |
|
|
Swaps drivers, contents and states of the two buffers.
|
template<typename T> |
void more::io::buffer< T >::sync |
( |
|
) |
[inline] |
|
|
Write out any buffered characters.
|
The documentation for this class was generated from the following files:
Generated on Sat Sep 7 19:12:42 2002 for more with Doxygen
1.2.13.1. Doxygen 1.2.13.1 is written and copyright
1997-2002 by Dimitri van
Heesch.