_BZ2Packet.py
Go to the documentation of this file.
00001 """autogenerated by genpy from bz2_transport/BZ2Packet.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006 
00007 
00008 class BZ2Packet(genpy.Message):
00009   _md5sum = "37a209db6e0c11cc6c12601cdd2e4aef"
00010   _type = "bz2_transport/BZ2Packet"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """uint32 original_length
00013 uint8[] buffer
00014 
00015 """
00016   __slots__ = ['original_length','buffer']
00017   _slot_types = ['uint32','uint8[]']
00018 
00019   def __init__(self, *args, **kwds):
00020     """
00021     Constructor. Any message fields that are implicitly/explicitly
00022     set to None will be assigned a default value. The recommend
00023     use is keyword arguments as this is more robust to future message
00024     changes.  You cannot mix in-order arguments and keyword arguments.
00025 
00026     The available fields are:
00027        original_length,buffer
00028 
00029     :param args: complete set of field values, in .msg order
00030     :param kwds: use keyword arguments corresponding to message field names
00031     to set specific fields.
00032     """
00033     if args or kwds:
00034       super(BZ2Packet, self).__init__(*args, **kwds)
00035       #message fields cannot be None, assign default values for those that are
00036       if self.original_length is None:
00037         self.original_length = 0
00038       if self.buffer is None:
00039         self.buffer = ''
00040     else:
00041       self.original_length = 0
00042       self.buffer = ''
00043 
00044   def _get_types(self):
00045     """
00046     internal API method
00047     """
00048     return self._slot_types
00049 
00050   def serialize(self, buff):
00051     """
00052     serialize message into buffer
00053     :param buff: buffer, ``StringIO``
00054     """
00055     try:
00056       buff.write(_struct_I.pack(self.original_length))
00057       _x = self.buffer
00058       length = len(_x)
00059       # - if encoded as a list instead, serialize as bytes instead of string
00060       if type(_x) in [list, tuple]:
00061         buff.write(struct.pack('<I%sB'%length, length, *_x))
00062       else:
00063         buff.write(struct.pack('<I%ss'%length, length, _x))
00064     except struct.error as se: self._check_types(se)
00065     except TypeError as te: self._check_types(te)
00066 
00067   def deserialize(self, str):
00068     """
00069     unpack serialized message in str into this message instance
00070     :param str: byte array of serialized message, ``str``
00071     """
00072     try:
00073       end = 0
00074       start = end
00075       end += 4
00076       (self.original_length,) = _struct_I.unpack(str[start:end])
00077       start = end
00078       end += 4
00079       (length,) = _struct_I.unpack(str[start:end])
00080       start = end
00081       end += length
00082       if python3:
00083         self.buffer = str[start:end].decode('utf-8')
00084       else:
00085         self.buffer = str[start:end]
00086       return self
00087     except struct.error as e:
00088       raise genpy.DeserializationError(e) #most likely buffer underfill
00089 
00090 
00091   def serialize_numpy(self, buff, numpy):
00092     """
00093     serialize message with numpy array types into buffer
00094     :param buff: buffer, ``StringIO``
00095     :param numpy: numpy python module
00096     """
00097     try:
00098       buff.write(_struct_I.pack(self.original_length))
00099       _x = self.buffer
00100       length = len(_x)
00101       # - if encoded as a list instead, serialize as bytes instead of string
00102       if type(_x) in [list, tuple]:
00103         buff.write(struct.pack('<I%sB'%length, length, *_x))
00104       else:
00105         buff.write(struct.pack('<I%ss'%length, length, _x))
00106     except struct.error as se: self._check_types(se)
00107     except TypeError as te: self._check_types(te)
00108 
00109   def deserialize_numpy(self, str, numpy):
00110     """
00111     unpack serialized message in str into this message instance using numpy for array types
00112     :param str: byte array of serialized message, ``str``
00113     :param numpy: numpy python module
00114     """
00115     try:
00116       end = 0
00117       start = end
00118       end += 4
00119       (self.original_length,) = _struct_I.unpack(str[start:end])
00120       start = end
00121       end += 4
00122       (length,) = _struct_I.unpack(str[start:end])
00123       start = end
00124       end += length
00125       if python3:
00126         self.buffer = str[start:end].decode('utf-8')
00127       else:
00128         self.buffer = str[start:end]
00129       return self
00130     except struct.error as e:
00131       raise genpy.DeserializationError(e) #most likely buffer underfill
00132 
00133 _struct_I = genpy.struct_I


bz2_transport
Author(s): Cedric Pradalier
autogenerated on Sat Dec 28 2013 16:57:04