Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes | Private Attributes
xdrlib.Unpacker Class Reference

List of all members.

Public Member Functions

def __init__
def reset
def get_position
def set_position
def get_buffer
def done
def unpack_uint
def unpack_int
def unpack_bool
def unpack_uhyper
def unpack_hyper
def unpack_float
def unpack_double
def unpack_fstring
def unpack_string
def unpack_list
def unpack_farray
def unpack_array

Static Public Attributes

 unpack_enum = unpack_int
 unpack_fopaque = unpack_fstring
 unpack_opaque = unpack_string
 unpack_bytes = unpack_string

Private Attributes

 __buf
 __pos

Detailed Description

Unpacks various data representations from the given buffer.

Definition at line 115 of file xdrlib.py.


Constructor & Destructor Documentation

def xdrlib.Unpacker.__init__ (   self,
  data 
)

Definition at line 118 of file xdrlib.py.

00118 
00119     def __init__(self, data):
00120         self.reset(data)

Here is the caller graph for this function:


Member Function Documentation

def xdrlib.Unpacker.done (   self)

Definition at line 134 of file xdrlib.py.

00134 
00135     def done(self):
00136         if self.__pos < len(self.__buf):
00137             raise Error('unextracted data remains')

Definition at line 131 of file xdrlib.py.

00131 
00132     def get_buffer(self):
00133         return self.__buf

Definition at line 125 of file xdrlib.py.

00125 
00126     def get_position(self):
00127         return self.__pos

def xdrlib.Unpacker.reset (   self,
  data 
)

Definition at line 121 of file xdrlib.py.

00121 
00122     def reset(self, data):
00123         self.__buf = data
00124         self.__pos = 0

Here is the caller graph for this function:

def xdrlib.Unpacker.set_position (   self,
  position 
)

Definition at line 128 of file xdrlib.py.

00128 
00129     def set_position(self, position):
00130         self.__pos = position

def xdrlib.Unpacker.unpack_array (   self,
  unpack_item 
)

Definition at line 226 of file xdrlib.py.

00226 
00227     def unpack_array(self, unpack_item):
00228         n = self.unpack_uint()
00229         return self.unpack_farray(n, unpack_item)

Here is the call graph for this function:

Definition at line 160 of file xdrlib.py.

00160 
00161     def unpack_bool(self):
00162         return bool(self.unpack_int())

Here is the call graph for this function:

Definition at line 182 of file xdrlib.py.

00182 
00183     def unpack_double(self):
00184         i = self.__pos
00185         self.__pos = j = i+8
00186         data = self.__buf[i:j]
00187         if len(data) < 8:
00188             raise EOFError
00189         return struct.unpack('>d', data)[0]

def xdrlib.Unpacker.unpack_farray (   self,
  n,
  unpack_item 
)

Definition at line 220 of file xdrlib.py.

00220 
00221     def unpack_farray(self, n, unpack_item):
00222         list = []
00223         for i in range(n):
00224             list.append(unpack_item())
00225         return list

Here is the caller graph for this function:

Definition at line 174 of file xdrlib.py.

00174 
00175     def unpack_float(self):
00176         i = self.__pos
00177         self.__pos = j = i+4
00178         data = self.__buf[i:j]
00179         if len(data) < 4:
00180             raise EOFError
00181         return struct.unpack('>f', data)[0]

def xdrlib.Unpacker.unpack_fstring (   self,
  n 
)

Definition at line 190 of file xdrlib.py.

00190 
00191     def unpack_fstring(self, n):
00192         if n < 0:
00193             raise ValueError('fstring size must be nonnegative')
00194         i = self.__pos
00195         j = i + (n+3)//4*4
00196         if j > len(self.__buf):
00197             raise EOFError
00198         self.__pos = j
00199         return self.__buf[i:i+n]

Here is the caller graph for this function:

Definition at line 168 of file xdrlib.py.

00168 
00169     def unpack_hyper(self):
00170         x = self.unpack_uhyper()
00171         if x >= 0x8000000000000000:
00172             x = x - 0x10000000000000000
00173         return x

Here is the call graph for this function:

Definition at line 150 of file xdrlib.py.

00150 
00151     def unpack_int(self):
00152         i = self.__pos
00153         self.__pos = j = i+4
00154         data = self.__buf[i:j]
00155         if len(data) < 4:
00156             raise EOFError
00157         return struct.unpack('>l', data)[0]

Here is the caller graph for this function:

def xdrlib.Unpacker.unpack_list (   self,
  unpack_item 
)

Definition at line 209 of file xdrlib.py.

00209 
00210     def unpack_list(self, unpack_item):
00211         list = []
00212         while 1:
00213             x = self.unpack_uint()
00214             if x == 0: break
00215             if x != 1:
00216                 raise ConversionError('0 or 1 expected, got %r' % (x,))
00217             item = unpack_item()
00218             list.append(item)
00219         return list

Here is the call graph for this function:

Definition at line 202 of file xdrlib.py.

00202 
00203     def unpack_string(self):
00204         n = self.unpack_uint()
00205         return self.unpack_fstring(n)

Here is the call graph for this function:

Definition at line 163 of file xdrlib.py.

00163 
00164     def unpack_uhyper(self):
00165         hi = self.unpack_uint()
00166         lo = self.unpack_uint()
00167         return int(hi)<<32 | lo

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 138 of file xdrlib.py.

00138 
00139     def unpack_uint(self):
00140         i = self.__pos
00141         self.__pos = j = i+4
00142         data = self.__buf[i:j]
00143         if len(data) < 4:
00144             raise EOFError
00145         x = struct.unpack('>L', data)[0]
00146         try:
00147             return int(x)
00148         except OverflowError:
00149             return x

Here is the caller graph for this function:


Member Data Documentation

Definition at line 122 of file xdrlib.py.

Definition at line 123 of file xdrlib.py.

Definition at line 207 of file xdrlib.py.

Definition at line 158 of file xdrlib.py.

Definition at line 200 of file xdrlib.py.

Definition at line 206 of file xdrlib.py.


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