Differences From Artifact [4b47d7e261]:
- File
src/OFMutableData.h
— part of check-in
[ef614a225d]
at
2020-09-26 21:58:39
on branch trunk
— Don't require __COUNTER__ for OF_RESERVE_IVARS
__COUNTER__ does not exist in GCC 4.2, and Apple GCC 4.2 is still the
newest compiler available for macOS 10.5. (user: js, size: 5988) [annotate] [blame] [check-ins using]
To Artifact [1a536a9853]:
- File src/OFMutableData.h — part of check-in [163a4a5a2e] at 2020-10-03 11:35:41 on branch trunk — Use /** */ instead of /*! */ for documentation (user: js, size: 5988) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
18 19 20 21 22 23 24 | #import "OFData.h" OF_ASSUME_NONNULL_BEGIN @class OFString; @class OFURL; | | | | | | | | | | | | | | | | | | | | | | | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | #import "OFData.h" OF_ASSUME_NONNULL_BEGIN @class OFString; @class OFURL; /** * @class OFMutableData OFMutableData.h ObjFW/OFMutableData.h * * @brief A class for storing and manipulating arbitrary data in an array. */ @interface OFMutableData: OFData { size_t _capacity; OF_RESERVE_IVARS(OFMutableData, 4) } /** * @brief All items of the OFMutableData as a C array. * * @warning The pointer is only valid until the OFMutableData is changed! * * Modifying the returned array directly is allowed and will change the contents * of the data. */ @property (readonly, nonatomic) void *mutableItems OF_RETURNS_INNER_POINTER; /** * @brief The first item of the OFMutableData or `NULL`. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *mutableFirstItem OF_RETURNS_INNER_POINTER; /** * @brief The last item of the OFMutableData or `NULL`. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *mutableLastItem OF_RETURNS_INNER_POINTER; /** * @brief Creates a new OFMutableData with an item size of 1. * * @return A new autoreleased OFMutableData */ + (instancetype)data; /** * @brief Creates a new OFMutableData whose items all have the same specified * size. * * @param itemSize The size of a single element in the OFMutableData * @return A new autoreleased OFMutableData */ + (instancetype)dataWithItemSize: (size_t)itemSize; /** * @brief Creates a new OFMutableData with enough memory to hold the specified * number of items which all have an item size of 1. * * @param capacity The initial capacity for the OFMutableData * @return A new autoreleased OFMutableData */ + (instancetype)dataWithCapacity: (size_t)capacity; /** * @brief Creates a new OFMutableData with enough memory to hold the specified * number of items which all have the same specified size. * * @param itemSize The size of a single element in the OFMutableData * @param capacity The initial capacity for the OFMutableData * @return A new autoreleased OFMutableData */ + (instancetype)dataWithItemSize: (size_t)itemSize capacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableData with an item size of 1. * * @return An initialized OFMutableData */ - (instancetype)init; /** * @brief Initializes an already allocated OFMutableData whose items all have * the same size. * * @param itemSize The size of a single element in the OFMutableData * @return An initialized OFMutableData */ - (instancetype)initWithItemSize: (size_t)itemSize; /** * @brief Initializes an already allocated OFMutableData with enough memory to * hold the the specified number of items which all have an item size of * 1. * * @param capacity The initial capacity for the OFMutableData * @return An initialized OFMutableData */ - (instancetype)initWithCapacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableData with enough memory to * hold the the specified number of items which all have the same * specified size. * * @param itemSize The size of a single element in the OFMutableData * @param capacity The initial capacity for the OFMutableData * @return An initialized OFMutableData */ - (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity; /** * @brief Returns a specific item of the OFMutableData. * * Modifying the returned item directly is allowed and will change the contents * of the data. * * @param index The number of the item to return * @return The specified item of the OFMutableData */ - (void *)mutableItemAtIndex: (size_t)index OF_RETURNS_INNER_POINTER; /** * @brief Adds an item to the OFMutableData. * * @param item A pointer to an arbitrary item */ - (void)addItem: (const void *)item; /** * @brief Adds an item to the OFMutableData at the specified index. * * @param item A pointer to an arbitrary item * @param index The index where the item should be added */ - (void)insertItem: (const void *)item atIndex: (size_t)index; /** * @brief Adds items from a C array to the OFMutableData. * * @param items A C array containing the items to add * @param count The number of items to add */ - (void)addItems: (const void *)items count: (size_t)count; /** * @brief Adds items from a C array to the OFMutableData at the specified index. * * @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)insertItems: (const void *)items atIndex: (size_t)index count: (size_t)count; /** * @brief Increases the count by the specified number. The new items are all * filled with null bytes. * * @param count The count by which to increase the count */ - (void)increaseCountBy: (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; /** * @brief Removes the specified amount of items at the specified index. * * @param range The range of items to remove */ - (void)removeItemsInRange: (of_range_t)range; /** * @brief Removes the last item. */ - (void)removeLastItem; /** * @brief Removes all items. */ - (void)removeAllItems; /** * @brief Converts the mutable URL to an immutable URL. */ - (void)makeImmutable; @end OF_ASSUME_NONNULL_END |