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

Public Member Functions

def __init__
 
def reset
 
def get_buffer
 
def pack_uint
 
def pack_bool
 
def pack_uhyper
 
def pack_float
 
def pack_double
 
def pack_fstring
 
def pack_string
 
def pack_list
 
def pack_farray
 
def pack_array
 

Static Public Attributes

 get_buf = get_buffer
 
 pack_int = pack_uint
 
 pack_enum = pack_int
 
 pack_hyper = pack_uhyper
 
 pack_fopaque = pack_fstring
 
 pack_opaque = pack_string
 
 pack_bytes = pack_string
 

Detailed Description

Pack various data representations into a buffer.

Definition at line 39 of file xdrlib.py.

Constructor & Destructor Documentation

Member Function Documentation

def get_buffer (   self)

Definition at line 48 of file xdrlib.py.

48 
49  def get_buffer(self):
return self.__buf.getvalue()
def pack_array (   self,
  list,
  pack_item 
)

Definition at line 109 of file xdrlib.py.

References Packer.pack_farray(), and Packer.pack_uint().

110  def pack_array(self, list, pack_item):
111  n = len(list)
112  self.pack_uint(n)
113  self.pack_farray(n, list, pack_item)
114 
115 
def pack_bool (   self,
  x 
)

Definition at line 59 of file xdrlib.py.

59 
60  def pack_bool(self, x):
61  if x: self.__buf.write('\0\0\0\1')
62  else: self.__buf.write('\0\0\0\0')
def pack_double (   self,
  x 
)

Definition at line 74 of file xdrlib.py.

74 
75  def pack_double(self, x):
76  try: self.__buf.write(struct.pack('>d', x))
77  except struct.error, msg:
78  raise ConversionError, msg
def pack_farray (   self,
  n,
  list,
  pack_item 
)

Definition at line 103 of file xdrlib.py.

104  def pack_farray(self, n, list, pack_item):
105  if len(list) != n:
106  raise ValueError, 'wrong array size'
107  for item in list:
108  pack_item(item)
def pack_float (   self,
  x 
)

Definition at line 69 of file xdrlib.py.

69 
70  def pack_float(self, x):
71  try: self.__buf.write(struct.pack('>f', x))
72  except struct.error, msg:
73  raise ConversionError, msg
def pack_fstring (   self,
  n,
  s 
)

Definition at line 79 of file xdrlib.py.

79 
80  def pack_fstring(self, n, s):
81  if n < 0:
82  raise ValueError, 'fstring size must be nonnegative'
83  n = ((n+3)/4)*4
84  data = s[:n]
85  data = data + (n - len(data)) * '\0'
86  self.__buf.write(data)
def pack_list (   self,
  list,
  pack_item 
)

Definition at line 97 of file xdrlib.py.

References Packer.pack_uint().

97 
98  def pack_list(self, list, pack_item):
99  for item in list:
100  self.pack_uint(1)
101  pack_item(item)
102  self.pack_uint(0)
def pack_string (   self,
  s 
)

Definition at line 89 of file xdrlib.py.

References Packer.pack_fstring(), and Packer.pack_uint().

89 
90  def pack_string(self, s):
91  n = len(s)
92  self.pack_uint(n)
93  self.pack_fstring(n, s)
def pack_uhyper (   self,
  x 
)

Definition at line 63 of file xdrlib.py.

References Packer.pack_uint().

63 
64  def pack_uhyper(self, x):
65  self.pack_uint(x>>32 & 0xffffffffL)
66  self.pack_uint(x & 0xffffffffL)
def pack_uint (   self,
  x 
)

Definition at line 53 of file xdrlib.py.

53 
54  def pack_uint(self, x):
55  self.__buf.write(struct.pack('>L', x))
def reset (   self)

Definition at line 45 of file xdrlib.py.

References Packer.__buf, and threading._StringIO.

45 
46  def reset(self):
47  self.__buf = _StringIO()

Field Documentation

get_buf = get_buffer
static

Definition at line 51 of file xdrlib.py.

pack_bytes = pack_string
static

Definition at line 95 of file xdrlib.py.

pack_enum = pack_int
static

Definition at line 57 of file xdrlib.py.

pack_fopaque = pack_fstring
static

Definition at line 87 of file xdrlib.py.

pack_hyper = pack_uhyper
static

Definition at line 67 of file xdrlib.py.

pack_int = pack_uint
static

Definition at line 56 of file xdrlib.py.

pack_opaque = pack_string
static

Definition at line 94 of file xdrlib.py.


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