_RosFile.py
Go to the documentation of this file.
00001 """autogenerated by genpy from re_msgs/RosFile.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 RosFile(genpy.Message):
00009   _md5sum = "893fbfd6413e9fa51a46d64705c3b6c3"
00010   _type = "re_msgs/RosFile"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """# This file representation is used to pass binary data to the RoboEarthDB.
00013 # As the endianess isn't stored, only files with a byte order mark (BOM) or
00014 # an implicitly specified endianess should be transferred.
00015 string name   # file name
00016 int8[] data   # binary data 
00017 
00018 """
00019   __slots__ = ['name','data']
00020   _slot_types = ['string','int8[]']
00021 
00022   def __init__(self, *args, **kwds):
00023     """
00024     Constructor. Any message fields that are implicitly/explicitly
00025     set to None will be assigned a default value. The recommend
00026     use is keyword arguments as this is more robust to future message
00027     changes.  You cannot mix in-order arguments and keyword arguments.
00028 
00029     The available fields are:
00030        name,data
00031 
00032     :param args: complete set of field values, in .msg order
00033     :param kwds: use keyword arguments corresponding to message field names
00034     to set specific fields.
00035     """
00036     if args or kwds:
00037       super(RosFile, self).__init__(*args, **kwds)
00038       #message fields cannot be None, assign default values for those that are
00039       if self.name is None:
00040         self.name = ''
00041       if self.data is None:
00042         self.data = []
00043     else:
00044       self.name = ''
00045       self.data = []
00046 
00047   def _get_types(self):
00048     """
00049     internal API method
00050     """
00051     return self._slot_types
00052 
00053   def serialize(self, buff):
00054     """
00055     serialize message into buffer
00056     :param buff: buffer, ``StringIO``
00057     """
00058     try:
00059       _x = self.name
00060       length = len(_x)
00061       if python3 or type(_x) == unicode:
00062         _x = _x.encode('utf-8')
00063         length = len(_x)
00064       buff.write(struct.pack('<I%ss'%length, length, _x))
00065       length = len(self.data)
00066       buff.write(_struct_I.pack(length))
00067       pattern = '<%sb'%length
00068       buff.write(struct.pack(pattern, *self.data))
00069     except struct.error as se: self._check_types(se)
00070     except TypeError as te: self._check_types(te)
00071 
00072   def deserialize(self, str):
00073     """
00074     unpack serialized message in str into this message instance
00075     :param str: byte array of serialized message, ``str``
00076     """
00077     try:
00078       end = 0
00079       start = end
00080       end += 4
00081       (length,) = _struct_I.unpack(str[start:end])
00082       start = end
00083       end += length
00084       if python3:
00085         self.name = str[start:end].decode('utf-8')
00086       else:
00087         self.name = str[start:end]
00088       start = end
00089       end += 4
00090       (length,) = _struct_I.unpack(str[start:end])
00091       pattern = '<%sb'%length
00092       start = end
00093       end += struct.calcsize(pattern)
00094       self.data = struct.unpack(pattern, str[start:end])
00095       return self
00096     except struct.error as e:
00097       raise genpy.DeserializationError(e) #most likely buffer underfill
00098 
00099 
00100   def serialize_numpy(self, buff, numpy):
00101     """
00102     serialize message with numpy array types into buffer
00103     :param buff: buffer, ``StringIO``
00104     :param numpy: numpy python module
00105     """
00106     try:
00107       _x = self.name
00108       length = len(_x)
00109       if python3 or type(_x) == unicode:
00110         _x = _x.encode('utf-8')
00111         length = len(_x)
00112       buff.write(struct.pack('<I%ss'%length, length, _x))
00113       length = len(self.data)
00114       buff.write(_struct_I.pack(length))
00115       pattern = '<%sb'%length
00116       buff.write(self.data.tostring())
00117     except struct.error as se: self._check_types(se)
00118     except TypeError as te: self._check_types(te)
00119 
00120   def deserialize_numpy(self, str, numpy):
00121     """
00122     unpack serialized message in str into this message instance using numpy for array types
00123     :param str: byte array of serialized message, ``str``
00124     :param numpy: numpy python module
00125     """
00126     try:
00127       end = 0
00128       start = end
00129       end += 4
00130       (length,) = _struct_I.unpack(str[start:end])
00131       start = end
00132       end += length
00133       if python3:
00134         self.name = str[start:end].decode('utf-8')
00135       else:
00136         self.name = str[start:end]
00137       start = end
00138       end += 4
00139       (length,) = _struct_I.unpack(str[start:end])
00140       pattern = '<%sb'%length
00141       start = end
00142       end += struct.calcsize(pattern)
00143       self.data = numpy.frombuffer(str[start:end], dtype=numpy.int8, count=length)
00144       return self
00145     except struct.error as e:
00146       raise genpy.DeserializationError(e) #most likely buffer underfill
00147 
00148 _struct_I = genpy.struct_I


re_msgs
Author(s): Alexander Perzylo
autogenerated on Sun Jan 5 2014 11:27:54