20#ifndef __STDC_LIMIT_MACROS
21# define __STDC_LIMIT_MACROS
23#ifndef __STDC_CONSTANT_MACROS
24# define __STDC_CONSTANT_MACROS
33# import "OFKernelEventObserver.h"
36OF_ASSUME_NONNULL_BEGIN
43#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_BLOCKS)
56 OF_DEPRECATED(ObjFW, 1, 2,
"Use OFStreamReadHandler instead");
70 size_t length,
id _Nullable exception);
84 OFString *_Nullable string,
id _Nullable exception);
99 id _Nullable exception)
100 OF_DEPRECATED(ObjFW, 1, 2,
"Use OFStreamStringReadHandler instead");
116 id _Nullable exception)
117 OF_DEPRECATED(ObjFW, 1, 2,
"Use OFStreamDataWrittenHandler instead");
133 OFData *data,
size_t bytesWritten,
id _Nullable exception);
149 size_t bytesWritten,
id _Nullable exception)
150 OF_DEPRECATED(ObjFW, 1, 2,
"Use OFStreamStringWrittenHandler instead");
168 id _Nullable exception);
189 didReadIntoBuffer: (
void *)buffer
190 length: (
size_t)length
191 exception: (nullable
id)exception;
204 didReadString: (nullable
OFString *)string
205 exception: (nullable
id)exception;
218 didReadLine: (nullable
OFString *)line
219 exception: (nullable
id)exception;
234 didWriteData: (
OFData *)data
235 bytesWritten: (
size_t)bytesWritten
236 exception: (nullable
id)exception;
254 bytesWritten: (
size_t)bytesWritten
255 exception: (nullable
id)exception;
281 id _Nullable _delegate;
282#ifndef OF_SEEKABLE_STREAM_M
285 char *_Nullable _readBuffer, *_Nullable _readBufferMemory;
286 char *_Nullable _writeBuffer;
287 size_t _readBufferLength, _writeBufferLength;
288 bool _buffersWrites, _waitingForDelimiter;
291 uintptr_t _allowsLossyEncoding;
298@property (readonly, nonatomic, getter=isAtEndOfStream)
bool atEndOfStream;
345@property OF_NULLABLE_PROPERTY (assign, nonatomic)
366- (size_t)readIntoBuffer: (
void *)buffer length: (
size_t)length;
387 - (void)readIntoBuffer: (
void *)buffer exactLength: (
size_t)length;
389#ifdef OF_HAVE_SOCKETS
410- (void)asyncReadIntoBuffer: (
void *)buffer length: (
size_t)length;
433- (void)asyncReadIntoBuffer: (
void *)buffer
434 length: (
size_t)length
453- (void)asyncReadIntoBuffer: (
void *)buffer exactLength: (
size_t)length;
472- (void)asyncReadIntoBuffer: (
void *)buffer
473 exactLength: (
size_t)length
476# ifdef OF_HAVE_BLOCKS
504- (void)asyncReadIntoBuffer: (
void *)buffer
505 length: (
size_t)length
507 OF_DEPRECATED(ObjFW, 1, 2,
508 "Use -[asyncReadIntoBuffer:length:handler:] instead");
536- (void)asyncReadIntoBuffer: (
void *)buffer
537 length: (
size_t)length
568- (void)asyncReadIntoBuffer: (
void *)buffer
569 length: (
size_t)length
572 OF_DEPRECATED(ObjFW, 1, 2,
573 "Use -[asyncReadIntoBuffer:length:runLoopMode:handler:] instead");
602- (void)asyncReadIntoBuffer: (
void *)buffer
603 length: (
size_t)length
630- (void)asyncReadIntoBuffer: (
void *)buffer
631 exactLength: (
size_t)length
633 OF_DEPRECATED(ObjFW, 1, 2,
634 "Use -[asyncReadIntoBuffer:exactLength:handler:] instead");
658- (void)asyncReadIntoBuffer: (
void *)buffer
659 exactLength: (
size_t)length
687- (void)asyncReadIntoBuffer: (
void *)buffer
688 exactLength: (
size_t)length
691 OF_DEPRECATED(ObjFW, 1, 2,
692 "Use -[asyncReadIntoBuffer:exactLength:runLoopMode:handler: instead]");
717- (void)asyncReadIntoBuffer: (
void *)buffer
718 exactLength: (
size_t)length
892- (
OFData *)readDataWithCount: (
size_t)count;
909- (
OFData *)readDataWithItemSize: (
size_t)itemSize count: (
size_t)count;
964- (
OFString *)readStringWithLength: (
size_t)length;
987- (
OFString *)readStringWithLength: (
size_t)length
1016#ifdef OF_HAVE_SOCKETS
1083# ifdef OF_HAVE_BLOCKS
1151 OF_DEPRECATED(ObjFW, 1, 2, "Use -[asyncReadLineWithHandler:] instead");
1186 OF_DEPRECATED(ObjFW, 1, 2,
1187 "Use -[asyncReadLineWithEncoding:handler:] instead");
1226 OF_DEPRECATED(ObjFW, 1, 2,
1227 "Use -[asyncReadLineWithEncoding:runLoopMode:handler:] instead");
1387- (void)writeBuffer: (const
void *)buffer length: (
size_t)length;
1389#ifdef OF_HAVE_SOCKETS
1398- (void)asyncWriteData: (
OFData *)data;
1409- (void)asyncWriteData: (
OFData *)data
1420- (void)asyncWriteString: (
OFString *)string;
1433- (void)asyncWriteString: (
OFString *)string
1448- (void)asyncWriteString: (
OFString *)string
1452# ifdef OF_HAVE_BLOCKS
1466- (void)asyncWriteData: (
OFData *)data
1468 OF_DEPRECATED(ObjFW, 1, 2, "Use -[asyncWriteData:handler:] instead");
1481- (void)asyncWriteData: (
OFData *)data
1498- (void)asyncWriteData: (
OFData *)data
1501 OF_DEPRECATED(ObjFW, 1, 2,
1502 "Use -[asyncWriteData:runLoopMode:handler:] instead");
1516- (void)asyncWriteData: (
OFData *)data
1533- (void)asyncWriteString: (
OFString *)string
1535 OF_DEPRECATED(ObjFW, 1, 2, "Use -[asyncWriteString:handler:] instead");
1548- (void)asyncWriteString: (
OFString *)string
1567- (void)asyncWriteString: (
OFString *)string
1570 OF_DEPRECATED(ObjFW, 1, 2,
1571 "Use -[asyncWriteString:
encoding:handler:] instead");
1587- (void)asyncWriteString: (
OFString *)string
1608- (void)asyncWriteString: (
OFString *)string
1612 OF_DEPRECATED(ObjFW, 1, 2,
1613 "Use -[asyncWriteString:
encoding:runLoopMode:handler:] instead");
1630- (void)asyncWriteString: (
OFString *)string
1646- (void)writeInt8: (uint8_t)int8;
1657- (void)writeBigEndianInt16: (uint16_t)int16;
1668- (void)writeBigEndianInt32: (uint32_t)int32;
1679- (void)writeBigEndianInt64: (uint64_t)int64;
1690- (void)writeBigEndianFloat: (
float)float_;
1701- (void)writeBigEndianDouble: (
double)double_;
1712- (void)writeLittleEndianInt16: (uint16_t)int16;
1723- (void)writeLittleEndianInt32: (uint32_t)int32;
1734- (void)writeLittleEndianInt64: (uint64_t)int64;
1745- (void)writeLittleEndianFloat: (
float)float_;
1756- (void)writeLittleEndianDouble: (
double)double_;
1767- (void)writeData: (
OFData *)data;
1778- (void)writeString: (
OFString *)string;
1802- (void)writeLine: (
OFString *)string;
1848- (void)writeFormat: (
OFConstantString *)format arguments: (va_list)arguments;
1850#ifdef OF_HAVE_SOCKETS
1878- (void)unreadFromBuffer: (const
void *)buffer length: (
size_t)length;
1903- (size_t)lowlevelReadIntoBuffer: (
void *)buffer length: (
size_t)length;
1919- (size_t)lowlevelWriteBuffer: (const
void *)buffer length: (
size_t)length;
1947OF_ASSUME_NONNULL_END
OFConstantString * OFRunLoopMode
A mode for an OFRunLoop.
Definition OFRunLoop.h:46
OFData *(^ OFStreamAsyncWriteDataBlock)(size_t bytesWritten, id exception)
A block which is called when data was written asynchronously to a stream.
Definition OFStream.h:115
OFData *(^ OFStreamDataWrittenHandler)(OFStream *stream, OFData *data, size_t bytesWritten, id exception)
A handler which is called when data was written asynchronously to a stream.
Definition OFStream.h:132
bool(^ OFStreamReadHandler)(OFStream *stream, void *buffer, size_t length, id exception)
A handler which is called when data was read asynchronously from a stream.
Definition OFStream.h:69
bool(^ OFStreamAsyncReadBlock)(size_t length, id exception)
A block which is called when data was read asynchronously from a stream.
Definition OFStream.h:55
bool(^ OFStreamAsyncReadLineBlock)(OFString *line, id exception)
A block which is called when a line was read asynchronously from a stream.
Definition OFStream.h:98
OFString *(^ OFStreamStringWrittenHandler)(OFStream *stream, OFString *string, OFStringEncoding encoding, size_t bytesWritten, id exception)
A handler which is called when a string was written asynchronously to a stream.
Definition OFStream.h:166
OFString *(^ OFStreamAsyncWriteStringBlock)(size_t bytesWritten, id exception)
A block which is called when a string was written asynchronously to a stream.
Definition OFStream.h:148
bool(^ OFStreamStringReadHandler)(OFStream *stream, OFString *string, id exception)
A block which is called when a string was read asynchronously from a stream.
Definition OFStream.h:83
OFStringEncoding
The encoding of a string.
Definition OFString.h:65
A class for storing constant strings using the @"" literal.
Definition OFConstantString.h:42
A class for storing arbitrary data in an array.
Definition OFData.h:46
The root class for all other classes inside ObjFW.
Definition OFObject.h:956
A base class for different types of streams.
Definition OFStream.h:280
double readBigEndianDouble()
Reads a double from the stream which is encoded in big endian.
Definition OFStream.m:422
uint8_t readInt8()
Reads a uint8_t from the stream.
Definition OFStream.m:387
bool lowlevelIsAtEndOfStream()
Returns whether the lowlevel is at the end of the stream.
Definition OFStream.m:112
OFString * readString()
Reads a string until a \0 appears in the stream or the end of the stream is reached.
Definition OFStream.m:512
uint32_t readLittleEndianInt32()
Reads a uint32_t from the stream which is encoded in little endian.
Definition OFStream.m:436
void close()
Closes the stream.
Definition OFStream.m:1801
OFData * readDataUntilEndOfStream()
Returns OFData with all the remaining data of the stream.
Definition OFStream.m:492
bool lowlevelHasDataInReadBuffer()
Returns whether the lowlevel has data in the read buffer.
Definition OFStream.m:117
bool canBlock
Whether the stream can block.
Definition OFStream.m:1695
uint64_t readLittleEndianInt64()
Reads a uint64_t from the stream which is encoded in little endian.
Definition OFStream.m:443
bool hasDataInReadBuffer
Whether data is present in the internal read buffer.
Definition OFStream.m:1670
float readBigEndianFloat()
Reads a float from the stream which is encoded in big endian.
Definition OFStream.m:415
uint16_t readLittleEndianInt16()
Reads a uint16_t from the stream which is encoded in little endian.
Definition OFStream.m:429
uint64_t readBigEndianInt64()
Reads a uint64_t from the stream which is encoded in big endian.
Definition OFStream.m:408
OFString * tryReadString()
Tries to read a string until a \0 appears in the stream or the end of the stream is reached.
Definition OFStream.m:885
void asyncReadString()
Asynchronously reads until a \0, end of stream or an exception occurs.
Definition OFStream.m:731
float readLittleEndianFloat()
Reads a float from the stream which is encoded in little endian.
Definition OFStream.m:450
void asyncReadLine()
Asynchronously reads until a newline, \0, end of stream or an exception occurs.
Definition OFStream.m:758
nullable OFString * readLine()
Reads until a newline, \0 or end of stream occurs.
Definition OFStream.m:714
bool flushWriteBuffer()
Writes everything in the write buffer to the stream.
Definition OFStream.m:1233
bool allowsLossyEncoding
Whether the stream allows the specified encoding to be lossy.
Definition OFStream.m:1685
id< OFStreamDelegate > delegate
The delegate for asynchronous operations on the stream.
Definition OFStream.h:347
uint16_t readBigEndianInt16()
Reads a uint16_t from the stream which is encoded in big endian.
Definition OFStream.m:394
void cancelAsyncRequests()
Cancels all pending asynchronous requests on the stream.
Definition OFStream.m:1778
bool buffersWrites
Whether writes are buffered.
Definition OFStream.h:304
uint32_t readBigEndianInt32()
Reads a uint32_t from the stream which is encoded in big endian.
Definition OFStream.m:401
nullable OFString * tryReadLine()
Tries to read a line from the stream (see readLine) and returns nil if no complete line has been rece...
Definition OFStream.m:1034
double readLittleEndianDouble()
Reads a double from the stream which is encoded in little endian.
Definition OFStream.m:457
OFStringEncoding encoding
The encoding to use for reading / writing strings to / from the stream if none has been specified.
Definition OFStream.m:1675
A class for handling strings.
Definition OFString.h:143
A protocol for the creation of copies.
Definition OFObject.h:1618