picofuse-objc

NXArchive.h
Go to the documentation of this file.
1 
6 #pragma once
7 #include <stdint.h>
8 
13 typedef enum {
17 
18 @class NXArchive;
19 
29 @protocol NXArchiving
30 
35 - (BOOL)encodeWithArchive:(NXArchive *)archive;
36 
42 - (id)initWithArchive:(NXArchive *)archive;
43 
44 @end
45 
77 @interface NXArchive : NXObject {
78 @private
79  NXStream *_stream;
80  BOOL _encoding;
81  unsigned _indent;
82  unsigned _maxDepth;
83  size_t _maxLength;
84  NXString *_failure;
85  void *_levels;
86  unsigned _depth;
87  Class _class;
88  id _root;
89  id _current;
90  BOOL _read;
91  NXArchiveFormat _format;
92  BOOL _top;
93  BOOL _given;
94 }
95 
101 + (id)JSONEncoderWithStream:(NXStream *)stream indent:(unsigned)indent;
102 
107 + (id)JSONDecoderWithStream:(NXStream *)stream;
108 
113 + (id)JSONDecoderWithObject:(id)object;
114 
118 + (id)binaryEncoderWithStream:(NXStream *)stream;
119 
124 + (id)binaryDecoderWithStream:(NXStream *)stream;
125 
130 + (BOOL)encodeObject:(id)object toStream:(NXStream *)stream format:(NXArchiveFormat)format;
131 
140 + (id)decodeObjectOfClass:(Class)cls
141  fromStream:(NXStream *)stream
143 
148 
152 - (BOOL)isEncoding;
153 
157 - (BOOL)failed;
158 
162 - (NXString *)failure;
163 
168 - (void)failWithReason:(NXString *)reason;
169 
174 - (void)setMaximumDepth:(unsigned)depth;
175 
181 - (void)setMaximumLength:(size_t)length;
182 
188 - (BOOL)encodeBool:(BOOL)value forKey:(NXString *)key;
189 - (BOOL)encodeInt32:(int32_t)value forKey:(NXString *)key;
190 - (BOOL)encodeInt64:(int64_t)value forKey:(NXString *)key;
191 - (BOOL)encodeUnsignedInt32:(uint32_t)value forKey:(NXString *)key;
192 - (BOOL)encodeUnsignedInt64:(uint64_t)value forKey:(NXString *)key;
193 - (BOOL)encodeFloat32:(float)value forKey:(NXString *)key;
194 - (BOOL)encodeFloat64:(double)value forKey:(NXString *)key;
195 
201 - (BOOL)encodeObject:(id)object forKey:(NXString *)key;
202 
207 - (BOOL)encodeObject:(id)object asClass:(Class)cls forKey:(NXString *)key;
208 
213 - (BOOL)containsKey:(NXString *)key;
214 
220 - (BOOL)decodeBoolForKey:(NXString *)key;
221 - (int32_t)decodeInt32ForKey:(NXString *)key;
222 - (int64_t)decodeInt64ForKey:(NXString *)key;
223 - (uint32_t)decodeUnsignedInt32ForKey:(NXString *)key;
224 - (uint64_t)decodeUnsignedInt64ForKey:(NXString *)key;
225 - (float)decodeFloat32ForKey:(NXString *)key;
226 - (double)decodeFloat64ForKey:(NXString *)key;
227 
236 - (id)decodeObjectOfClass:(Class)cls forKey:(NXString *)key;
237 
242 - (NXArray *)decodeArrayOfClass:(Class)cls forKey:(NXString *)key;
243 
248 - (NXMap *)decodeMapOfClass:(Class)cls forKey:(NXString *)key;
249 
250 @end
A stream of bytes, which can be read or written.
Definition: NXStream.h:38
Objects found by keys, which can be changed.
Definition: NXMap.h:31
Objects which can be written to an archive and read back.
Definition: NXArchive.h:29
BOOL isEncoding()
Returns YES if it writes, or NO if it reads.
BOOL failed()
Returns YES if there&#39;s been an error.
bool BOOL
A Boolean value.
Definition: runtime.h:60
A string of UTF-8 text.
Definition: NXString.h:53
An ordered list of objects, which can be changed.
Definition: NXArray.h:26
struct objc_class * Class
A pointer to a class definition.
Definition: runtime.h:28
The base class for objects in the Foundation framework.
Definition: NXObject.h:28
Values in order, little-endian, with a hash of each class.
Definition: NXArchive.h:15
NXString * failure()
Returns what the first error was, or nil if there hasn&#39;t been one.
struct objc_object * id
A pointer to an instance of a class.
Definition: runtime.h:18
NXArchiveFormat
The formats of an archive.
Definition: NXArchive.h:13
JSON, with keys, and no classes unless they differ.
Definition: NXArchive.h:14
Writes objects out as JSON or binary, and reads them back.
Definition: NXArchive.h:77
NXArchiveFormat format()
Returns the format.