@@ -38,19 +38,10 @@ * * @brief A class for storing arbitrary data in an array. */ @interface OFData: OFObject -{ - unsigned char *_Nullable _items; - size_t _count, _itemSize; - bool _freeWhenDone; -@private - OFData *_Nullable _parentData; - OF_RESERVE_IVARS(OFData, 4) -} - /** * @brief The size of a single item in the OFData in bytes. */ @property (readonly, nonatomic) size_t itemSize; @@ -90,10 +81,25 @@ /** * @brief A string containing the data in Base64 encoding. */ @property (readonly, nonatomic) OFString *stringByBase64Encoding; +/** + * @brief Creates a new OFData that is empty with an item size of 1. + * + * @return A new autoreleased OFData + */ ++ (instancetype)data; + +/** + * @brief Creates a new OFData that is empty with the specified item size. + * + * @param itemSize The size of a single element in the OFData + * @return A new autoreleased OFData + */ ++ (instancetype)dataWithItemSize: (size_t)itemSize; + /** * @brief Creates a new OFData with the specified `count` items of size 1. * * @param items The items to store in the OFData * @param count The number of items @@ -190,10 +196,27 @@ * @throw OFInvalidFormatException The specified string is not correctly * formatted */ + (instancetype)dataWithBase64EncodedString: (OFString *)string; +/** + * @brief Initializes an already allocated OFData to be empty with an item size + * of 1. + * + * @return An initialized OFData + */ +- (instancetype)init; + +/** + * @brief Initializes an already allocated OFData to be empty with the + * specified item size. + * + * @param itemSize The size of a single element in the OFData + * @return An initialized OFData + */ +- (instancetype)initWithItemSize: (size_t)itemSize; + /** * @brief Initializes an already allocated OFData with the specified `count` * items of size 1. * * @param items The items to store in the OFData