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 *_readBuffer, *_readBufferMemory, *_writeBuffer;
98 size_t _readBufferLength, _writeBufferLength;
99 bool _writeBuffered, _waitingForDelimiter;
125 - (size_t)readIntoBuffer: (
void *)buffer
126 length: (size_t)length;
143 - (void)readIntoBuffer: (
void *)buffer
144 exactLength: (size_t)length;
146 #ifdef OF_HAVE_SOCKETS 174 - (void)asyncReadIntoBuffer: (
void *)buffer
175 length: (size_t)length
177 selector: (SEL)selector;
204 - (void)asyncReadIntoBuffer: (
void *)buffer
205 exactLength: (size_t)length
207 selector: (SEL)selector;
209 # ifdef OF_HAVE_BLOCKS 233 - (void)asyncReadIntoBuffer: (
void *)buffer
234 length: (size_t)length
258 - (void)asyncReadIntoBuffer: (
void *)buffer
259 exactLength: (size_t)length
336 - (size_t)readBigEndianInt16sIntoBuffer: (uint16_t *)buffer
337 count: (size_t)count;
351 - (size_t)readBigEndianInt32sIntoBuffer: (uint32_t *)buffer
352 count: (size_t)count;
366 - (size_t)readBigEndianInt64sIntoBuffer: (uint64_t *)buffer
367 count: (size_t)count;
381 - (size_t)readBigEndianFloatsIntoBuffer: (
float *)buffer
382 count: (size_t)count;
396 - (size_t)readBigEndianDoublesIntoBuffer: (
double *)buffer
397 count: (size_t)count;
461 - (size_t)readLittleEndianInt16sIntoBuffer: (uint16_t *)buffer
462 count: (size_t)count;
476 - (size_t)readLittleEndianInt32sIntoBuffer: (uint32_t *)buffer
477 count: (size_t)count;
491 - (size_t)readLittleEndianInt64sIntoBuffer: (uint64_t *)buffer
492 count: (size_t)count;
506 - (size_t)readLittleEndianFloatsIntoBuffer: (
float *)buffer
507 count: (size_t)count;
521 - (size_t)readLittleEndianDoublesIntoBuffer: (
double *)buffer
522 count: (size_t)count;
534 - (
OFData *)readDataWithCount: (
size_t)count;
547 - (
OFData *)readDataWithItemSize: (
size_t)itemSize
548 count: (size_t)count;
572 - (
OFString *)readStringWithLength: (
size_t)length;
589 - (
OFString *)readStringWithLength: (
size_t)length
610 #ifdef OF_HAVE_SOCKETS 627 - (void)asyncReadLineWithTarget: (
id)target
628 selector: (SEL)selector;
649 selector: (
SEL)selector;
651 # ifdef OF_HAVE_BLOCKS 764 - (void)setWriteBuffered: (
bool)enable;
777 - (void)writeBuffer: (
const void *)buffer
778 length: (size_t)length;
785 - (void)writeInt8: (uint8_t)int8;
792 - (void)writeBigEndianInt16: (uint16_t)int16;
799 - (void)writeBigEndianInt32: (uint32_t)int32;
806 - (void)writeBigEndianInt64: (uint64_t)int64;
813 - (void)writeBigEndianFloat: (
float)float_;
820 - (void)writeBigEndianDouble: (
double)double_;
831 - (size_t)writeBigEndianInt16s: (
const uint16_t *)buffer
832 count: (size_t)count;
843 - (size_t)writeBigEndianInt32s: (
const uint32_t *)buffer
844 count: (size_t)count;
855 - (size_t)writeBigEndianInt64s: (
const uint64_t *)buffer
856 count: (size_t)count;
867 - (size_t)writeBigEndianFloats: (
const float *)buffer
868 count: (size_t)count;
879 - (size_t)writeBigEndianDoubles: (
const double *)buffer
880 count: (size_t)count;
887 - (void)writeLittleEndianInt16: (uint16_t)int16;
894 - (void)writeLittleEndianInt32: (uint32_t)int32;
901 - (void)writeLittleEndianInt64: (uint64_t)int64;
908 - (void)writeLittleEndianFloat: (
float)float_;
915 - (void)writeLittleEndianDouble: (
double)double_;
926 - (size_t)writeLittleEndianInt16s: (
const uint16_t *)buffer
927 count: (size_t)count;
938 - (size_t)writeLittleEndianInt32s: (
const uint32_t *)buffer
939 count: (size_t)count;
950 - (size_t)writeLittleEndianInt64s: (
const uint64_t *)buffer
951 count: (size_t)count;
962 - (size_t)writeLittleEndianFloats: (
const float *)buffer
963 count: (size_t)count;
974 - (size_t)writeLittleEndianDoubles: (
const double *)buffer
975 count: (size_t)count;
983 - (size_t)writeData: (
OFData *)data;
991 - (size_t)writeString: (
OFString *)string;
1001 - (size_t)writeString: (
OFString *)
string 1010 - (size_t)writeLine: (
OFString *)string;
1020 - (size_t)writeLine: (
OFString *)
string 1047 arguments: (va_list)arguments;
1071 - (void)setBlocking: (
bool)enable;
1087 #ifdef OF_HAVE_SOCKETS 1115 - (void)unreadFromBuffer: (
const void *)buffer
1116 length: (size_t)length;
1137 - (size_t)lowlevelReadIntoBuffer: (
void *)buffer
1138 length: (size_t)length;
1151 - (void)lowlevelWriteBuffer: (
const void *)buffer
1152 length: (size_t)length;
1167 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:912
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