picofuse-objc

NXStream.h
Go to the documentation of this file.
1 
5 #pragma once
6 #include "NXHashAlgorithm.h"
7 #include <picofuse/sys.h>
8 #include <stddef.h>
9 
14 #define NXStreamEnd SYS_IOSTREAM_EOF
15 
38 @interface NXStream : NXObject {
39 @private
40  sys_iostream_t *_stream;
41  BOOL _owned;
42  NXString *_string;
43  char *_buffer;
44  int _peeked;
45 }
46 
51 + (id)streamWithString:(NXString *)string;
52 
58 + (id)streamWithCapacity:(size_t)capacity;
59 
66 + (id)streamWithBytes:(const void *)bytes length:(size_t)length;
67 
73 + (id)streamWithData:(NXData *)data;
74 
79 
84 
89 - (id)initWithString:(NXString *)string;
90 
94 - (id)initWithCapacity:(size_t)capacity;
95 
99 - (id)initWithBytes:(const void *)bytes length:(size_t)length;
100 
105 - (id)initWithStream:(sys_iostream_t *)stream;
106 
111 - (int)peek;
112 
119 - (size_t)readBytes:(void *)bytes length:(size_t)length;
120 
128 - (NXString *)readStringWithLength:(size_t)length;
129 
135 - (size_t)writeBytes:(const void *)bytes length:(size_t)length;
136 
141 - (size_t)writeString:(NXString *)string;
142 
152 - (NXString *)hashWithAlgorithm:(NXHashAlgorithm)algorithm;
153 
160 - (size_t)hashWithAlgorithm:(NXHashAlgorithm)algorithm bytes:(void *)bytes;
161 
166 - (size_t)position;
167 
176 - (BOOL)seek:(ptrdiff_t)offset relative:(BOOL)relative;
177 
185 - (BOOL)isEnded;
186 
191 - (void)close;
192 
196 - (BOOL)isClosed;
197 
198 @end
A stream of bytes, which can be read or written.
Definition: NXStream.h:38
Defines the NXHashAlgorithm type, for algorithms which hash data.
BOOL isClosed()
Returns YES if the stream has been closed.
BOOL isEnded()
Returns YES if there&#39;ll never be anything else to read, as when a network connection has been closed...
NXHashAlgorithm
Algorithms which hash data.
NXStream * standardInput()
Returns a stream for the standard input, or nil if there isn&#39;t one.
bool BOOL
A Boolean value.
Definition: runtime.h:60
void close()
Closes the stream, which can&#39;t be used after that.
A string of UTF-8 text.
Definition: NXString.h:53
The base class for objects in the Foundation framework.
Definition: NXObject.h:28
size_t position()
Returns the position from the start, or NXNotFound if the stream doesn&#39;t have one.
struct objc_object * id
A pointer to an instance of a class.
Definition: runtime.h:18
NXStream * standardOutput()
Returns a stream for the standard output, or nil if there isn&#39;t one.
Bytes, which can be added to.
Definition: NXData.h:21
int peek()
Returns the next byte, without reading it, or NXStreamEnd if there isn&#39;t one at present.