ObjFW
|
00001 /* 00002 * Copyright (c) 2008, 2009, 2010, 2011 00003 * Jonathan Schleifer <js@webkeks.org> 00004 * 00005 * All rights reserved. 00006 * 00007 * This file is part of ObjFW. It may be distributed under the terms of the 00008 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in 00009 * the packaging of this file. 00010 * 00011 * Alternatively, it may be distributed under the terms of the GNU General 00012 * Public License, either version 2 or 3, which can be found in the file 00013 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this 00014 * file. 00015 */ 00016 00017 #include <stdarg.h> 00018 00019 #import "OFObject.h" 00020 #import "OFString.h" 00021 00022 @class OFDataArray; 00023 00033 @interface OFStream: OFObject 00034 { 00035 char *cache; 00036 char *wBuffer; 00037 size_t cacheLen, wBufferLen; 00038 BOOL buffersWrites; 00039 BOOL isBlocking; 00040 } 00041 00042 #ifdef OF_HAVE_PROPERTIES 00043 @property (assign, setter=setBlocking:) BOOL isBlocking; 00044 #endif 00045 00051 - (BOOL)isAtEndOfStream; 00052 00061 - (size_t)readNBytes: (size_t)size 00062 intoBuffer: (char*)buf; 00063 00077 - (void)readExactlyNBytes: (size_t)size 00078 intoBuffer: (char*)buf; 00079 00088 - (uint8_t)readInt8; 00089 00098 - (uint16_t)readBigEndianInt16; 00099 00108 - (uint32_t)readBigEndianInt32; 00109 00118 - (uint64_t)readBigEndianInt64; 00119 00128 - (uint16_t)readLittleEndianInt16; 00129 00138 - (uint32_t)readLittleEndianInt32; 00139 00148 - (uint64_t)readLittleEndianInt64; 00149 00161 - (OFDataArray*)readDataArrayWithItemSize: (size_t)itemsize 00162 andNItems: (size_t)nitems; 00163 00168 - (OFDataArray*)readDataArrayTillEndOfStream; 00169 00176 - (OFString*)readLine; 00177 00186 - (OFString*)readLineWithEncoding: (of_string_encoding_t)encoding; 00187 00195 - (OFString*)readTillDelimiter: (OFString*)delimiter; 00196 00205 - (OFString*)readTillDelimiter: (OFString*)delimiter 00206 withEncoding: (of_string_encoding_t)encoding; 00207 00211 - (BOOL)buffersWrites; 00212 00218 - (void)setBuffersWrites: (BOOL)enable; 00219 00223 - (void)flushWriteBuffer; 00224 00232 - (size_t)writeNBytes: (size_t)size 00233 fromBuffer: (const char*)buf; 00234 00240 - (void)writeInt8: (uint8_t)int8; 00241 00247 - (void)writeBigEndianInt16: (uint16_t)int16; 00248 00254 - (void)writeBigEndianInt32: (uint32_t)int32; 00255 00261 - (void)writeBigEndianInt64: (uint64_t)int64; 00262 00268 - (void)writeLittleEndianInt16: (uint16_t)int16; 00269 00275 - (void)writeLittleEndianInt32: (uint32_t)int32; 00276 00282 - (void)writeLittleEndianInt64: (uint64_t)int64; 00283 00290 - (size_t)writeDataArray: (OFDataArray*)dataarray; 00291 00298 - (size_t)writeString: (OFString*)str; 00299 00306 - (size_t)writeLine: (OFString*)str; 00307 00314 - (size_t)writeFormat: (OFString*)fmt, ...; 00315 00323 - (size_t)writeFormat: (OFString*)fmt 00324 withArguments: (va_list)args; 00325 00329 - (size_t)pendingBytes; 00330 00334 - (BOOL)isBlocking; 00335 00344 - (void)setBlocking: (BOOL)enable; 00345 00349 - (int)fileDescriptor; 00350 00354 - (void)close; 00355 @end