CkoByteData Objective-C Reference Documentation

CkoByteData

Represents a chunk of byte data and provides methods for accessing it, adding to it, or saving and loading from files.

Properties

Methods

- (void)append:(NSData *)db

Appends byte data to the data already contained in the object.

- (void)append2:(NSData *)pByteData
    szByteData:(NSNumber *)szByteData

Appends bytes to the data already contained in the object.

- (void)appendChar:(UNKNOWN_ARG_TYPE1)[char]

Appends a single byte.

- (void)appendCharN:(UNKNOWN_ARG_TYPE1)[char]

Appends a single char N times. The equivalent of calling appendChar N times.

- (void)appendEncoded:(NSString *)str
    encoding:(NSString *)encoding

Appends binary data from an encoded string. The encoding can be "hex", "base64", "quoted-printable", or "url". The input string is decoded from the specified encoding and the binary data is appended to the calling object's content.

- (void)appendEncodedW:(UNKNOWN_ARG_TYPE1)[const wchar_t *]

To be documented soon...

- (BOOL)appendFile:(NSString *)path

Opens a file for binary read, appends the file contents, and closes the file.

- (BOOL)appendFileW:(UNKNOWN_ARG_TYPE1)[const wchar_t *]

To be documented soon...

- (void)appendInt:(NSNumber *)intValue
    littleEndian:(BOOL)littleEndian

Appends a 32-bit signed integer (4 bytes) to the data already contained in the object. littleEndian determines whether the big endian or little endian byte ordering is used.

- (void)appendRandom:(NSNumber *)numBytes

Appends numBytes random bytes to the data already contained within the object.

- (void)appendRange:(NSData *)byteData
    index:(NSNumber *)index
    numBytes:(NSNumber *)numBytes

Appends a range of bytes from byteData to the data contained withing the caller. The first byte is at index 0.

- (void)appendShort:(UNKNOWN_ARG_TYPE1)[short]

Appends a 16-bit signed integer (2 bytes) to the data already contained in the object. littleEndian determines whether the big endian or little endian byte ordering is used.

- (void)appendStr:(NSString *)str

Appends a null-terminated string to the data, without including the terminating null.

- (void)appendStrW:(UNKNOWN_ARG_TYPE1)[const wchar_t *]

To be documented soon...

- (BOOL)beginsWith:(NSData *)byteDataObj

Returns YES if the caller's data begins with the exact bytes contained within byteDataObj.

- (BOOL)beginsWith2:(NSData *)pByteData
    szByteData:(NSNumber *)szByteData

Returns YES if the caller's data begins with specified bytes.

- (void)borrowData:(UNKNOWN_ARG_TYPE1)[void *]

Sets the CkByteData's data pointer and size to memory outside the object. This is useful in cases where a CkByteData object is needed, but copying data into the CkByteData is not desired.

- (void)byteSwap4321

4321 byte swaps the data contained within the object.

- (void)clear

Clears the CkByteData object of all data.

- (void)encode:(NSString *)encoding
    str:(NSString *)str

Encodes binary data according to the encoding requested. The encoding can be specified as "hex", "base64", "url", or "quoted-printable".

- (void)encodeW:(UNKNOWN_ARG_TYPE1)[const wchar_t *]

To be documented soon...

- (void)ensureBuffer:(NSNumber *)expectedNumBytes

This method can be called to help optimize internal memory re-allocation. If, for example, many calls will be made to append data, and the total size is approximately known, then this method can be called to pre-allocate the internal buffer to the expected total size.

- (BOOL)equals:(NSData *)compareBytes

Returns YES if compareBytes contains exactly the same content as the caller. Otherwise returns NO.

- (BOOL)equals2:(NSData *)pCompareBytes
    numBytes:(NSNumber *)numBytes

Returns YES if the bytes pointed to by pCompareBytes contains exactly the same content as the caller. Otherwise returns NO.

- (NSNumber *)findBytes:(NSData *)byteDataObj

Locates the first occurance of the bytes contained in byteDataObj and returns the index of where these bytes occur in the caller's data. Returns -1 if not found.

- (NSNumber *)findBytes2:(NSData *)findBytes
    findBytesLen:(NSNumber *)findBytesLen

Locates the first occurance of the specified bytes and returns the index of where these bytes occur in the caller's data. Returns -1 if not found.

- UNKNOWN_RETURN_TYPE - (unsigned char)

Returns the Nth byte of the binary data. The 1st byte is at index 0.

- UNKNOWN_RETURN_TYPE - (const unsigned char *)

Returns a pointer to the bytes contained within the object. Be very careful with the pointer that is returned. If more data is appended to the object, an internal reallocation may occur such that the previously returned pointer is no longer valid.

- UNKNOWN_RETURN_TYPE - (char)

Returns the Nth byte of the binary content as a "char". The 1st byte is at index 0.

- UNKNOWN_RETURN_TYPE - (const unsigned char *)

Returns a pointer to the internal buffer. Be careful with this method because if additional data is appended, the data within the object may be relocated and the pointer may cease to be valid.

- UNKNOWN_RETURN_TYPE - (const unsigned char *)

Same as getData, except it gets a pointer to the data at a byte offset. (0 = the start of buffer)

- UNKNOWN_RETURN_TYPE - (const wchar_t *)

To be documented soon...

- (NSNumber *)getInt:(NSNumber *)byteIndex

Returns the 4-byte integer located at a specific byte index.

- UNKNOWN_RETURN_TYPE - (const unsigned char *)

Copies a range of bytes to a separate internal memory buffer and returns the pointer to the bytes. The returned pointer is only valid while the object exists. Also, any subsequent calls to getRange, getRangeStr, or to_s will invalidate the buffer.

- UNKNOWN_RETURN_TYPE - (short)

Returns the 2-byte integer located at a specific byte index.

- (NSNumber *)getSize

Returns the number of bytes in the data buffer.

- UNKNOWN_RETURN_TYPE - (unsigned int)

Returns the 4-byte unsigned integer located at a specific byte index.

- (NSNumber *)getUShort:(NSNumber *)byteIndex

Returns the 2-byte unsigned integer located at a specific byte index.

- (BOOL)is7bit

Returns YES if all the bytes are in the range 0x00 to 0x7F.

- (BOOL)loadFile:(NSString *)path

Equivalent to clear() followed by appendFile().

- (BOOL)loadFileW:(UNKNOWN_ARG_TYPE1)[const wchar_t *]

To be documented soon...

- (void)pad:(NSNumber *)blockSize
    paddingScheme:(NSNumber *)paddingScheme

Pads the data to a multiple of the blockSize using a cryptographic padding scheme specified by paddingScheme. The possible integer values for paddingScheme are the same as those listed for the PaddingScheme property of the CkCrypt2 class.

- (BOOL)preAllocate:(NSNumber *)expectedNumBytes

This method can be called to help optimize internal memory re-allocation. If, for example, many calls will be made to append data, and the total size is approximately known, then this method can be called to pre-allocate the internal buffer to the expected total size.

- (void)removeChunk:(NSNumber *)startIndex
    numBytes:(NSNumber *)numBytes

Removes (discards) a range from the data.

- UNKNOWN_RETURN_TYPE - (unsigned char *)

Removes the data from the CkByteData object. The caller will receivea pointer to the memory buffer, and is responsible for deleting it.
Example:
unsigned char *data = byteData.removeData();
... do something with the data....
delete [] data;

- (void)replaceChar:(UNKNOWN_ARG_TYPE1)[unsigned char]

Replaces all occurances of existingByteValue with replacementByteValue.

- (BOOL)saveFile:(NSString *)path

Saves the byte data to a file. If the file already exists, it will be overwritten.

- (BOOL)saveFileW:(UNKNOWN_ARG_TYPE1)[const wchar_t *]

To be documented soon...

- (void)shorten:(NSNumber *)numBytes

Discards N bytes from the end of the data.

- UNKNOWN_RETURN_TYPE - (const wchar_t *)

To be documented soon...

- (void)unpad:(NSNumber *)blockSize
    paddingScheme:(NSNumber *)paddingScheme

Unpads the data from a multiple of the blockSize to the original data size using a cryptographic padding scheme specified by paddingScheme. The possible integer values for paddingScheme are the same as those listed for the PaddingScheme property of the CkCrypt2 class.