ObjFW
 All Classes Functions Variables
OFDataArray.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012
3  * Jonathan Schleifer <js@webkeks.org>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #import "OFObject.h"
18 #import "OFSerialization.h"
19 
20 @class OFString;
21 @class OFURL;
22 
33 {
34  uint8_t *data;
35  size_t count;
36  size_t itemSize;
37 }
38 
39 #ifdef OF_HAVE_PROPERTIES
40 @property (readonly, getter=cArray) void *data;
41 @property (readonly) size_t count;
42 @property (readonly) size_t itemSize;
43 #endif
44 
50 + (instancetype)dataArray;
51 
58 + (instancetype)dataArrayWithItemSize: (size_t)itemSize;
59 
67 + (instancetype)dataArrayWithContentsOfFile: (OFString*)path;
68 
76 + (instancetype)dataArrayWithContentsOfURL: (OFURL*)URL;
77 
85 + (instancetype)dataArrayWithStringRepresentation: (OFString*)string;
86 
94 + (instancetype)dataArrayWithBase64EncodedString: (OFString*)string;
95 
101 - init;
102 
110 - initWithItemSize: (size_t)itemSize;
111 
119 - initWithContentsOfFile: (OFString*)path;
120 
128 - initWithContentsOfURL: (OFURL*)URL;
129 
137 - initWithStringRepresentation: (OFString*)string;
138 
146 - initWithBase64EncodedString: (OFString*)string;
147 
153 - (size_t)count;
154 
160 - (size_t)itemSize;
161 
172 - (void*)cArray OF_RETURNS_INNER_POINTER;
173 
180 - (void*)itemAtIndex: (size_t)index OF_RETURNS_INNER_POINTER;
181 
187 - (void*)firstItem OF_RETURNS_INNER_POINTER;
188 
194 - (void*)lastItem OF_RETURNS_INNER_POINTER;
195 
201 - (void)addItem: (const void*)item;
202 
209 - (void)insertItem: (const void*)item
210  atIndex: (size_t)index;
211 
218 - (void)addItemsFromCArray: (const void*)cArray
219  count: (size_t)count;
220 
228 - (void)insertItemsFromCArray: (const void*)cArray
229  atIndex: (size_t)index
230  count: (size_t)count;
231 
237 - (void)removeItemAtIndex: (size_t)index;
238 
244 - (void)removeItemsInRange: (of_range_t)range;
245 
249 - (void)removeLastItem;
250 
254 - (void)removeAllItems;
255 
261 - (OFString*)stringRepresentation;
262 
268 - (OFString*)stringByBase64Encoding;
269 
275 - (void)writeToFile: (OFString*)path;
276 @end
277 
285 @interface OFBigDataArray: OFDataArray
286 {
287  size_t size;
288 }
289 @end
290 
291 #import "OFDataArray+Hashing.h"