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;
297@property (readonly, nonatomic, getter=isAtEndOfStream)
bool atEndOfStream;
334@property OF_NULLABLE_PROPERTY (assign, nonatomic)
355- (size_t)readIntoBuffer: (
void *)buffer length: (
size_t)length;
376 - (void)readIntoBuffer: (
void *)buffer exactLength: (
size_t)length;
378#ifdef OF_HAVE_SOCKETS
399- (void)asyncReadIntoBuffer: (
void *)buffer length: (
size_t)length;
422- (void)asyncReadIntoBuffer: (
void *)buffer
423 length: (
size_t)length
442- (void)asyncReadIntoBuffer: (
void *)buffer exactLength: (
size_t)length;
461- (void)asyncReadIntoBuffer: (
void *)buffer
462 exactLength: (
size_t)length
465# ifdef OF_HAVE_BLOCKS
493- (void)asyncReadIntoBuffer: (
void *)buffer
494 length: (
size_t)length
496 OF_DEPRECATED(ObjFW, 1, 2,
497 "Use -[asyncReadIntoBuffer:length:handler:] instead");
525- (void)asyncReadIntoBuffer: (
void *)buffer
526 length: (
size_t)length
557- (void)asyncReadIntoBuffer: (
void *)buffer
558 length: (
size_t)length
561 OF_DEPRECATED(ObjFW, 1, 2,
562 "Use -[asyncReadIntoBuffer:length:runLoopMode:handler:] instead");
591- (void)asyncReadIntoBuffer: (
void *)buffer
592 length: (
size_t)length
619- (void)asyncReadIntoBuffer: (
void *)buffer
620 exactLength: (
size_t)length
622 OF_DEPRECATED(ObjFW, 1, 2,
623 "Use -[asyncReadIntoBuffer:exactLength:handler:] instead");
647- (void)asyncReadIntoBuffer: (
void *)buffer
648 exactLength: (
size_t)length
676- (void)asyncReadIntoBuffer: (
void *)buffer
677 exactLength: (
size_t)length
680 OF_DEPRECATED(ObjFW, 1, 2,
681 "Use -[asyncReadIntoBuffer:exactLength:runLoopMode:handler: instead]");
706- (void)asyncReadIntoBuffer: (
void *)buffer
707 exactLength: (
size_t)length
881- (
OFData *)readDataWithCount: (
size_t)count;
898- (
OFData *)readDataWithItemSize: (
size_t)itemSize count: (
size_t)count;
953- (
OFString *)readStringWithLength: (
size_t)length;
976- (
OFString *)readStringWithLength: (
size_t)length
1005#ifdef OF_HAVE_SOCKETS
1072# ifdef OF_HAVE_BLOCKS
1140 OF_DEPRECATED(ObjFW, 1, 2, "Use -[asyncReadLineWithHandler:] instead");
1175 OF_DEPRECATED(ObjFW, 1, 2,
1176 "Use -[asyncReadLineWithEncoding:handler:] instead");
1215 OF_DEPRECATED(ObjFW, 1, 2,
1216 "Use -[asyncReadLineWithEncoding:runLoopMode:handler:] instead");
1376- (void)writeBuffer: (const
void *)buffer length: (
size_t)length;
1378#ifdef OF_HAVE_SOCKETS
1387- (void)asyncWriteData: (
OFData *)data;
1398- (void)asyncWriteData: (
OFData *)data
1409- (void)asyncWriteString: (
OFString *)string;
1422- (void)asyncWriteString: (
OFString *)string
1437- (void)asyncWriteString: (
OFString *)string
1441# ifdef OF_HAVE_BLOCKS
1455- (void)asyncWriteData: (
OFData *)data
1457 OF_DEPRECATED(ObjFW, 1, 2, "Use -[asyncWriteData:handler:] instead");
1470- (void)asyncWriteData: (
OFData *)data
1487- (void)asyncWriteData: (
OFData *)data
1490 OF_DEPRECATED(ObjFW, 1, 2,
1491 "Use -[asyncWriteData:runLoopMode:handler:] instead");
1505- (void)asyncWriteData: (
OFData *)data
1522- (void)asyncWriteString: (
OFString *)string
1524 OF_DEPRECATED(ObjFW, 1, 2, "Use -[asyncWriteString:handler:] instead");
1537- (void)asyncWriteString: (
OFString *)string
1556- (void)asyncWriteString: (
OFString *)string
1559 OF_DEPRECATED(ObjFW, 1, 2,
1560 "Use -[asyncWriteString:
encoding:handler:] instead");
1576- (void)asyncWriteString: (
OFString *)string
1597- (void)asyncWriteString: (
OFString *)string
1601 OF_DEPRECATED(ObjFW, 1, 2,
1602 "Use -[asyncWriteString:
encoding:runLoopMode:handler:] instead");
1619- (void)asyncWriteString: (
OFString *)string
1635- (void)writeInt8: (uint8_t)int8;
1646- (void)writeBigEndianInt16: (uint16_t)int16;
1657- (void)writeBigEndianInt32: (uint32_t)int32;
1668- (void)writeBigEndianInt64: (uint64_t)int64;
1679- (void)writeBigEndianFloat: (
float)float_;
1690- (void)writeBigEndianDouble: (
double)double_;
1701- (void)writeLittleEndianInt16: (uint16_t)int16;
1712- (void)writeLittleEndianInt32: (uint32_t)int32;
1723- (void)writeLittleEndianInt64: (uint64_t)int64;
1734- (void)writeLittleEndianFloat: (
float)float_;
1745- (void)writeLittleEndianDouble: (
double)double_;
1756- (void)writeData: (
OFData *)data;
1767- (void)writeString: (
OFString *)string;
1791- (void)writeLine: (
OFString *)string;
1837- (void)writeFormat: (
OFConstantString *)format arguments: (va_list)arguments;
1839#ifdef OF_HAVE_SOCKETS
1867- (void)unreadFromBuffer: (const
void *)buffer length: (
size_t)length;
1892- (size_t)lowlevelReadIntoBuffer: (
void *)buffer length: (
size_t)length;
1908- (size_t)lowlevelWriteBuffer: (const
void *)buffer length: (
size_t)length;
1936OF_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:922
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:1772
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:1666
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:1651
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:878
void asyncReadString()
Asynchronously reads until a \0, end of stream or an exception occurs.
Definition OFStream.m:724
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:751
nullable OFString * readLine()
Reads until a newline, \0 or end of stream occurs.
Definition OFStream.m:707
bool flushWriteBuffer()
Writes everything in the write buffer to the stream.
Definition OFStream.m:1223
id< OFStreamDelegate > delegate
The delegate for asynchronous operations on the stream.
Definition OFStream.h:336
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:1749
bool buffersWrites
Whether writes are buffered.
Definition OFStream.h:303
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:1024
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:1656
A class for handling strings.
Definition OFString.h:143
A protocol for the creation of copies.
Definition OFObject.h:1584