ObjFW
OFMutableData.h
1 /*
2  * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFData.h"
17 
18 OF_ASSUME_NONNULL_BEGIN
19 
20 @class OFString;
21 @class OFURL;
22 
28 @interface OFMutableData: OFData
29 {
30  size_t _capacity;
31  OF_RESERVE_IVARS(OFMutableData, 4)
32 }
33 
42 @property (readonly, nonatomic) void *mutableItems OF_RETURNS_INNER_POINTER;
43 
47 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *mutableFirstItem
48  OF_RETURNS_INNER_POINTER;
49 
53 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *mutableLastItem
54  OF_RETURNS_INNER_POINTER;
55 
61 + (instancetype)data;
62 
70 + (instancetype)dataWithItemSize: (size_t)itemSize;
71 
79 + (instancetype)dataWithCapacity: (size_t)capacity;
80 
89 + (instancetype)dataWithItemSize: (size_t)itemSize capacity: (size_t)capacity;
90 
96 - (instancetype)init;
97 
105 - (instancetype)initWithItemSize: (size_t)itemSize;
106 
115 - (instancetype)initWithCapacity: (size_t)capacity;
116 
126 - (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity;
127 
137 - (void *)mutableItemAtIndex: (size_t)index OF_RETURNS_INNER_POINTER;
138 
144 - (void)addItem: (const void *)item;
145 
152 - (void)insertItem: (const void *)item atIndex: (size_t)index;
153 
160 - (void)addItems: (const void *)items count: (size_t)count;
161 
169 - (void)insertItems: (const void *)items
170  atIndex: (size_t)index
171  count: (size_t)count;
172 
179 - (void)increaseCountBy: (size_t)count;
180 
186 - (void)removeItemAtIndex: (size_t)index;
187 
193 - (void)removeItemsInRange: (of_range_t)range;
194 
198 - (void)removeLastItem;
199 
203 - (void)removeAllItems;
204 
208 - (void)makeImmutable;
209 @end
210 
211 OF_ASSUME_NONNULL_END
A class for storing arbitrary data in an array.
Definition: OFData.h:40
A class for storing and manipulating arbitrary data in an array.
Definition: OFMutableData.h:29
A class for handling strings.
Definition: OFString.h:132
A class for parsing URLs and accessing parts of it.
Definition: OFURL.h:34
A range.
Definition: OFObject.h:93