17 #ifndef __STDC_LIMIT_MACROS 18 # define __STDC_LIMIT_MACROS 20 #ifndef __STDC_CONSTANT_MACROS 21 # define __STDC_CONSTANT_MACROS 28 #ifdef OF_HAVE_SOCKETS 29 # import "OFKernelEventObserver.h" 32 OF_ASSUME_NONNULL_BEGIN
40 #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_BLOCKS) 89 #ifdef OF_HAVE_SOCKETS 94 #if !defined(OF_SEEKABLE_STREAM_M) && !defined(OF_TCP_SOCKET_M) 97 char *_Nullable _readBuffer, *_Nullable _readBufferMemory;
98 char *_Nullable _writeBuffer;
99 size_t _readBufferLength, _writeBufferLength;
100 bool _writeBuffered, _waitingForDelimiter;
126 - (size_t)readIntoBuffer: (
void *)buffer
127 length: (size_t)length;
144 - (void)readIntoBuffer: (
void *)buffer
145 exactLength: (size_t)length;
147 #ifdef OF_HAVE_SOCKETS 175 - (void)asyncReadIntoBuffer: (
void *)buffer
176 length: (size_t)length
178 selector: (SEL)selector;
205 - (void)asyncReadIntoBuffer: (
void *)buffer
206 exactLength: (size_t)length
208 selector: (SEL)selector;
210 # ifdef OF_HAVE_BLOCKS 234 - (void)asyncReadIntoBuffer: (
void *)buffer
235 length: (size_t)length
259 - (void)asyncReadIntoBuffer: (
void *)buffer
260 exactLength: (size_t)length
337 - (size_t)readBigEndianInt16sIntoBuffer: (uint16_t *)buffer
338 count: (size_t)count;
352 - (size_t)readBigEndianInt32sIntoBuffer: (uint32_t *)buffer
353 count: (size_t)count;
367 - (size_t)readBigEndianInt64sIntoBuffer: (uint64_t *)buffer
368 count: (size_t)count;
382 - (size_t)readBigEndianFloatsIntoBuffer: (
float *)buffer
383 count: (size_t)count;
397 - (size_t)readBigEndianDoublesIntoBuffer: (
double *)buffer
398 count: (size_t)count;
462 - (size_t)readLittleEndianInt16sIntoBuffer: (uint16_t *)buffer
463 count: (size_t)count;
477 - (size_t)readLittleEndianInt32sIntoBuffer: (uint32_t *)buffer
478 count: (size_t)count;
492 - (size_t)readLittleEndianInt64sIntoBuffer: (uint64_t *)buffer
493 count: (size_t)count;
507 - (size_t)readLittleEndianFloatsIntoBuffer: (
float *)buffer
508 count: (size_t)count;
522 - (size_t)readLittleEndianDoublesIntoBuffer: (
double *)buffer
523 count: (size_t)count;
535 - (
OFData *)readDataWithCount: (
size_t)count;
548 - (
OFData *)readDataWithItemSize: (
size_t)itemSize
549 count: (size_t)count;
573 - (
OFString *)readStringWithLength: (
size_t)length;
590 - (
OFString *)readStringWithLength: (
size_t)length
611 #ifdef OF_HAVE_SOCKETS 628 - (void)asyncReadLineWithTarget: (
id)target
629 selector: (SEL)selector;
650 selector: (
SEL)selector;
652 # ifdef OF_HAVE_BLOCKS 765 - (void)setWriteBuffered: (
bool)enable;
778 - (void)writeBuffer: (
const void *)buffer
779 length: (size_t)length;
786 - (void)writeInt8: (uint8_t)int8;
793 - (void)writeBigEndianInt16: (uint16_t)int16;
800 - (void)writeBigEndianInt32: (uint32_t)int32;
807 - (void)writeBigEndianInt64: (uint64_t)int64;
814 - (void)writeBigEndianFloat: (
float)float_;
821 - (void)writeBigEndianDouble: (
double)double_;
832 - (size_t)writeBigEndianInt16s: (
const uint16_t *)buffer
833 count: (size_t)count;
844 - (size_t)writeBigEndianInt32s: (
const uint32_t *)buffer
845 count: (size_t)count;
856 - (size_t)writeBigEndianInt64s: (
const uint64_t *)buffer
857 count: (size_t)count;
868 - (size_t)writeBigEndianFloats: (
const float *)buffer
869 count: (size_t)count;
880 - (size_t)writeBigEndianDoubles: (
const double *)buffer
881 count: (size_t)count;
888 - (void)writeLittleEndianInt16: (uint16_t)int16;
895 - (void)writeLittleEndianInt32: (uint32_t)int32;
902 - (void)writeLittleEndianInt64: (uint64_t)int64;
909 - (void)writeLittleEndianFloat: (
float)float_;
916 - (void)writeLittleEndianDouble: (
double)double_;
927 - (size_t)writeLittleEndianInt16s: (
const uint16_t *)buffer
928 count: (size_t)count;
939 - (size_t)writeLittleEndianInt32s: (
const uint32_t *)buffer
940 count: (size_t)count;
951 - (size_t)writeLittleEndianInt64s: (
const uint64_t *)buffer
952 count: (size_t)count;
963 - (size_t)writeLittleEndianFloats: (
const float *)buffer
964 count: (size_t)count;
975 - (size_t)writeLittleEndianDoubles: (
const double *)buffer
976 count: (size_t)count;
984 - (size_t)writeData: (
OFData *)data;
992 - (size_t)writeString: (
OFString *)string;
1002 - (size_t)writeString: (
OFString *)
string 1011 - (size_t)writeLine: (
OFString *)string;
1021 - (size_t)writeLine: (
OFString *)
string 1048 arguments: (va_list)arguments;
1072 - (void)setBlocking: (
bool)enable;
1088 #ifdef OF_HAVE_SOCKETS 1116 - (void)unreadFromBuffer: (
const void *)buffer
1117 length: (size_t)length;
1138 - (size_t)lowlevelReadIntoBuffer: (
void *)buffer
1139 length: (size_t)length;
1152 - (void)lowlevelWriteBuffer: (
const void *)buffer
1153 length: (size_t)length;
1168 OF_ASSUME_NONNULL_END
int fileDescriptorForWriting()
Returns the file descriptor for the write end of the stream.
Definition: OFStream.m:1622
uint32_t readBigEndianInt32()
Reads a uint32_t from the stream which is encoded in big endian.
Definition: OFStream.m:258
void close()
Closes the stream.
Definition: OFStream.m:1651
bool(^ of_stream_async_read_block_t)(OFStream *stream, void *buffer, size_t length, OFException *_Nullable exception)
A block which is called when data was read from the stream.
Definition: OFStream.h:51
A class for handling strings.
Definition: OFString.h:114
uint64_t readBigEndianInt64()
Reads a uint64_t from the stream which is encoded in big endian.
Definition: OFStream.m:268
nullable OFString * readLine()
Reads until a newline, \0 or end of stream occurs.
Definition: OFStream.m:796
uint8_t readInt8()
Reads a uint8_t from the stream.
Definition: OFStream.m:238
uint16_t readBigEndianInt16()
Reads a uint16_t from the stream which is encoded in big endian.
Definition: OFStream.m:248
double readBigEndianDouble()
Reads a double from the stream which is encoded in big endian.
Definition: OFStream.m:288
The base class for all exceptions in ObjFW.
Definition: OFException.h:143
bool isWriteBuffered()
Returns a boolean whether writes are buffered.
Definition: OFStream.m:1018
uint32_t readLittleEndianInt32()
Reads a uint32_t from the stream which is encoded in little endian.
Definition: OFStream.m:413
A protocol for the creation of copies.
Definition: OFObject.h:914
The root class for all other classes inside ObjFW.
Definition: OFObject.h:379
A class for storing constant strings using the @"" literal.
Definition: OFConstantString.h:37
double readLittleEndianDouble()
Reads a double from the stream which is encoded in little endian.
Definition: OFStream.m:443
float readBigEndianFloat()
Reads a float from the stream which is encoded in big endian.
Definition: OFStream.m:278
float readLittleEndianFloat()
Reads a float from the stream which is encoded in little endian.
Definition: OFStream.m:433
uint64_t readLittleEndianInt64()
Reads a uint64_t from the stream which is encoded in little endian.
Definition: OFStream.m:423
void flushWriteBuffer()
Writes everything in the write buffer to the stream.
Definition: OFStream.m:1028
uint16_t readLittleEndianInt16()
Reads a uint16_t from the stream which is encoded in little endian.
Definition: OFStream.m:403
of_string_encoding_t
The encoding of a string.
Definition: OFString.h:53
bool hasDataInReadBuffer()
Returns whether data is present in the internal read buffer.
Definition: OFStream.m:1542
bool lowlevelIsAtEndOfStream()
Returns whether the lowlevel is at the end of the stream.
Definition: OFStream.m:88
A class for storing arbitrary data in an array.
Definition: OFData.h:34
OFData * readDataUntilEndOfStream()
Returns OFData with all the remaining data of the stream.
Definition: OFStream.m:593
int fileDescriptorForReading()
Returns the file descriptor for the read end of the stream.
Definition: OFStream.m:1617
void cancelAsyncRequests()
Cancels all pending asynchronous requests on the stream.
Definition: OFStream.m:1628
This protocol is implemented by classes which can be observed for readiness for writing by OFKernelEv...
bool isBlocking()
Returns whether the stream is in blocking mode.
Definition: OFStream.m:1547
A base class for different types of streams.
Definition: OFStream.h:88
This protocol is implemented by classes which can be observed for readiness for reading by OFKernelEv...
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:848
bool(^ of_stream_async_read_line_block_t)(OFStream *stream, OFString *_Nullable line, OFException *_Nullable exception)
A block which is called when a line was read from the stream.
Definition: OFStream.h:64
bool isAtEndOfStream()
Returns a boolean whether the end of the stream has been reached.
Definition: OFStream.m:110