ObjFW
Public Member Functions | Static Public Member Functions | Protected Attributes | Properties
OFDataArray Class Reference

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

#include <OFDataArray.h>

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

List of all members.

Public Member Functions

id initWithItemSize: (size_t is)
id initWithContentsOfFile: (OFString *path)
id initWithBase64EncodedString: (OFString *str)
size_t count ()
size_t itemSize ()
void * cArray ()
void * itemAtIndex: (size_t index)
void * firstItem ()
void * lastItem ()
void addItem: (const void *item)
void addItem:atIndex: (const void *item,[atIndex] size_t index)
void addNItems:fromCArray: (size_t nitems,[fromCArray] const void *carray)
void addNItems:fromCArray:atIndex: (size_t nitems,[fromCArray] const void *carray,[atIndex] size_t index)
void removeItemAtIndex: (size_t index)
void removeNItems: (size_t nitems)
void removeNItems:atIndex: (size_t nitems,[atIndex] size_t index)
OFStringstringByBase64Encoding ()
OFStringMD5Hash ()
OFStringSHA1Hash ()

Static Public Member Functions

id dataArrayWithItemSize: (size_t is)
id dataArrayWithContentsOfFile: (OFString *path)
id dataArrayWithBase64EncodedString: (OFString *str)

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 OFDataArray::addItem: ( const void*  item) [virtual]

Adds an item to the OFDataArray.

Parameters:
itemA pointer to an arbitrary item
void OFDataArray::addItem:atIndex: ( const void*  item,
[atIndex] size_t  index 
) [virtual]

Adds an item to the OFDataArray at the specified index.

Parameters:
itemA pointer to an arbitrary item
indexThe index where the item should be added
void OFDataArray::addNItems:fromCArray: ( size_t  nitems,
[fromCArray] const void*  carray 
) [virtual]

Adds items from a C array to the OFDataArray.

Parameters:
nitemsThe number of items to add
carrayA C array containing the items to add
void OFDataArray::addNItems:fromCArray:atIndex: ( size_t  nitems,
[fromCArray] const void*  carray,
[atIndex] size_t  index 
) [virtual]

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

Parameters:
nitemsThe number of items to add
carrayA C array containing the items to add
indexThe index where the items should be added
void * OFDataArray::cArray ( ) [virtual]
Returns:
All elements of the OFDataArray as a C array
size_t OFDataArray::count ( ) [virtual]
Returns:
The number of items in the OFDataArray
id OFDataArray::dataArrayWithBase64EncodedString: ( OFString str) [static, virtual]

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

Parameters:
strThe string with the Base64-encoded data
Returns:
A new autoreleased OFDataArray
id OFDataArray::dataArrayWithContentsOfFile: ( OFString path) [static, virtual]

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

Parameters:
pathThe path of the file
Returns:
A new autoreleased OFDataArray
id OFDataArray::dataArrayWithItemSize: ( size_t  is) [static, virtual]

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

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

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

Parameters:
strThe string with the Base64-encoded data
Returns:
A initialized OFDataArray
id OFDataArray::initWithContentsOfFile: ( OFString path) [virtual]

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

Parameters:
pathThe path of the file
Returns:
An initialized OFDataArray
id OFDataArray::initWithItemSize: ( size_t  is) [virtual]

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

Parameters:
isThe size of each element in the OFDataArray
Returns:
An initialized OFDataArray
void * OFDataArray::itemAtIndex: ( size_t  index) [virtual]

Returns a specific item of the OFDataArray.

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

Removes the item at the specified index.

Parameters:
indexThe index of the item to remove
void OFDataArray::removeNItems: ( size_t  nitems) [virtual]

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

Parameters:
nitemsThe number of items to remove
void OFDataArray::removeNItems:atIndex: ( size_t  nitems,
[atIndex] size_t  index 
) [virtual]

Removes the specified amount of items at the specified index.

Parameters:
nitemsThe number of items to remove
indexThe index at which the items are removed
OFString* OFDataArray(Hashing)::SHA1Hash ( ) [virtual]
Returns:
The SHA1 hash of the data array as an autoreleased OFString
OFString * OFDataArray::stringByBase64Encoding ( ) [virtual]
Returns:
A string containing the data in Base64 encoding

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