![]() |
Public Member Functions | |
(id) | - initWithArrayLength: |
(id) | - initWithData:withLen: |
(id) | - initWithAsciiString: |
(id) | - initWithHexString: |
(int) | - arrayLength |
(byte *) | - data |
(int) | - setData:withDataLen: |
(int) | - setData:withDataLen:withIndex:withCount: |
(int) | - setData: |
(NSString *) | - toString |
(NSString *) | - toStringReversed |
(void) | - reverse |
Protected Attributes | |
int | _length |
byte * | _data |
CByteArray is used to encapsulate a C pointer to an array of bytes (byte*), handling dynamically creating memory for the array, and freeing the allocated array when the class is dealllocated.
- (int) arrayLength |
Gets the length of the byte array
- (byte *) data |
Gets the pointer to the byte array
- (id) initWithArrayLength: | (int) | length |
Initialize the current CByteArray
length | the number of bytes to allocate for the byte array |
- (id) initWithAsciiString: | (NSString*) | s |
Creates a byte array of ascii characters
s | An NSString containing all ASCII characters |
- (id) initWithData: | (const byte*) | data | |
withLen: | (int) | len | |
Initialize a CByteArray with an array of bytes
data | The pointer to the data to be set The number of bytes to copy |
- (id) initWithHexString: | (NSString*) | hex |
Initialize a CByteArray from a string of hex bytes
hex | A string containing hex values, that may contain spaces. Each hex value must be stored in 2 characters. (e.g. 00 FF 00 FF). |
- (void) reverse |
Reverse the bytes in the CByteArray
- (int) setData: | (CByteArray*) | data |
Copy data from another CByteArray into the current CByteArray
data | The CByteArray to copy data from |
- (int) setData: | (const byte*) | data | |
withDataLen: | (int) | dataLen | |
Copy the given data into the current CByteArray replacing the old data with the new data and length
data | The data to be copied |
dataLen | The number of bytes in the specified byte array |
- (int) setData: | (const byte*) | data | |
withDataLen: | (int) | dataLen | |
withIndex: | (int) | index | |
withCount: | (int) | count | |
Copy a portion of the given data array into the current CByteArray replacing the old data with the new data and length
data | The data to be copied |
dataLen | The length of the byte array |
index | The index to start copying from |
count | The number of bytes to copy |
- (NSString *) toString |
Convert to the current CByteArray to a string, where each byte is represented as it's 2 character hex equivalent, separated by spaces.
- (NSString *) toStringReversed |
Convert the current CByteArray to a string, the same as toString, except the string is in reverse order.