ObjFW  Diff

Differences From Artifact [ebbd8162b6]:

To Artifact [fbee0f546e]:


27
28
29
30
31
32
33
34

35
36
37
38
39
40

41
42
43
44
45
46
47
27
28
29
30
31
32
33

34
35
36
37
38
39

40
41
42
43
44
45
46
47







-
+





-
+







 * OFBigDataArray, which allocates the memory in pages rather than in bytes.
 *
 * For security reasons, serialization and deserialization is only implemented
 * for OFDataArrays with item size 1.
 */
@interface OFDataArray: OFObject <OFCopying, OFComparing, OFSerialization>
{
	uint8_t *data;
	uint8_t *items;
	size_t count;
	size_t itemSize;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, getter=cArray) void *data;
@property (readonly) void *items;
@property (readonly) size_t count;
@property (readonly) size_t itemSize;
#endif

/*!
 * @brief Creates a new OFDataArray with an item size of 1.
 *
149
150
151
152
153
154
155
156

157
158
159
160
161
162
163
164
165

166
167
168
169
170
171
172
149
150
151
152
153
154
155

156
157
158
159
160
161
162
163
164

165
166
167
168
169
170
171
172







-
+








-
+







 * @brief Returns the size of each item in the OFDataArray in bytes.
 *
 * @return The size of each item in the OFDataArray in bytes
 */
- (size_t)itemSize;

/*!
 * @brief Returns all elements of the OFDataArray as a C array.
 * @brief Returns all items of the OFDataArray as a C array.
 *
 * @warning The pointer is only valid until the OFDataArray is changed!
 *
 * Modifying the returned array directly is allowed and will change the contents
 * of the data array.
 *
 * @return All elements of the OFDataArray as a C array
 */
- (void*)cArray OF_RETURNS_INNER_POINTER;
- (void*)items OF_RETURNS_INNER_POINTER;

/*!
 * @brief Returns a specific item of the OFDataArray.
 *
 * @param index The number of the item to return
 * @return The specified item of the OFDataArray
 */
202
203
204
205
206
207
208
209

210
211
212


213
214
215
216
217

218
219
220
221
222
223



224
225
226
227
228
229
230
202
203
204
205
206
207
208

209
210


211
212
213
214
215
216

217
218
219
220



221
222
223
224
225
226
227
228
229
230







-
+

-
-
+
+




-
+



-
-
-
+
+
+







- (void)insertItem: (const void*)item
	   atIndex: (size_t)index;

/*!
 * @brief Adds items from a C array to the OFDataArray.
 *
 * @param count The number of items to add
 * @param cArray A C array containing the items to add
 * @param items A C array containing the items to add
 */
- (void)addItemsFromCArray: (const void*)cArray
		     count: (size_t)count;
- (void)addItems: (const void*)array
	   count: (size_t)count;

/*!
 * @brief Adds items from a C array to the OFDataArray at the specified index.
 *
 * @param cArray A C array containing the items to add
 * @param items A C array containing the items to add
 * @param index The index where the items should be added
 * @param count The number of items to add
 */
- (void)insertItemsFromCArray: (const void*)cArray
		      atIndex: (size_t)index
			count: (size_t)count;
- (void)insertItems: (const void*)items
	    atIndex: (size_t)index
	      count: (size_t)count;

/*!
 * @brief Removes the item at the specified index.
 *
 * @param index The index of the item to remove
 */
- (void)removeItemAtIndex: (size_t)index;