Back to index

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

List of all members.

Public Member Functions

def __init__
def reset
def get_buffer
def pack_uint
def pack_int
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_enum = pack_int
 pack_hyper = pack_uhyper
 pack_fopaque = pack_fstring
 pack_opaque = pack_string
 pack_bytes = pack_string

Private Attributes

 __buf

Detailed Description

Pack various data representations into a buffer.

Definition at line 36 of file xdrlib.py.


Constructor & Destructor Documentation

def xdrlib.Packer.__init__ (   self)

Definition at line 39 of file xdrlib.py.

00039 
00040     def __init__(self):
00041         self.reset()

Here is the caller graph for this function:


Member Function Documentation

def xdrlib.Packer.get_buffer (   self)

Definition at line 45 of file xdrlib.py.

00045 
00046     def get_buffer(self):
        return self.__buf.getvalue()
def xdrlib.Packer.pack_array (   self,
  list,
  pack_item 
)

Definition at line 108 of file xdrlib.py.

00108 
00109     def pack_array(self, list, pack_item):
00110         n = len(list)
00111         self.pack_uint(n)
00112         self.pack_farray(n, list, pack_item)
00113 
00114 

Here is the call graph for this function:

def xdrlib.Packer.pack_bool (   self,
  x 
)

Definition at line 58 of file xdrlib.py.

00058 
00059     def pack_bool(self, x):
00060         if x: self.__buf.write(b'\0\0\0\1')
00061         else: self.__buf.write(b'\0\0\0\0')

def xdrlib.Packer.pack_double (   self,
  x 
)

Definition at line 73 of file xdrlib.py.

00073 
00074     def pack_double(self, x):
00075         try: self.__buf.write(struct.pack('>d', x))
00076         except struct.error as msg:
00077             raise ConversionError(msg)

def xdrlib.Packer.pack_farray (   self,
  n,
  list,
  pack_item 
)

Definition at line 102 of file xdrlib.py.

00102 
00103     def pack_farray(self, n, list, pack_item):
00104         if len(list) != n:
00105             raise ValueError('wrong array size')
00106         for item in list:
00107             pack_item(item)

Here is the caller graph for this function:

def xdrlib.Packer.pack_float (   self,
  x 
)

Definition at line 68 of file xdrlib.py.

00068 
00069     def pack_float(self, x):
00070         try: self.__buf.write(struct.pack('>f', x))
00071         except struct.error as msg:
00072             raise ConversionError(msg)

def xdrlib.Packer.pack_fstring (   self,
  n,
  s 
)

Definition at line 78 of file xdrlib.py.

00078 
00079     def pack_fstring(self, n, s):
00080         if n < 0:
00081             raise ValueError('fstring size must be nonnegative')
00082         data = s[:n]
00083         n = ((n+3)//4)*4
00084         data = data + (n - len(data)) * b'\0'
00085         self.__buf.write(data)

Here is the caller graph for this function:

def xdrlib.Packer.pack_int (   self,
  x 
)

Definition at line 53 of file xdrlib.py.

00053 
00054     def pack_int(self, x):
00055         self.__buf.write(struct.pack('>l', x))

def xdrlib.Packer.pack_list (   self,
  list,
  pack_item 
)

Definition at line 96 of file xdrlib.py.

00096 
00097     def pack_list(self, list, pack_item):
00098         for item in list:
00099             self.pack_uint(1)
00100             pack_item(item)
00101         self.pack_uint(0)

Here is the call graph for this function:

def xdrlib.Packer.pack_string (   self,
  s 
)

Definition at line 88 of file xdrlib.py.

00088 
00089     def pack_string(self, s):
00090         n = len(s)
00091         self.pack_uint(n)
00092         self.pack_fstring(n, s)

Here is the call graph for this function:

def xdrlib.Packer.pack_uhyper (   self,
  x 
)

Definition at line 62 of file xdrlib.py.

00062 
00063     def pack_uhyper(self, x):
00064         self.pack_uint(x>>32 & 0xffffffff)
00065         self.pack_uint(x & 0xffffffff)

Here is the call graph for this function:

def xdrlib.Packer.pack_uint (   self,
  x 
)

Definition at line 50 of file xdrlib.py.

00050 
00051     def pack_uint(self, x):
00052         self.__buf.write(struct.pack('>L', x))

Here is the caller graph for this function:

def xdrlib.Packer.reset (   self)

Definition at line 42 of file xdrlib.py.

00042 
00043     def reset(self):
00044         self.__buf = BytesIO()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 43 of file xdrlib.py.

Definition at line 48 of file xdrlib.py.

Definition at line 94 of file xdrlib.py.

Definition at line 56 of file xdrlib.py.

Definition at line 86 of file xdrlib.py.

Definition at line 66 of file xdrlib.py.

Definition at line 93 of file xdrlib.py.


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