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 
103 - initWithItemSize: (size_t)itemSize;
104 
112 - initWithContentsOfFile: (OFString*)path;
113 
121 - initWithContentsOfURL: (OFURL*)URL;
122 
130 - initWithStringRepresentation: (OFString*)string;
131 
139 - initWithBase64EncodedString: (OFString*)string;
140 
146 - (size_t)count;
147 
153 - (size_t)itemSize;
154 
165 - (void*)cArray OF_RETURNS_INNER_POINTER;
166 
173 - (void*)itemAtIndex: (size_t)index OF_RETURNS_INNER_POINTER;
174 
180 - (void*)firstItem OF_RETURNS_INNER_POINTER;
181 
187 - (void*)lastItem OF_RETURNS_INNER_POINTER;
188 
194 - (void)addItem: (const void*)item;
195 
202 - (void)insertItem: (const void*)item
203  atIndex: (size_t)index;
204 
211 - (void)addItemsFromCArray: (const void*)cArray
212  count: (size_t)count;
213 
221 - (void)insertItemsFromCArray: (const void*)cArray
222  atIndex: (size_t)index
223  count: (size_t)count;
224 
230 - (void)removeItemAtIndex: (size_t)index;
231 
237 - (void)removeItemsInRange: (of_range_t)range;
238 
242 - (void)removeLastItem;
243 
247 - (void)removeAllItems;
248 
254 - (OFString*)stringRepresentation;
255 
261 - (OFString*)stringByBase64Encoding;
262 
268 - (void)writeToFile: (OFString*)path;
269 @end
270 
278 @interface OFBigDataArray: OFDataArray
279 {
280  size_t size;
281 }
282 @end
283 
284 #import "OFDataArray+Hashing.h"