Class CFBinaryPropertyList

Description

Facility for reading and writing binary PropertyLists. Ported from CFBinaryPList.c.

Located in /CFBinaryPropertyList.php (line 19)


	
			
Direct descendents
Class Description
CFPropertyList Property List Interface for handling reading, editing and saving Property Lists as defined by Apple.
Variable Summary
integer $countObjects
integer $intSize
integer $miscSize
integer $objectRefs
mixed $objectTable
mixed $offsets
integer $stringSize
array $uniqueTable
Method Summary
static integer binaryStrlen (string $val)
static integer bytesInt (integer $int)
static integer bytesNeeded (integer $count_objects)
static integer bytesSizeInt (integer $int)
static integer charsetStrlen (string $string, [string $charset = "UTF-8"])
static string convertCharset (string $string, string $fromCharset, [string $toCharset = 'UTF-8'])
static string intBytes (integer $int)
static mixed make64Int (int $hi, int $lo)
static string packItWithSize (integer $nbytes, integer $int)
static string typeBytes (string $type, integer $type_len)
integer arrayToBinary (CFArray $val)
integer boolToBinary (bool $val)
integer dataToBinary (string $val)
integer dateToBinary ( $val, integer $value)
integer dictToBinary (CFDictionary $val)
string intToBinary (integer $value)
integer numToBinary (numeric $value)
void readBinary (string $file)
CFArray readBinaryArray (string $fname, ressource $fd, integer $length)
CFData readBinaryData (string $fname, ressource $fd, integer $length)
CFDate readBinaryDate (string $fname, ressource $fd, integer $length)
CFDictionary readBinaryDict (string $fname, ressource $fd, integer $length)
CFNumber readBinaryInt (string $fname, ressource $fd, integer $length)
the readBinaryNullType ($length $length)
mixed readBinaryObject (string $fname, ressource $fd)
mixed readBinaryObjectAt (string $fname, ressource $fd, integer $pos)
CFNumber readBinaryReal (string $fname, ressource $fd, integer $length)
CFString readBinaryString (string $fname, ressource $fd, integer $length)
CFString readBinaryUnicodeString (string $fname, ressource $fd, integer $length)
string realToBinary (float $val)
integer stringToBinary (string $val)
string toBinary ()
void uniqueAndCountValues ($value $value)
Variables
integer $countObjects = 0 (line 30)

Number of objects in file

  • access: protected
integer $intSize = 0 (line 42)

The length of all ints in file (byte length)

  • access: protected
integer $miscSize = 0 (line 48)

The length of misc objects (i.e. not integer and not string) in file

  • access: protected
integer $objectRefs = 0 (line 54)

Number of object references in file (needed to calculate reference byte length)

  • access: protected
mixed $objectRefSize = 0 (line 70)

The size of object references

  • access: protected
mixed $objectTable = array() (line 65)

Table containing all objects in the file

  • access: protected
mixed $offsets = array() (line 75)

The „offsets” (i.e. the different entries) in the file

  • access: protected
integer $stringSize = 0 (line 36)

The length of all strings in the file (byte length, not character length)

  • access: protected
array $uniqueTable = array() (line 24)

Table containing uniqued objects

  • access: protected
integer $writtenObjectCount = 0 (line 60)

Number of objects written during save phase; needed to calculate the size of the object table

  • access: protected
Methods
static method binaryStrlen (line 718)

Counts the number of bytes the string will have when coded; utf-16be if non-ascii characters are present.

  • return: The length of the coded string in bytes
  • access: protected
static integer binaryStrlen (string $val)
  • string $val: The string value
static method bytesInt (line 506)

Calculate the byte needed for a „normal” integer value

  • return: The number of bytes needed + 1 (because of the „marker byte”)
  • access: public
static integer bytesInt (integer $int)
  • integer $int: The integer value
static method bytesNeeded (line 537)

Calculate the bytes needed to save the number of objects

  • return: The number of bytes
  • access: public
static integer bytesNeeded (integer $count_objects)
  • integer $count_objects: The number of objects
static method bytesSizeInt (line 491)

calculate the bytes needed for a size integer value

  • return: The number of bytes needed
  • access: public
static integer bytesSizeInt (integer $int)
  • integer $int: The integer value to calculate
static method charsetStrlen (line 285)

Count characters considering character set Trying to use MBString, Iconv - in that particular order.

  • return: The number of characters in that string
  • throws: PListException on neither MBString, Iconv being available
  • access: public
static integer charsetStrlen (string $string, [string $charset = "UTF-8"])
  • string $string: the string to convert
  • string $charset: the charset the given string is currently encoded in
static method convertCharset (line 269)

Convert the given string from one charset to another.

Trying to use MBString, Iconv, Recode - in that particular order.

  • return: the converted string
  • throws: PListException on neither MBString, Iconv, Recode being available
  • access: public
static string convertCharset (string $string, string $fromCharset, [string $toCharset = 'UTF-8'])
  • string $string: the string to convert
  • string $fromCharset: the charset the given string is currently encoded in
  • string $toCharset: the charset to convert to, defaults to UTF-8
static method intBytes (line 553)

Code an integer to byte representation

  • return: The packed byte value
  • access: public
static string intBytes (integer $int)
  • integer $int: The integer value
static method make64Int (line 101)

Create an 64 bit integer using bcmath or gmp

  • return: The integer (as int if possible, as string if not possible)
  • throws: PListException if neither gmp nor bc available
  • access: protected
  • usedby: CFBinaryPropertyList::readBinaryInt() - to overcome PHP's big integer problems
static mixed make64Int (int $hi, int $lo)
  • int $hi: The higher word
  • int $lo: The lower word
static method packItWithSize (line 523)

„pack” a value (i.e. write the binary representation as big endian to a string) with the specified size

  • return: The packed value as string
  • access: public
static string packItWithSize (integer $nbytes, integer $int)
  • integer $nbytes: The number of bytes to pack
  • integer $int: the integer value to pack
static method typeBytes (line 569)

Code an type byte, consisting of the type marker and the length of the type

  • return: The packed type byte value
  • access: public
static string typeBytes (string $type, integer $type_len)
  • string $type: The type byte value (i.e. "d" for dictionaries)
  • integer $type_len: The length of the type
arrayToBinary (line 884)

Convert array to binary format and add it to the object table

  • return: The position in the object table
  • access: public
integer arrayToBinary (CFArray $val)
  • CFArray $val: The array to convert
boolToBinary (line 859)

Convert a bool value to binary and add it to the object table

  • return: The position in the object table
  • access: public
integer boolToBinary (bool $val)
  • bool $val: The boolean value
dataToBinary (line 870)

Convert data value to binary format and add it to the object table

  • return: The position in the object table
  • access: public
integer dataToBinary (string $val)
  • string $val: The data value
dateToBinary (line 836)

Convert date value (apple format) to binary and adds it to the object table

  • return: The position of the coded value in the object table
  • access: public
integer dateToBinary ( $val, integer $value)
  • integer $value: The date value
  • $val
dictToBinary (line 903)

Convert dictionary to binary format and add it to the object table

  • return: The position in the object table
  • access: public
integer dictToBinary (CFDictionary $val)
intToBinary (line 769)

Codes an integer to binary format

  • return: the coded integer
  • access: protected
string intToBinary (integer $value)
  • integer $value: The integer value
numToBinary (line 820)

Converts a numeric value to binary and adds it to the object table

  • return: The position in the object table
  • access: public
integer numToBinary (numeric $value)
  • numeric $value: The numeric value
readBinary (line 442)

Read a binary plist file

  • throws: IOException if read error occurs
void readBinary (string $file)
  • string $file: The file to read
readBinaryArray (line 318)

Read an array value, including contained objects

  • return: The array value, including the objects
  • throws: IOException if read error occurs
  • access: protected
CFArray readBinaryArray (string $fname, ressource $fd, integer $length)
  • string $fname: The filename of the file we're reading from
  • ressource $fd: The file descriptor we're reading from
  • integer $length: The number of contained objects
readBinaryData (line 233)

Read a data value

  • return: The data value
  • throws: IOException if read error occurs
  • access: protected
CFData readBinaryData (string $fname, ressource $fd, integer $length)
  • string $fname: The filename of the file we're reading from
  • ressource $fd: The file descriptor we're reading from
  • integer $length: The length (in bytes) of the integer value, coded as „set bit $length to 1”
readBinaryDate (line 199)

Read a date value

  • return: The date value
  • throws: IOException if read error occurs
  • throws: PListException if date val is invalid
  • access: protected
CFDate readBinaryDate (string $fname, ressource $fd, integer $length)
  • string $fname: The filename of the file we're reading from
  • ressource $fd: The file descriptor we're reading from
  • integer $length: The length (in bytes) of the integer value, coded as „set bit $length to 1”
readBinaryDict (line 344)

Read a dictionary value, including contained objects

  • return: The dictionary value, including the objects
  • throws: IOException if read error occurs
  • access: protected
CFDictionary readBinaryDict (string $fname, ressource $fd, integer $length)
  • string $fname: The filename of the file we're reading from
  • ressource $fd: The file descriptor we're reading from
  • integer $length: The number of contained objects
readBinaryInt (line 126)

Read an integer value

  • return: The integer value
  • throws: IOException if read error occurs
  • throws: PListException if integer val is invalid
  • access: protected
  • uses: CFBinaryPropertyList::make64Int() - to overcome PHP's big integer problems
CFNumber readBinaryInt (string $fname, ressource $fd, integer $length)
  • string $fname: The filename of the file we're reading from
  • ressource $fd: The file descriptor we're reading from
  • integer $length: The length (in bytes) of the integer value, coded as „set bit $length to 1”
readBinaryNullType (line 83)

Read a „null type” (filler byte, true, false, 0 byte)

  • return: byte value (e.g. CFBoolean(true), CFBoolean(false), 0 or 15)
  • throws: PListException on encountering an unknown null type
  • access: protected
the readBinaryNullType ($length $length)
  • $length $length: The byte itself
readBinaryObject (line 374)

Read an object type byte, decode it and delegate to the correct reader function

  • return: The value of the delegate reader, so any of the CFType subclasses
  • throws: IOException if read error occurs
mixed readBinaryObject (string $fname, ressource $fd)
  • string $fname: The filename of the file we're reading from
  • ressource $fd: The file descriptor we're reading from
readBinaryObjectAt (line 430)

Read an object type byte at position $pos, decode it and delegate to the correct reader function

  • return: The value of the delegate reader, so any of the CFType subclasses
mixed readBinaryObjectAt (string $fname, ressource $fd, integer $pos)
  • string $fname: The filename of the file we're reading from
  • ressource $fd: The file descriptor we're reading from
  • integer $pos: The table position in the offsets table
readBinaryReal (line 165)

Read a real value

  • return: The real value
  • throws: IOException if read error occurs
  • throws: PListException if real val is invalid
  • access: protected
CFNumber readBinaryReal (string $fname, ressource $fd, integer $length)
  • string $fname: The filename of the file we're reading from
  • ressource $fd: The file descriptor we're reading from
  • integer $length: The length (in bytes) of the integer value, coded as „set bit $length to 1”
readBinaryString (line 250)

Read a string value, usually coded as utf8

  • return: The string value, utf8 encoded
  • throws: IOException if read error occurs
  • access: protected
CFString readBinaryString (string $fname, ressource $fd, integer $length)
  • string $fname: The filename of the file we're reading from
  • ressource $fd: The file descriptor we're reading from
  • integer $length: The length (in bytes) of the string value
readBinaryUnicodeString (line 300)

Read a unicode string value, coded as UTF-16BE

  • return: The string value, utf8 encoded
  • throws: IOException if read error occurs
  • access: protected
CFString readBinaryUnicodeString (string $fname, ressource $fd, integer $length)
  • string $fname: The filename of the file we're reading from
  • ressource $fd: The file descriptor we're reading from
  • integer $length: The length (in bytes) of the string value
realToBinary (line 810)

Codes a real value to binary format

  • return: The coded real
  • access: protected
string realToBinary (float $val)
  • float $val: The real value
stringToBinary (line 734)

Uniques and transforms a string value to binary format and adds it to the object table

  • return: The position in the object table
  • access: public
integer stringToBinary (string $val)
  • string $val: The string value
toBinary (line 662)

Convert CFPropertyList to binary format; since we have to count our objects we simply unique CFDictionary and CFArray

  • return: The binary plist content
  • access: public
string toBinary ()
uniqueAndCountValues (line 586)

Count number of objects and create a unique table for strings

  • access: protected
void uniqueAndCountValues ($value $value)
  • $value $value: The value to count and unique

Documentation generated on Fri, 01 Jan 2010 21:33:32 +0100 by phpDocumentor 1.4.1