CkByteData Perl Programming
Reference Documentation

CkByteData

* This is a freeware class/component/library.

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

Properties

# Returns a boolean value
get_Utf8( )

# b is a boolean (input)
put_Utf8( b )

When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.

Methods

# data is a string (input)
# numBytes is an integer (input)
append( data, numBytes )

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

# ch is a char (input)
appendChar( ch )

Appends a single byte.

# str is a string (input)
# encoding is a string (input)
appendEncoded( str, 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.

# filename is a string (input)
# Returns a boolean value
appendFile( filename )

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

# v is an integer (input)
# littleEndian is a boolean (input)
appendInt( v, littleEndian )

To be documented soon...

# byteData is a CkByteData object (input)
# index is an integer (input)
# numBytes is an integer (input)
appendRange( byteData, index, numBytes )

To be documented soon...

# littleEndian is a boolean (input)
appendShort( v, littleEndian )

To be documented soon...

# str is a string (input)
appendStr( str )

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

# byteData is a CkByteData object (input)
# Returns a boolean value
beginsWith( byteData )

To be documented soon...

# byteData is a string (input)
# byteDataLen is an integer (input)
# Returns a boolean value
beginsWith2( byteData, byteDataLen )

To be documented soon...

byteSwap4321( )

To be documented soon...

clear( )

Clears the CkByteData object of all data.

# encoding is a string (input)
# str is a CkString object (output)
encode( encoding, str )

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

Returns 1 for success, 0 for failure.

# numBytes is an integer (input)
ensureBuffer( numBytes )

To be documented soon...

# byteData is a CkByteData object (input)
# Returns an integer value
findBytes( byteData )

To be documented soon...

# byteData is a string (input)
# byteDataLen is an integer (input)
# Returns an integer value
findBytes2( byteData, byteDataLen )

To be documented soon...

# byteIndex is an integer (input)
# Returns a byte
getByte( byteIndex )

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

getBytes( )

To be documented soon...

# byteIndex is an integer (input)
# Returns a char
getChar( byteIndex )

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

getData( )

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.

# encoding is a string (input)
# Returns a string
getEncoded( encoding )

To be documented soon...

# encoding is a string (input)
# index is an integer (input)
# numBytes is an integer (input)
# Returns a string
getEncodedRange( encoding, index, numBytes )

To be documented soon...

# byteIndex is an integer (input)
# Returns an integer value
getInt( byteIndex )

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

# index is an integer (input)
# numBytes is an integer (input)
# Returns a byte array
getRange( index, numBytes )

To be documented soon...

# index is an integer (input)
# numAnsiChars is an integer (input)
# Returns a string
getRangeStr( index, numAnsiChars )

To be documented soon...

# byteIndex is an integer (input)
# Returns an integer value
getShort( byteIndex )

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

# Returns an integer value
getSize( )

Returns the number of bytes in the data buffer.

# byteIndex is an integer (input)
# Returns an integer value
getUInt( byteIndex )

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

# byteIndex is an integer (input)
# Returns an integer value
getUShort( byteIndex )

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

# Returns a boolean value
is7bit( )

To be documented soon...

# filename is a string (input)
# Returns a boolean value
loadFile( filename )

Equivalent to clear() followed by appendFile().

# blockSize is an integer (input)
# paddingScheme is an integer (input)
pad( blockSize, paddingScheme )

To be documented soon...

# index is an integer (input)
# numBytes is an integer (input)
removeChunk( index, numBytes )

To be documented soon...

# filename is a string (input)
# Returns a boolean value
saveFile( filename )

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

# numBytes is an integer (input)
shorten( numBytes )

Discards N bytes from the end of the data.

# Returns a string
to_s( )

To be documented soon...

# blockSize is an integer (input)
# paddingScheme is an integer (input)
unpad( blockSize, paddingScheme )

To be documented soon...