IDBLUE logo
Public Member Functions | Protected Attributes
CByteArray Class Reference
Inheritance diagram for CByteArray:
IDBluePacket RfidTag IDBlueCommand ByteArrayCommand ByteCommand EpcReadTagCommand EpcWriteTagCommand GetTagInfoCommand ReadBlockCommand ReadBlocksCommand SetPropertyCommand SimpleCommand StringCommand UShortCommand WriteBlockCommand WriteBlocksCommand

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

Detailed Description

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.


Member Function Documentation

- (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

Parameters:
lengththe number of bytes to allocate for the byte array
Returns:
the initialized CByteArray
- (id) initWithAsciiString: (NSString*)  s

Creates a byte array of ascii characters

Parameters:
sAn NSString containing all ASCII characters
- (id) initWithData: (const byte*)  data
withLen: (int)  len 

Initialize a CByteArray with an array of bytes

Parameters:
dataThe 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

Parameters:
hexA string containing hex values, that may contain spaces. Each hex value must be stored in 2 characters. (e.g. 00 FF 00 FF).
Returns:
The CByteArray containing each hex value in byte format if successful, nil otherwise.
- (void) reverse

Reverse the bytes in the CByteArray

- (int) setData: (CByteArray*)  data

Copy data from another CByteArray into the current CByteArray

Parameters:
dataThe CByteArray to copy data from
Returns:
the number of bytes copied.
- (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

Parameters:
dataThe data to be copied
dataLenThe number of bytes in the specified byte array
Returns:
The number of bytes copied into the current CByteArray
- (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

Parameters:
dataThe data to be copied
dataLenThe length of the byte array
indexThe index to start copying from
countThe number of bytes to copy
Returns:
the number of bytes copied
- (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.

Returns:
An NSString object containing the bytes of the byte array, displayed in hex format.
- (NSString *) toStringReversed

Convert the current CByteArray to a string, the same as toString, except the string is in reverse order.

Remarks:
Equivalet to calling reverse on the CByteArray followed by a toString

The documentation for this class was generated from the following files:

 

Generated on Mon Jan 19 2015 15:47:38
Copyright © 2015 Cathexis Innovations Inc. All Rights Reserved.