Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
CFBinaryPropertyList Class Reference
Inheritance diagram for CFBinaryPropertyList:
CFPropertyList

Public Member Functions

 arrayToBinary ($val)
 Convert array to binary format and add it to the object table.
 
 boolToBinary ($val)
 Convert a bool value to binary and add it to the object table.
 
 dataToBinary ($val)
 Convert data value to binary format and add it to the object table.
 
 dateToBinary ($val)
 Convert date value (apple format) to binary and adds it to the object table.
 
 dictToBinary ($val)
 Convert dictionary to binary format and add it to the object table.
 
 numToBinary ($value)
 Converts a numeric value to binary and adds it to the object table.
 
 parseBinary ($content=null)
 parse a binary plist string
 
 parseBinaryString ()
 Parse a binary plist string.
 
 readBinary ($file)
 Read a binary plist file.
 
 readBinaryObject ()
 Read an object type byte, decode it and delegate to the correct reader function.
 
 readBinaryObjectAt ($pos)
 Read an object type byte at position $pos, decode it and delegate to the correct reader function.
 
 readBinaryStream ($stream)
 Read a binary plist stream.
 
 stringToBinary ($val)
 Uniques and transforms a string value to binary format and adds it to the object table.
 
 toBinary ()
 Convert CFPropertyList to binary format; since we have to count our objects we simply unique CFDictionary and CFArray.
 
 uidToBinary ($value)
 

Static Public Member Functions

static bytesInt ($int)
 Calculate the byte needed for a „normal” integer value.
 
static bytesNeeded ($count_objects)
 Calculate the bytes needed to save the number of objects.
 
static bytesSizeInt ($int)
 calculate the bytes needed for a size integer value
 
static charsetStrlen ($string, $charset="UTF-8")
 Count characters considering character set Trying to use MBString, Iconv - in that particular order.
 
static convertCharset ($string, $fromCharset, $toCharset='UTF-8')
 Convert the given string from one charset to another.
 
static intBytes ($int)
 Code an integer to byte representation.
 
static packItWithSize ($nbytes, $int)
 „pack” a value (i.e.
 
static typeBytes ($type, $type_len)
 Code an type byte, consisting of the type marker and the length of the type.
 
static unpackWithSize ($nbytes, $buff)
 „unpack” multiple values of the specified size (i.e.
 

Protected Member Functions

 intToBinary ($value)
 Codes an integer to binary format.
 
 readBinaryArray ($length)
 Read an array value, including contained objects.
 
 readBinaryData ($length)
 Read a data value.
 
 readBinaryDate ($length)
 Read a date value.
 
 readBinaryDict ($length)
 Read a dictionary value, including contained objects.
 
 readBinaryInt ($length)
 Read an integer value.
 
 readBinaryNullType ($length)
 Read a „null type” (filler byte, true, false, 0 byte)
 
 readBinaryReal ($length)
 Read a real value.
 
 readBinaryString ($length)
 Read a string value, usually coded as utf8.
 
 readBinaryUnicodeString ($length)
 Read a unicode string value, coded as UTF-16BE.
 
 realToBinary ($val)
 Codes a real value to binary format.
 
 uniqueAndCountValues ($value)
 Count number of objects and create a unique table for strings.
 

Static Protected Member Functions

static binaryStrlen ($val)
 Counts the number of bytes the string will have when coded; utf-16be if non-ascii characters are present.
 
static make64Int ($hi, $lo)
 Create an 64 bit integer using bcmath or gmp.
 

Protected Attributes

string $content = null
 Content of the plist (unparsed string)
 
integer $countObjects = 0
 Number of objects in file.
 
integer $intSize = 0
 The length of all ints in file (byte length)
 
integer $miscSize = 0
 The length of misc objects (i.e.
 
integer $objectRefs = 0
 Number of object references in file (needed to calculate reference byte length)
 
 $objectRefSize = 0
 The size of object references.
 
 $objectTable = array()
 Table containing all objects in the file.
 
 $offsets = array()
 The „offsets” (i.e.
 
integer $pos = 0
 position in the (unparsed) string
 
integer $stringSize = 0
 The length of all strings in the file (byte length, not character length)
 
array $uniqueTable = array()
 Table containing uniqued objects.
 
integer $writtenObjectCount = 0
 Number of objects written during save phase; needed to calculate the size of the object table.
 

Member Function Documentation

◆ arrayToBinary()

CFBinaryPropertyList::arrayToBinary ( $val)

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

Parameters
CFArray$valThe array to convert
Return values
integerThe position in the object table

◆ binaryStrlen()

static CFBinaryPropertyList::binaryStrlen ( $val)
staticprotected

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

Parameters
string$valThe string value
Return values
integerThe length of the coded string in bytes

◆ boolToBinary()

CFBinaryPropertyList::boolToBinary ( $val)

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

Parameters
bool$valThe boolean value
Return values
integerThe position in the object table

◆ bytesInt()

static CFBinaryPropertyList::bytesInt ( $int)
static

Calculate the byte needed for a „normal” integer value.

Parameters
integer$intThe integer value
Return values
integerThe number of bytes needed + 1 (because of the „marker byte”)

◆ bytesNeeded()

static CFBinaryPropertyList::bytesNeeded ( $count_objects)
static

Calculate the bytes needed to save the number of objects.

Parameters
integer$count_objectsThe number of objects
Return values
integerThe number of bytes

◆ bytesSizeInt()

static CFBinaryPropertyList::bytesSizeInt ( $int)
static

calculate the bytes needed for a size integer value

Parameters
integer$intThe integer value to calculate
Return values
integerThe number of bytes needed

◆ charsetStrlen()

static CFBinaryPropertyList::charsetStrlen ( $string,
$charset = "UTF-8" )
static

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

Parameters
string$stringthe string to convert
string$charsetthe charset the given string is currently encoded in
Return values
integerThe number of characters in that string
Exceptions
PListExceptionon neither MBString, Iconv being available

◆ convertCharset()

static CFBinaryPropertyList::convertCharset ( $string,
$fromCharset,
$toCharset = 'UTF-8' )
static

Convert the given string from one charset to another.

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

Parameters
string$stringthe string to convert
string$fromCharsetthe charset the given string is currently encoded in
string$toCharsetthe charset to convert to, defaults to UTF-8
Return values
stringthe converted string
Exceptions
PListExceptionon neither MBString, Iconv, Recode being available

◆ dataToBinary()

CFBinaryPropertyList::dataToBinary ( $val)

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

Parameters
string$valThe data value
Return values
integerThe position in the object table

◆ dateToBinary()

CFBinaryPropertyList::dateToBinary ( $val)

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

Parameters
integer$valueThe date value
Return values
integerThe position of the coded value in the object table

◆ dictToBinary()

CFBinaryPropertyList::dictToBinary ( $val)

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

Parameters
CFDictionary$valThe dict to convert
Return values
integerThe position in the object table

◆ intBytes()

static CFBinaryPropertyList::intBytes ( $int)
static

Code an integer to byte representation.

Parameters
integer$intThe integer value
Return values
stringThe packed byte value

◆ intToBinary()

CFBinaryPropertyList::intToBinary ( $value)
protected

Codes an integer to binary format.

Parameters
integer$valueThe integer value
Return values
stringthe coded integer

◆ make64Int()

static CFBinaryPropertyList::make64Int ( $hi,
$lo )
staticprotected

Create an 64 bit integer using bcmath or gmp.

Parameters
int$hiThe higher word
int$loThe lower word
Return values
mixedThe integer (as int if possible, as string if not possible)
Exceptions
PListExceptionif neither gmp nor bc available

◆ numToBinary()

CFBinaryPropertyList::numToBinary ( $value)

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

Parameters
numeric$valueThe numeric value
Return values
integerThe position in the object table

◆ packItWithSize()

static CFBinaryPropertyList::packItWithSize ( $nbytes,
$int )
static

„pack” a value (i.e.

write the binary representation as big endian to a string) with the specified size

Parameters
integer$nbytesThe number of bytes to pack
integer$intThe integer value to pack
Return values
stringThe packed value as string

◆ parseBinary()

CFBinaryPropertyList::parseBinary ( $content = null)

parse a binary plist string

Parameters
string$contentThe stream to read, defaults to ->content
Return values
void
Exceptions
IOExceptionif read error occurs

◆ parseBinaryString()

CFBinaryPropertyList::parseBinaryString ( )

Parse a binary plist string.

Return values
void
Exceptions
IOExceptionif read error occurs

◆ readBinary()

CFBinaryPropertyList::readBinary ( $file)

Read a binary plist file.

Parameters
string$fileThe file to read
Return values
void
Exceptions
IOExceptionif read error occurs

◆ readBinaryArray()

CFBinaryPropertyList::readBinaryArray ( $length)
protected

Read an array value, including contained objects.

Parameters
integer$lengthThe number of contained objects
Return values
CFArrayThe array value, including the objects
Exceptions
IOExceptionif read error occurs

◆ readBinaryData()

CFBinaryPropertyList::readBinaryData ( $length)
protected

Read a data value.

Parameters
integer$lengthThe length (in bytes) of the integer value, coded as „set bit $length to 1”
Return values
CFDataThe data value
Exceptions
IOExceptionif read error occurs

◆ readBinaryDate()

CFBinaryPropertyList::readBinaryDate ( $length)
protected

Read a date value.

Parameters
integer$lengthThe length (in bytes) of the integer value, coded as „set bit $length to 1”
Return values
CFDateThe date value
Exceptions
PListExceptionif date val is invalid
IOExceptionif read error occurs

◆ readBinaryDict()

CFBinaryPropertyList::readBinaryDict ( $length)
protected

Read a dictionary value, including contained objects.

Parameters
integer$lengthThe number of contained objects
Return values
CFDictionaryThe dictionary value, including the objects
Exceptions
IOExceptionif read error occurs

◆ readBinaryInt()

CFBinaryPropertyList::readBinaryInt ( $length)
protected

Read an integer value.

Parameters
integer$lengthThe length (in bytes) of the integer value, coded as „set bit $length to 1”
Return values
CFNumberThe integer value
Exceptions
PListExceptionif integer val is invalid
IOExceptionif read error occurs @uses make64Int() to overcome PHP's big integer problems

◆ readBinaryNullType()

CFBinaryPropertyList::readBinaryNullType ( $length)
protected

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

Parameters
$lengthThe byte itself
Return values
thebyte value (e.g. CFBoolean(true), CFBoolean(false), 0 or 15)
Exceptions
PListExceptionon encountering an unknown null type

◆ readBinaryObject()

CFBinaryPropertyList::readBinaryObject ( )

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

Return values
mixedThe value of the delegate reader, so any of the CFType subclasses
Exceptions
IOExceptionif read error occurs

◆ readBinaryObjectAt()

CFBinaryPropertyList::readBinaryObjectAt ( $pos)

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

Parameters
integer$posThe table position in the offsets table
Return values
mixedThe value of the delegate reader, so any of the CFType subclasses

◆ readBinaryReal()

CFBinaryPropertyList::readBinaryReal ( $length)
protected

Read a real value.

Parameters
integer$lengthThe length (in bytes) of the integer value, coded as „set bit $length to 1”
Return values
CFNumberThe real value
Exceptions
PListExceptionif real val is invalid
IOExceptionif read error occurs

◆ readBinaryStream()

CFBinaryPropertyList::readBinaryStream ( $stream)

Read a binary plist stream.

Parameters
resource$streamThe stream to read
Return values
void
Exceptions
IOExceptionif read error occurs

◆ readBinaryString()

CFBinaryPropertyList::readBinaryString ( $length)
protected

Read a string value, usually coded as utf8.

Parameters
integer$lengthThe length (in bytes) of the string value
Return values
CFStringThe string value, utf8 encoded
Exceptions
IOExceptionif read error occurs

◆ readBinaryUnicodeString()

CFBinaryPropertyList::readBinaryUnicodeString ( $length)
protected

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

Parameters
integer$lengthThe length (in bytes) of the string value
Return values
CFStringThe string value, utf8 encoded
Exceptions
IOExceptionif read error occurs

◆ realToBinary()

CFBinaryPropertyList::realToBinary ( $val)
protected

Codes a real value to binary format.

Parameters
float$valThe real value
Return values
stringThe coded real

◆ stringToBinary()

CFBinaryPropertyList::stringToBinary ( $val)

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

Parameters
string$valThe string value
Return values
integerThe position in the object table

◆ toBinary()

CFBinaryPropertyList::toBinary ( )

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

Return values
stringThe binary plist content

◆ typeBytes()

static CFBinaryPropertyList::typeBytes ( $type,
$type_len )
static

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

Parameters
string$typeThe type byte value (i.e. "d" for dictionaries)
integer$type_lenThe length of the type
Return values
stringThe packed type byte value

◆ uniqueAndCountValues()

CFBinaryPropertyList::uniqueAndCountValues ( $value)
protected

Count number of objects and create a unique table for strings.

Parameters
$valueThe value to count and unique
Return values
void

◆ unpackWithSize()

static CFBinaryPropertyList::unpackWithSize ( $nbytes,
$buff )
static

„unpack” multiple values of the specified size (i.e.

get the integers from their binary representation) from a string

Parameters
integer$nbytesThe number of bytes of each value to unpack
integer$buffThe string packed with integer values
Return values
arrayThe unpacked integers

Member Data Documentation

◆ $miscSize

integer CFBinaryPropertyList::$miscSize = 0
protected

The length of misc objects (i.e.

not integer and not string) in file

◆ $offsets

CFBinaryPropertyList::$offsets = array()
protected

The „offsets” (i.e.

the different entries) in the file


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