API Documentation

Serializer/Adapter/PythonPickle.php

Includes Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Serializer
subpackage
Adapter
version
$Id: PythonPickle.php 20575 2010-01-24 17:48:27Z mabe $
Classes
Zend_Serializer_Adapter_PythonPickle

Description

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Zend_Serializer_Adapter_PythonPickle

Extends from
Zend_Serializer_Adapter_AdapterAbstract
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
link
http://www.python.org
link
http://pickle-js.googlecode.com
package
Zend_Serializer
see
Phython3.1/Lib/pickle.py
see
Phython3.1/Modules/_pickle.c
subpackage
Adapter
Constants
OP_MARK
OP_STOP
OP_POP
OP_POP_MARK
OP_DUP
OP_FLOAT
OP_INT
OP_BININT
OP_BININT1
OP_LONG
OP_BININT2
OP_NONE
OP_PERSID
OP_BINPERSID
OP_REDUCE
OP_STRING
OP_BINSTRING
OP_SHORT_BINSTRING
OP_UNICODE
OP_BINUNICODE
OP_APPEND
OP_BUILD
OP_GLOBAL
OP_DICT
OP_EMPTY_DICT
OP_APPENDS
OP_GET
OP_BINGET
OP_INST
OP_LONG_BINGET
OP_LIST
OP_EMPTY_LIST
OP_OBJ
OP_PUT
OP_BINPUT
OP_LONG_BINPUT
OP_SETITEM
OP_TUPLE
OP_EMPTY_TUPLE
OP_SETITEMS
OP_BINFLOAT
OP_PROTO
OP_NEWOBJ
OP_EXT1
OP_EXT2
OP_EXT4
OP_TUPLE1
OP_TUPLE2
OP_TUPLE3
OP_NEWTRUE
OP_NEWFALSE
OP_LONG1
OP_LONG4
OP_BINBYTES
OP_SHORT_BINBYTES
Properties
$_isPhp6
$_isLittleEndian
$_quoteString
$_options
$_protocol
$_binary
$_memo
$_pickle
$_pickleLen
$_pos
$_stack
$_marker
Methods
__construct
setOption
_checkProtocolNumber
serialize
_write
_writeProto
_writeGet
_writePut
_writeNull
_writeTrue
_writeFalse
_writeInt
_writeFloat
_writeString
_writeArrayDict
_writeArrayList
_writeObject
_writeStop
_momorize
_searchMomo
_isArrayAssoc
_quoteString
unserialize
_load
_loadPut
_loadBinPut
_loadLongBinPut
_loadGet
_loadBinGet
_loadLongBinGet
_loadNone
_loadNewTrue
_loadNewFalse
_loadInt
_loadBinInt
_loadBinInt1
_loadBinInt2
_loadLong
_loadLong1
_loadLong4
_loadFloat
_loadBinFloat
_loadString
_loadBinString
_loadShortBinString
_loadBinBytes
_loadShortBinBytes
_loadUnicode
_convertMatchingUnicodeSequence2Utf8
_hex2Utf8
_loadBinUnicode
_loadMark
_loadList
_loadAppend
_loadEmptyList
_loadAppends
_loadDict
_loadSetItem
_loadEmptyDict
_loadSetItems
_loadTuple
_loadTuple1
_loadTuple2
_loadTuple3
_loadProto
_read
_readline
_unquoteString
_lastMarker
_decodeBinLong

Description

Constants

OP_MARK

 OP_MARK = '('

Details

value
(

OP_STOP

 OP_STOP = '.'

Details

value
.

OP_POP

 OP_POP = '0'

Details

value
0

OP_POP_MARK

 OP_POP_MARK = '1'

Details

value
1

OP_DUP

 OP_DUP = '2'

Details

value
2

OP_FLOAT

 OP_FLOAT = 'F'

Details

value
F

OP_INT

 OP_INT = 'I'

Details

value
I

OP_BININT

 OP_BININT = 'J'

Details

value
J

OP_BININT1

 OP_BININT1 = 'K'

Details

value
K

OP_LONG

 OP_LONG = 'L'

Details

value
L

OP_BININT2

 OP_BININT2 = 'M'

Details

value
M

OP_NONE

 OP_NONE = 'N'

Details

value
N

OP_PERSID

 OP_PERSID = 'P'

Details

value
P

OP_BINPERSID

 OP_BINPERSID = 'Q'

Details

value
Q

OP_REDUCE

 OP_REDUCE = 'R'

Details

value
R

OP_STRING

 OP_STRING = 'S'

Details

value
S

OP_BINSTRING

 OP_BINSTRING = 'T'

Details

value
T

OP_SHORT_BINSTRING

 OP_SHORT_BINSTRING = 'U'

Details

value
U

OP_UNICODE

 OP_UNICODE = 'V'

Details

value
V

OP_BINUNICODE

 OP_BINUNICODE = 'X'

Details

value
X

OP_APPEND

 OP_APPEND = 'a'

Details

value
a

OP_BUILD

 OP_BUILD = 'b'

Details

value
b

OP_GLOBAL

 OP_GLOBAL = 'c'

Details

value
c

OP_DICT

 OP_DICT = 'd'

Details

value
d

OP_EMPTY_DICT

 OP_EMPTY_DICT = '}'

Details

value
}

OP_APPENDS

 OP_APPENDS = 'e'

Details

value
e

OP_GET

 OP_GET = 'g'

Details

value
g

OP_BINGET

 OP_BINGET = 'h'

Details

value
h

OP_INST

 OP_INST = 'i'

Details

value
i

OP_LONG_BINGET

 OP_LONG_BINGET = 'j'

Details

value
j

OP_LIST

 OP_LIST = 'l'

Details

value
l

OP_EMPTY_LIST

 OP_EMPTY_LIST = ']'

Details

value
]

OP_OBJ

 OP_OBJ = 'o'

Details

value
o

OP_PUT

 OP_PUT = 'p'

Details

value
p

OP_BINPUT

 OP_BINPUT = 'q'

Details

value
q

OP_LONG_BINPUT

 OP_LONG_BINPUT = 'r'

Details

value
r

OP_SETITEM

 OP_SETITEM = 's'

Details

value
s

OP_TUPLE

 OP_TUPLE = 't'

Details

value
t

OP_EMPTY_TUPLE

 OP_EMPTY_TUPLE = ')'

Details

value
)

OP_SETITEMS

 OP_SETITEMS = 'u'

Details

value
u

OP_BINFLOAT

 OP_BINFLOAT = 'G'

Details

value
G

OP_PROTO

 OP_PROTO = '\x80'

Details

value
\x80

OP_NEWOBJ

 OP_NEWOBJ = '\x81'

Details

value
\x81

OP_EXT1

 OP_EXT1 = '\x82'

Details

value
\x82

OP_EXT2

 OP_EXT2 = '\x83'

Details

value
\x83

OP_EXT4

 OP_EXT4 = '\x84'

Details

value
\x84

OP_TUPLE1

 OP_TUPLE1 = '\x85'

Details

value
\x85

OP_TUPLE2

 OP_TUPLE2 = '\x86'

Details

value
\x86

OP_TUPLE3

 OP_TUPLE3 = '\x87'

Details

value
\x87

OP_NEWTRUE

 OP_NEWTRUE = '\x88'

Details

value
\x88

OP_NEWFALSE

 OP_NEWFALSE = '\x89'

Details

value
\x89

OP_LONG1

 OP_LONG1 = '\x8a'

Details

value
\x8a

OP_LONG4

 OP_LONG4 = '\x8b'

Details

value
\x8b

OP_BINBYTES

 OP_BINBYTES = 'B'

Details

value
B

OP_SHORT_BINBYTES

 OP_SHORT_BINBYTES = 'C'

Details

value
C

Properties

$_binary

 $_binary = 'false'

Details

visibility
protected
default
false
final
false
static
false

$_isLittleEndian

bool $_isLittleEndian = 'null'

Details

$_isLittleEndian
bool
Whether or not the system is little-endian
visibility
protected
default
null
final
false
static
true

$_isPhp6

bool $_isPhp6 = 'null'

Details

$_isPhp6
bool
Whether or not this is a PHP 6 binary
visibility
protected
default
null
final
false
static
true

$_marker

 $_marker = 'null'

Details

visibility
protected
default
null
final
false
static
false

$_memo

 $_memo = 'array'

Details

visibility
protected
default
array
final
false
static
false

$_options

array $_options = 'array'

Details

$_options
array
Default options
visibility
protected
default
array
final
false
static
false

$_pickle

 $_pickle = ''

Details

visibility
protected
default
final
false
static
false

$_pickleLen

 $_pickleLen = '0'

Details

visibility
protected
default
0
final
false
static
false

$_pos

 $_pos = '0'

Details

visibility
protected
default
0
final
false
static
false

$_protocol

 $_protocol = '0'

Details

visibility
protected
default
0
final
false
static
false

$_quoteString

array $_quoteString = 'array'

Details

$_quoteString
array
Strings representing quotes
visibility
protected
default
array
final
false
static
true

$_stack

 $_stack = 'array'

Details

visibility
protected
default
array
final
false
static
false

Methods

__construct

__construct(  $opts = array ) :

Constructor

Arguments
$opts
Details
visibility
public
final
false
static
false
link
Zend_Serializer_Adapter_AdapterAbstract::__construct()

_checkProtocolNumber

_checkProtocolNumber( int $number ) : int

Check and normalize pickle protocol number

Arguments
$number
int
Output
int
Details
visibility
protected
final
false
static
false
throws

_convertMatchingUnicodeSequence2Utf8

_convertMatchingUnicodeSequence2Utf8( array $match ) : string

Convert a unicode sequence to UTF-8

Arguments
$match
array
Output
string
Details
visibility
protected
final
false
static
false

_decodeBinLong

_decodeBinLong( string $data ) : int|float|string

Decode a binary long sequence

Arguments
$data
string
Output
int|float|string
Details
visibility
protected
final
false
static
false

_hex2Utf8

_hex2Utf8(  $hex ) : string

Convert a hex string to a UTF-8 string

Arguments
$hex
Output
string
Details
visibility
protected
final
false
static
false
throws
on unmatched unicode sequence

_isArrayAssoc

_isArrayAssoc( array $value ) : boolean

Is an array associative?

Arguments
$value
array
Output
boolean
Details
visibility
protected
final
false
static
false

_lastMarker

_lastMarker( ) : int

Return last marker position in stack

Output
int
Details
visibility
protected
final
false
static
false

_load

_load( string $op ) : void

Load a pickle opcode

Arguments
$op
string
Details
visibility
protected
final
false
static
false
throws
on invalid opcode

_loadAppend

_loadAppend( ) : void

Load an append (to list) sequence

Details
visibility
protected
final
false
static
false

_loadAppends

_loadAppends( ) : void

Load multiple append (to list) sequences at once

Details
visibility
protected
final
false
static
false

_loadBinBytes

_loadBinBytes( ) : void

Load arbitrary binary bytes

Details
visibility
protected
final
false
static
false

_loadBinFloat

_loadBinFloat( ) : void

Load a binary float value

Details
visibility
protected
final
false
static
false

_loadBinGet

_loadBinGet( ) : void

Load a binary GET operation

Details
visibility
protected
final
false
static
false
throws
on missing GET identifier

_loadBinInt

_loadBinInt( ) : void

Load a binary integer operator

Details
visibility
protected
final
false
static
false

_loadBinInt1

_loadBinInt1( ) : void

Load the first byte of a binary integer

Details
visibility
protected
final
false
static
false

_loadBinInt2

_loadBinInt2( ) : void

Load the second byte of a binary integer

Details
visibility
protected
final
false
static
false

_loadBinPut

_loadBinPut( ) : void

Load a binary PUT

Details
visibility
protected
final
false
static
false
throws
on missing stack

_loadBinString

_loadBinString( ) : void

Load a binary string

Details
visibility
protected
final
false
static
false

_loadBinUnicode

_loadBinUnicode( ) : void

Load binary unicode sequence

Details
visibility
protected
final
false
static
false

_loadDict

_loadDict( ) : void

Load an associative array (Python dictionary)

Details
visibility
protected
final
false
static
false

_loadEmptyDict

_loadEmptyDict( ) : void

Load an empty dictionary

Details
visibility
protected
final
false
static
false

_loadEmptyList

_loadEmptyList( ) : void

Load an empty list sequence

Details
visibility
protected
final
false
static
false

_loadFloat

_loadFloat( ) : void

Load a float value

Details
visibility
protected
final
false
static
false

_loadGet

_loadGet( ) : void

Load a GET operation

Details
visibility
protected
final
false
static
false
throws
on missing GET identifier

_loadInt

_loadInt( ) : void

Load an integer operator

Details
visibility
protected
final
false
static
false

_loadList

_loadList( ) : void

Load an array (list)

Details
visibility
protected
final
false
static
false

_loadLong

_loadLong( ) : void

Load a long (float) operator

Details
visibility
protected
final
false
static
false

_loadLong1

_loadLong1( ) : void

Load a one byte long integer

Details
visibility
protected
final
false
static
false

_loadLong4

_loadLong4( ) : void

Load a 4 byte long integer

Details
visibility
protected
final
false
static
false

_loadLongBinGet

_loadLongBinGet( ) : void

Load a long binary GET operation

Details
visibility
protected
final
false
static
false
throws
on missing GET identifier

_loadLongBinPut

_loadLongBinPut( ) : void

Load a long binary PUT

Details
visibility
protected
final
false
static
false
throws
on missing stack

_loadMark

_loadMark( ) : void

Load a marker sequence

Details
visibility
protected
final
false
static
false

_loadNewFalse

_loadNewFalse( ) : void

Load a boolean FALSE operator

Details
visibility
protected
final
false
static
false

_loadNewTrue

_loadNewTrue( ) : void

Load a boolean TRUE operator

Details
visibility
protected
final
false
static
false

_loadNone

_loadNone( ) : void

Load a NONE operator

Details
visibility
protected
final
false
static
false

_loadProto

_loadProto( ) : void

Load a proto value

Details
visibility
protected
final
false
static
false
throws
if Pickle version does not support this feature

_loadPut

_loadPut( ) : void

Load a PUT opcode

Details
visibility
protected
final
false
static
false
throws
on missing stack

_loadSetItem

_loadSetItem( ) : void

Load an item from a set

Details
visibility
protected
final
false
static
false

_loadSetItems

_loadSetItems( ) : void

Load set items

Details
visibility
protected
final
false
static
false

_loadShortBinBytes

_loadShortBinBytes( ) : void

Load a single binary byte

Details
visibility
protected
final
false
static
false

_loadShortBinString

_loadShortBinString( ) : void

Load a short binary string

Details
visibility
protected
final
false
static
false

_loadString

_loadString( ) : void

Load a string

Details
visibility
protected
final
false
static
false

_loadTuple

_loadTuple( ) : void

Load a tuple

Details
visibility
protected
final
false
static
false

_loadTuple1

_loadTuple1( ) : void

Load single item tuple

Details
visibility
protected
final
false
static
false

_loadTuple2

_loadTuple2( ) : void

Load two item tuple

Details
visibility
protected
final
false
static
false

_loadTuple3

_loadTuple3( ) : void

Load three item tuple

Details
visibility
protected
final
false
static
false

_loadUnicode

_loadUnicode( ) : void

Load a unicode string

Details
visibility
protected
final
false
static
false

_momorize

_momorize( mixed $value ) : void

Add a value to the memo and write the id

Arguments
$value
mixed
Details
visibility
protected
final
false
static
false

_quoteString

_quoteString( string $str ) : string

Quote/Escape a string

Arguments
$str
string
Output
string
quoted string
Details
visibility
protected
final
false
static
false

_read

_read( mixed $len ) : string

Read a segment of the pickle

Arguments
$len
mixed
Output
string
Details
visibility
protected
final
false
static
false
throws
if position matches end of data

_readline

_readline( ) : string

Read a line of the pickle at once

Output
string
Details
visibility
protected
final
false
static
false
throws
if no EOL character found

_searchMomo

_searchMomo( mixed $value ) : int|false

Search a value in the meno and return the id

Arguments
$value
mixed
Output
int|false
The id or false
Details
visibility
protected
final
false
static
false

_unquoteString

_unquoteString( string $str ) : string

Unquote/Unescape a quoted string

Arguments
$str
string
quoted string
Output
string
unquoted string
Details
visibility
protected
final
false
static
false

_write

_write( mixed $value ) : void

Write a value

Arguments
$value
mixed
Details
visibility
protected
final
false
static
false
throws
on invalid or unrecognized value type

_writeArrayDict

_writeArrayDict( array $value ) : void

Write an associative array value as dictionary

Arguments
$value
array
Details
visibility
protected
final
false
static
false

_writeArrayList

_writeArrayList( array $value ) : void

Write a simple array value as list

Arguments
$value
array
Details
visibility
protected
final
false
static
false

_writeFalse

_writeFalse( ) : void

Write a boolean false

Details
visibility
protected
final
false
static
false

_writeFloat

_writeFloat( float $value ) : void

Write a float value

Arguments
$value
float
Details
visibility
protected
final
false
static
false

_writeGet

_writeGet( int $id ) : void

Write a get

Arguments
$id
int
Id of memo
Details
visibility
protected
final
false
static
false

_writeInt

_writeInt( int $value ) : void

Write an integer value

Arguments
$value
int
Details
visibility
protected
final
false
static
false

_writeNull

_writeNull( ) : void

Write a null as None

Details
visibility
protected
final
false
static
false

_writeObject

_writeObject( object $value ) : void

Write an object as an dictionary

Arguments
$value
object
Details
visibility
protected
final
false
static
false

_writeProto

_writeProto( int $protocol ) : void

Write pickle protocol

Arguments
$protocol
int
Details
visibility
protected
final
false
static
false

_writePut

_writePut( int $id ) : void

Write a put

Arguments
$id
int
Id of memo
Details
visibility
protected
final
false
static
false

_writeStop

_writeStop( ) : void

Write stop

Details
visibility
protected
final
false
static
false

_writeString

_writeString( string $value ) : void

Write a string value

Arguments
$value
string
Details
visibility
protected
final
false
static
false

_writeTrue

_writeTrue( ) : void

Write a boolean true

Details
visibility
protected
final
false
static
false

serialize

serialize( mixed $value, array $opts = array ) : string

Serialize PHP to PythonPickle format

Arguments
$value
mixed
$opts
array
Output
string
Details
visibility
public
final
false
static
false

setOption

setOption( string $name, mixed $value ) : Zend_Serializer_Adapter_PythonPickle

Set an option

Arguments
$name
string
$value
mixed
Details
visibility
public
final
false
static
false
link
Zend_Serializer_Adapter_AdapterAbstract::setOption()

unserialize

unserialize( string $pickle, array $opts = array ) : mixed

Unserialize from Python Pickle format to PHP

Arguments
$pickle
string
$opts
array
Output
mixed
Details
visibility
public
final
false
static
false
throws
on invalid Pickle string
Documentation was generated by DocBlox.