Public Member Functions | Static Public Member Functions | Protected Attributes | Properties

OFDataArray Class Reference

A class for storing arbitrary data in an array. More...

#import <OFDataArray.h>

Inheritance diagram for OFDataArray:
OFObject <OFCopying> <OFComparing> <OFObject> OFBigDataArray

List of all members.

Public Member Functions

(id) - initWithItemSize:
(id) - initWithContentsOfFile:
(id) - initWithBase64EncodedString:
(size_t) - count
(size_t) - itemSize
(void *) - cArray
(void *) - itemAtIndex:
(void *) - firstItem
(void *) - lastItem
(void) - addItem:
(void) - addItem:atIndex:
(void) - addNItems:fromCArray:
(void) - addNItems:fromCArray:atIndex:
(void) - removeItemAtIndex:
(void) - removeNItems:
(void) - removeNItems:atIndex:
(OFString *) - stringByBase64Encoding
(OFString *) - MD5Hash
(OFString *) - SHA1Hash

Static Public Member Functions

(id) + dataArrayWithItemSize:
(id) + dataArrayWithContentsOfFile:
(id) + dataArrayWithBase64EncodedString:

Protected Attributes

char * data

Properties

size_t count
size_t itemSize

Detailed Description

A class for storing arbitrary data in an array.

If you plan to store large hunks of data, you should consider using OFBigDataArray, which allocates the memory in pages rather than in bytes.


Member Function Documentation

- (void) addItem: (const void*)  item  

Adds an item to the OFDataArray.

Parameters:
item A pointer to an arbitrary item
- (void) addItem: (const void*)  item
atIndex: (size_t)  index 

Adds an item to the OFDataArray at the specified index.

Parameters:
item A pointer to an arbitrary item
index The index where the item should be added
- (void) addNItems: (size_t)  nitems
fromCArray: (const void*)  carray 

Adds items from a C array to the OFDataArray.

Parameters:
nitems The number of items to add
carray A C array containing the items to add
- (void) addNItems: (size_t)  nitems
fromCArray: (const void*)  carray
atIndex: (size_t)  index 

Adds items from a C array to the OFDataArray at the specified index.

Parameters:
nitems The number of items to add
carray A C array containing the items to add
index The index where the items should be added
- (void *) cArray  
Returns:
All elements of the OFDataArray as a C array
- (size_t) count  
Returns:
The number of items in the OFDataArray
+ (id) dataArrayWithBase64EncodedString: (OFString*)  str  

Creates a new OFDataArray with an item size of 1, containing the data of the Base64-encoded string.

Parameters:
str The string with the Base64-encoded data
Returns:
A new autoreleased OFDataArray
+ (id) dataArrayWithContentsOfFile: (OFString*)  path  

Creates a new OFDataArary with an item size of 1, containing the data of the specified file.

Parameters:
path The path of the file
Returns:
A new autoreleased OFDataArray
+ (id) dataArrayWithItemSize: (size_t)  is  

Creates a new OFDataArray whose items all have the same size.

Parameters:
is The size of each element in the OFDataArray
Returns:
A new autoreleased OFDataArray
- (void *) firstItem  
Returns:
The first item of the OFDataArray or NULL
- (id) initWithBase64EncodedString: (OFString*)  str  

Initializes an already allocated OFDataArray with an item size of 1, containing the data of the Base64-encoded string.

Parameters:
str The string with the Base64-encoded data
Returns:
A initialized OFDataArray
- (id) initWithContentsOfFile: (OFString*)  path  

Initializes an already allocated OFDataArray with an item size of 1, containing the data of the specified file.

Parameters:
path The path of the file
Returns:
An initialized OFDataArray
- (id) initWithItemSize: (size_t)  is  

Initializes an already allocated OFDataArray whose items all have the same size.

Parameters:
is The size of each element in the OFDataArray
Returns:
An initialized OFDataArray
- (void *) itemAtIndex: (size_t)  index  

Returns a specific item of the OFDataArray.

Parameters:
index The number of the item to return
Returns:
The specified item of the OFDataArray
- (size_t) itemSize  
Returns:
The size of each item in the OFDataArray in bytes
- (void *) lastItem  
Returns:
The last item of the OFDataArray or NULL
- (OFString*) MD5Hash  
Returns:
The MD5 hash of the data array as an autoreleased OFString
- (void) removeItemAtIndex: (size_t)  index  

Removes the item at the specified index.

Parameters:
index The index of the item to remove
- (void) removeNItems: (size_t)  nitems  

Removes the specified amount of items from the end of the OFDataArray.

Parameters:
nitems The number of items to remove
- (void) removeNItems: (size_t)  nitems
atIndex: (size_t)  index 

Removes the specified amount of items at the specified index.

Parameters:
nitems The number of items to remove
index The index at which the items are removed
- (OFString*) SHA1Hash  
Returns:
The SHA1 hash of the data array as an autoreleased OFString
- (OFString *) stringByBase64Encoding  
Returns:
A string containing the data in Base64 encoding

The documentation for this class was generated from the following files:
 All Classes Functions Variables