OFStream Class Reference

#import <OFStream.h>

Inheritance diagram for OFStream:
OFObject OFFile OFSocket OFFileSingleton OFTCPSocket

List of all members.

Public Member Functions

(BOOL) - atEndOfStream
(BOOL) - atEndOfStreamWithoutCache
(size_t) - readNBytes:intoBuffer:
(size_t) - readNBytesWithoutCache:intoBuffer:
(OFString *) - readLine
(OFString *) - readLineWithEncoding:
(size_t) - writeNBytes:fromBuffer:
(size_t) - writeString:
(id) - close

Protected Attributes

char * cache
size_t cache_len

Detailed Description

The OFStream class provides a base class for different types of streams.


Member Function Documentation

- (BOOL) atEndOfStream  

Returns a boolean whether the end of the stream has been reached.

IMPORTANT: Do *NOT* override this in subclasses! Override atEndOfStreamWithoutCache instead, as otherwise, you *WILL* break caching and thus get broken results!

Returns:
A boolean whether the end of the stream has been reached
- (BOOL) atEndOfStreamWithoutCache  

Returns a boolean whether the end of the stream has been reached without looking at the cache.

IMPORTANT: Do *NOT* use this! Use atEndOfCache instead, as this is *ONLY* for being overriden in subclasses!

Returns:
A boolean whether the end of the stream has been reached
- (id) close  

Closes the stream.

Reimplemented in OFSocket, and OFTCPSocket.

- (OFString *) readLine  

Read until a newline, \0 or end of stream occurs.

Returns:
The line that was read, autoreleased, or nil if the end of the stream has been reached.
- (OFString *) readLineWithEncoding: (enum of_string_encoding)  encoding  

Read with the specified encoding until a newline, \0 or end of stream occurs.

Returns:
The line that was read, autoreleased, or nil if the end of the stream has been reached.
- (size_t) readNBytes: (size_t)  size
intoBuffer: (char*)  buf 

Reads from the stream into a buffer.

IMPORTANT: Do *NOT* override this in subclasses! Override readNBytesWithoutCache:intoBuffer: instead, as otherwise, you *WILL* break caching and thus get broken results!

Parameters:
buf The buffer into which the data is read
size The size of the data that should be read. The buffer MUST be at least size big!
Returns:
The number of bytes read
- (size_t) readNBytesWithoutCache: (size_t)  size
intoBuffer: (char*)  buf 

Reads from the stream into a buffer without looking at the cache.

IMPORTANT: Do *NOT* use this! Use readNBytes:intoBuffer: instead, as this is *ONLY* for being overriden in subclasses!

Parameters:
buf The buffer into which the data is read
size The size of the data that should be read. The buffer MUST be at least size big!
Returns:
The number of bytes read
- (size_t) writeNBytes: (size_t)  size
fromBuffer: (const char*)  buf 

Writes from a buffer into the stream.

Parameters:
buf The buffer from which the data is written to the stream
size The size of the data that should be written
Returns:
The number of bytes written
- (size_t) writeString: (OFString*)  str  

Writes a string into the stream, without the trailing zero.

Parameters:
str The string from which the data is written to the stream
Returns:
The number of bytes written

The documentation for this class was generated from the following files:
 All Classes Functions Variables

Generated on Thu Dec 24 11:10:01 2009 for ObjFW by  doxygen 1.6.1