Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
Unpacker Class Reference

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_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_bool = unpack_int
 
 unpack_fopaque = unpack_fstring
 
 unpack_opaque = unpack_string
 
 unpack_bytes = unpack_string
 

Detailed Description

Unpacks various data representations from the given buffer.

Definition at line 116 of file xdrlib.py.

Constructor & Destructor Documentation

Member Function Documentation

def done (   self)

Definition at line 135 of file xdrlib.py.

References Packer.__buf, Unpacker.__buf, and Unpacker.__pos.

136  def done(self):
137  if self.__pos < len(self.__buf):
138  raise Error('unextracted data remains')
def get_buffer (   self)

Definition at line 132 of file xdrlib.py.

References Packer.__buf, and Unpacker.__buf.

133  def get_buffer(self):
134  return self.__buf
def get_position (   self)

Definition at line 126 of file xdrlib.py.

References Unpacker.__pos.

127  def get_position(self):
128  return self.__pos
def reset (   self,
  data 
)

Definition at line 122 of file xdrlib.py.

References Packer.__buf, Unpacker.__buf, and Unpacker.__pos.

123  def reset(self, data):
124  self.__buf = data
125  self.__pos = 0
def set_position (   self,
  position 
)

Definition at line 129 of file xdrlib.py.

References Unpacker.__pos.

130  def set_position(self, position):
131  self.__pos = position
def unpack_array (   self,
  unpack_item 
)

Definition at line 225 of file xdrlib.py.

References Unpacker.unpack_farray(), and Unpacker.unpack_uint().

226  def unpack_array(self, unpack_item):
227  n = self.unpack_uint()
228  return self.unpack_farray(n, unpack_item)
229 
230 
# test suite
def unpack_double (   self)

Definition at line 181 of file xdrlib.py.

References Packer.__buf, Unpacker.__buf, and Unpacker.__pos.

182  def unpack_double(self):
183  i = self.__pos
184  self.__pos = j = i+8
185  data = self.__buf[i:j]
186  if len(data) < 8:
187  raise EOFError
188  return struct.unpack('>d', data)[0]
def unpack_farray (   self,
  n,
  unpack_item 
)

Definition at line 219 of file xdrlib.py.

220  def unpack_farray(self, n, unpack_item):
221  list = []
222  for i in range(n):
223  list.append(unpack_item())
224  return list
def unpack_float (   self)

Definition at line 173 of file xdrlib.py.

References Packer.__buf, Unpacker.__buf, and Unpacker.__pos.

174  def unpack_float(self):
175  i = self.__pos
176  self.__pos = j = i+4
177  data = self.__buf[i:j]
178  if len(data) < 4:
179  raise EOFError
180  return struct.unpack('>f', data)[0]
def unpack_fstring (   self,
  n 
)

Definition at line 189 of file xdrlib.py.

References Packer.__buf, Unpacker.__buf, and Unpacker.__pos.

190  def unpack_fstring(self, n):
191  if n < 0:
192  raise ValueError, 'fstring size must be nonnegative'
193  i = self.__pos
194  j = i + (n+3)/4*4
195  if j > len(self.__buf):
196  raise EOFError
197  self.__pos = j
198  return self.__buf[i:i+n]
def unpack_hyper (   self)

Definition at line 167 of file xdrlib.py.

References Unpacker.unpack_uhyper().

168  def unpack_hyper(self):
169  x = self.unpack_uhyper()
170  if x >= 0x8000000000000000L:
171  x = x - 0x10000000000000000L
172  return x
def unpack_int (   self)

Definition at line 151 of file xdrlib.py.

References Packer.__buf, Unpacker.__buf, and Unpacker.__pos.

152  def unpack_int(self):
153  i = self.__pos
154  self.__pos = j = i+4
155  data = self.__buf[i:j]
156  if len(data) < 4:
157  raise EOFError
158  return struct.unpack('>l', data)[0]
def unpack_list (   self,
  unpack_item 
)

Definition at line 208 of file xdrlib.py.

References Unpacker.unpack_uint().

209  def unpack_list(self, unpack_item):
210  list = []
211  while 1:
212  x = self.unpack_uint()
213  if x == 0: break
214  if x != 1:
215  raise ConversionError, '0 or 1 expected, got ' + `x`
216  item = unpack_item()
217  list.append(item)
218  return list
def unpack_string (   self)

Definition at line 201 of file xdrlib.py.

References Unpacker.unpack_fstring(), and Unpacker.unpack_uint().

202  def unpack_string(self):
203  n = self.unpack_uint()
204  return self.unpack_fstring(n)
def unpack_uhyper (   self)

Definition at line 162 of file xdrlib.py.

References Unpacker.unpack_uint().

163  def unpack_uhyper(self):
164  hi = self.unpack_uint()
165  lo = self.unpack_uint()
166  return long(hi)<<32 | lo
def unpack_uint (   self)

Definition at line 139 of file xdrlib.py.

References Packer.__buf, Unpacker.__buf, and Unpacker.__pos.

140  def unpack_uint(self):
141  i = self.__pos
142  self.__pos = j = i+4
143  data = self.__buf[i:j]
144  if len(data) < 4:
145  raise EOFError
146  x = struct.unpack('>L', data)[0]
147  try:
148  return int(x)
149  except OverflowError:
150  return x

Field Documentation

unpack_bool = unpack_int
static

Definition at line 160 of file xdrlib.py.

unpack_bytes = unpack_string
static

Definition at line 206 of file xdrlib.py.

unpack_enum = unpack_int
static

Definition at line 159 of file xdrlib.py.

unpack_fopaque = unpack_fstring
static

Definition at line 199 of file xdrlib.py.

unpack_opaque = unpack_string
static

Definition at line 205 of file xdrlib.py.


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