ObjFW
|
A base class for different types of streams. More...
#include <OFStream.h>
Public Member Functions | |
BOOL | isAtEndOfStream () |
size_t | readNBytes:intoBuffer: (size_t size,[intoBuffer] char *buf) |
void | readExactlyNBytes:intoBuffer: (size_t size,[intoBuffer] char *buf) |
uint8_t | readInt8 () |
uint16_t | readBigEndianInt16 () |
uint32_t | readBigEndianInt32 () |
uint64_t | readBigEndianInt64 () |
uint16_t | readLittleEndianInt16 () |
uint32_t | readLittleEndianInt32 () |
uint64_t | readLittleEndianInt64 () |
OFDataArray * | readDataArrayWithItemSize:andNItems: (size_t itemsize,[andNItems] size_t nitems) |
OFDataArray * | readDataArrayTillEndOfStream () |
OFString * | readLine () |
OFString * | readLineWithEncoding: (of_string_encoding_t encoding) |
OFString * | readTillDelimiter: (OFString *delimiter) |
OFString * | readTillDelimiter:withEncoding: (OFString *delimiter,[withEncoding] of_string_encoding_t encoding) |
BOOL | buffersWrites () |
void | setBuffersWrites: (BOOL enable) |
void | flushWriteBuffer () |
size_t | writeNBytes:fromBuffer: (size_t size,[fromBuffer] const char *buf) |
void | writeInt8: (uint8_t int8) |
void | writeBigEndianInt16: (uint16_t int16) |
void | writeBigEndianInt32: (uint32_t int32) |
void | writeBigEndianInt64: (uint64_t int64) |
void | writeLittleEndianInt16: (uint16_t int16) |
void | writeLittleEndianInt32: (uint32_t int32) |
void | writeLittleEndianInt64: (uint64_t int64) |
size_t | writeDataArray: (OFDataArray *dataarray) |
size_t | writeString: (OFString *str) |
size_t | writeLine: (OFString *str) |
size_t | writeFormat: (OFString *fmt,[,]...) |
size_t | writeFormat:withArguments: (OFString *fmt,[withArguments] va_list args) |
size_t | pendingBytes () |
BOOL | isBlocking () |
void | setBlocking: (BOOL enable) |
int | fileDescriptor () |
void | close () |
Protected Attributes | |
char * | cache |
char * | wBuffer |
size_t | cacheLen |
size_t | wBufferLen |
BOOL | buffersWrites |
Properties | |
BOOL | isBlocking |
A base class for different types of streams.
IMPORTANT: If you want to subclass this, override _readNBytes:intoBuffer:, _writeNBytes:fromBuffer: and _isAtEndOfStream, but nothing else. Those are not defined in the headers, but do the actual work. OFStream uses those and does all the caching and other stuff. If you override these methods without the _ prefix, you *WILL* break caching and get broken results!
BOOL OFStream::buffersWrites | ( | ) | [virtual] |
void OFStream::close | ( | ) | [virtual] |
Closes the stream.
int OFStream::fileDescriptor | ( | ) | [virtual] |
void OFStream::flushWriteBuffer | ( | ) | [virtual] |
Writes everythig in the write buffer to the stream.
BOOL OFStream::isAtEndOfStream | ( | ) | [virtual] |
Returns a boolean whether the end of the stream has been reached.
BOOL OFStream::isBlocking | ( | ) | [virtual] |
size_t OFStream::pendingBytes | ( | ) | [virtual] |
uint16_t OFStream::readBigEndianInt16 | ( | ) | [virtual] |
Reads a uint16_t from the stream which is encoded in big endian.
WARNING: Only call this when you know that enough data is available! Otherwise you will get an exception!
uint32_t OFStream::readBigEndianInt32 | ( | ) | [virtual] |
Reads a uint32_t from the stream which is encoded in big endian.
WARNING: Only call this when you know that enough data is available! Otherwise you will get an exception!
uint64_t OFStream::readBigEndianInt64 | ( | ) | [virtual] |
Reads a uint64_t from the stream which is encoded in big endian.
WARNING: Only call this when you know that enough data is available! Otherwise you will get an exception!
OFDataArray * OFStream::readDataArrayTillEndOfStream | ( | ) | [virtual] |
OFDataArray * OFStream::readDataArrayWithItemSize:andNItems: | ( | size_t | itemsize, |
[andNItems] size_t | nitems | ||
) | [virtual] |
Reads nitems items with the specified item size from the stream and returns them in an OFDataArray.
WARNING: Only call this when you know that enough data is available! Otherwise you will get an exception!
itemsize | The size of each item |
nitems | The number of iteams to read |
void OFStream::readExactlyNBytes:intoBuffer: | ( | size_t | size, |
[intoBuffer] char* | buf | ||
) | [virtual] |
Reads exactly size bytes from the stream into a buffer. Unlike readNBytes:intoBuffer:, this method does not return when less than the specified size has been read - instead, it waits until it got exactly size bytes.
WARNING: Only call this when you know that specified amount of data is available! Otherwise you will get an exception!
buf | The buffer into which the data is read |
size | The size of the data that should be read. The buffer MUST be EXACTLY this big! |
uint8_t OFStream::readInt8 | ( | ) | [virtual] |
Reads a uint8_t from the stream.
WARNING: Only call this when you know that enough data is available! Otherwise you will get an exception!
OFString * OFStream::readLine | ( | ) | [virtual] |
Read until a newline, \0 or end of stream occurs.
OFString * OFStream::readLineWithEncoding: | ( | of_string_encoding_t | encoding | ) | [virtual] |
Read with the specified encoding until a newline, \0 or end of stream occurs.
encoding | The encoding used by the stream |
uint16_t OFStream::readLittleEndianInt16 | ( | ) | [virtual] |
Reads a uint16_t from the stream which is encoded in little endian.
WARNING: Only call this when you know that enough data is available! Otherwise you will get an exception!
uint32_t OFStream::readLittleEndianInt32 | ( | ) | [virtual] |
Reads a uint32_t from the stream which is encoded in little endian.
WARNING: Only call this when you know that enough data is available! Otherwise you will get an exception!
uint64_t OFStream::readLittleEndianInt64 | ( | ) | [virtual] |
Reads a uint64_t from the stream which is encoded in little endian.
WARNING: Only call this when you know that enough data is available! Otherwise you will get an exception!
size_t OFStream::readNBytes:intoBuffer: | ( | size_t | size, |
[intoBuffer] char* | buf | ||
) | [virtual] |
Reads at most size bytes from the stream into a buffer.
buf | The buffer into which the data is read |
size | The size of the data that should be read at most. The buffer MUST be at least size big! |
Read until the specified string or \0 is found or the end of stream occurs.
delimiter | The delimiter |
OFString * OFStream::readTillDelimiter:withEncoding: | ( | OFString* | delimiter, |
[withEncoding] of_string_encoding_t | encoding | ||
) | [virtual] |
Read until the specified string or \0 is found or the end of stream occurs.
delimiter | The delimiter |
encoding | The encoding used by the stream |
void OFStream::setBlocking: | ( | BOOL | enable | ) | [virtual] |
Enables or disables non-blocking I/O.
By default, a stream is in blocking mode. On Win32, this currently only works for sockets!
enable | Whether the stream should be blocking |
void OFStream::setBuffersWrites: | ( | BOOL | enable | ) | [virtual] |
Enables or disables the write buffer.
enable | Whether the write buffer should be enabled or disabled |
void OFStream::writeBigEndianInt16: | ( | uint16_t | int16 | ) | [virtual] |
Writes a uint16_t into the stream, encoded in big endian.
int16 | A uint16_t |
void OFStream::writeBigEndianInt32: | ( | uint32_t | int32 | ) | [virtual] |
Writes a uint32_t into the stream, encoded in big endian.
int32 | A uint32_t |
void OFStream::writeBigEndianInt64: | ( | uint64_t | int64 | ) | [virtual] |
Writes a uint64_t into the stream, encoded in big endian.
int64 | A uint64_t |
size_t OFStream::writeDataArray: | ( | OFDataArray* | dataarray | ) | [virtual] |
Writes from an OFDataArray into the stream.
dataarray | The OFDataArray to write into the stream |
size_t OFStream::writeFormat: | ( | OFString* | fmt, |
[,] | ... | ||
) | [virtual] |
Writes a formatted string into the stream.
fmt | A string used as format |
size_t OFStream::writeFormat:withArguments: | ( | OFString* | fmt, |
[withArguments] va_list | args | ||
) | [virtual] |
Writes a formatted string into the stream.
fmt | A string used as format |
args | The arguments used in the format string |
void OFStream::writeInt8: | ( | uint8_t | int8 | ) | [virtual] |
Writes a uint8_t into the stream.
int8 | A uint8_t |
size_t OFStream::writeLine: | ( | OFString* | str | ) | [virtual] |
Writes a string into the stream with a trailing newline.
str | The string from which the data is written to the stream |
void OFStream::writeLittleEndianInt16: | ( | uint16_t | int16 | ) | [virtual] |
Writes a uint16_t into the stream, encoded in little endian.
int16 | A uint16_t |
void OFStream::writeLittleEndianInt32: | ( | uint32_t | int32 | ) | [virtual] |
Writes a uint32_t into the stream, encoded in little endian.
int32 | A uint32_t |
void OFStream::writeLittleEndianInt64: | ( | uint64_t | int64 | ) | [virtual] |
Writes a uint64_t into the stream, encoded in little endian.
int64 | A uint64_t |
size_t OFStream::writeNBytes:fromBuffer: | ( | size_t | size, |
[fromBuffer] const char* | buf | ||
) | [virtual] |
Writes from a buffer into the stream.
buf | The buffer from which the data is written to the stream |
size | The size of the data that should be written |
size_t OFStream::writeString: | ( | OFString* | str | ) | [virtual] |
Writes a string into the stream, without the trailing zero.
str | The string from which the data is written to the stream |