ObjFW
OFMutableData.h
1 /*
2  * Copyright (c) 2008-2024 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 
25 @interface OFMutableData: OFData
34 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *mutableItems
35  OF_RETURNS_INNER_POINTER;
36 
40 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *mutableFirstItem
41  OF_RETURNS_INNER_POINTER;
42 
46 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *mutableLastItem
47  OF_RETURNS_INNER_POINTER;
48 
56 + (instancetype)dataWithCapacity: (size_t)capacity;
57 
66 + (instancetype)dataWithItemSize: (size_t)itemSize capacity: (size_t)capacity;
67 
76 - (instancetype)initWithCapacity: (size_t)capacity;
77 
87 - (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity;
88 
98 - (void *)mutableItemAtIndex: (size_t)index OF_RETURNS_INNER_POINTER;
99 
105 - (void)addItem: (const void *)item;
106 
113 - (void)insertItem: (const void *)item atIndex: (size_t)index;
114 
121 - (void)addItems: (const void *)items count: (size_t)count;
122 
130 - (void)insertItems: (const void *)items
131  atIndex: (size_t)index
132  count: (size_t)count;
133 
140 - (void)increaseCountBy: (size_t)count;
141 
147 - (void)removeItemAtIndex: (size_t)index;
148 
154 - (void)removeItemsInRange: (OFRange)range;
155 
159 - (void)removeLastItem;
160 
164 - (void)removeAllItems;
165 
169 - (void)makeImmutable;
170 @end
171 
172 OF_ASSUME_NONNULL_END
void * mutableLastItem
The last item of the OFMutableData or NULL.
Definition: OFMutableData.h:47
void * mutableFirstItem
The first item of the OFMutableData or NULL.
Definition: OFMutableData.h:41
void makeImmutable()
Converts the mutable data to an immutable data.
Definition: OFMutableData.m:288
void removeAllItems()
Removes all items.
Definition: OFMutableData.m:276
void * mutableItems
All items of the OFMutableData as a C array.
Definition: OFMutableData.h:35
A class for storing arbitrary data in an array.
Definition: OFData.h:41
void removeLastItem()
Removes the last item.
Definition: OFMutableData.m:266
A class for storing and manipulating arbitrary data in an array.
Definition: OFMutableData.h:25
A range.
Definition: OFObject.h:106