_Icon.py
Go to the documentation of this file.
00001 """autogenerated by genpy from app_manager/Icon.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 Icon(genpy.Message):
00009   _md5sum = "e378a502c24c5aa2af7065d57c580d12"
00010   _type = "app_manager/Icon"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """# Image data format.  "jpeg" or "png"
00013 string format
00014 
00015 # Image data.
00016 uint8[] data
00017 
00018 """
00019   __slots__ = ['format','data']
00020   _slot_types = ['string','uint8[]']
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        format,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(Icon, self).__init__(*args, **kwds)
00038       #message fields cannot be None, assign default values for those that are
00039       if self.format is None:
00040         self.format = ''
00041       if self.data is None:
00042         self.data = ''
00043     else:
00044       self.format = ''
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.format
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       _x = self.data
00066       length = len(_x)
00067       # - if encoded as a list instead, serialize as bytes instead of string
00068       if type(_x) in [list, tuple]:
00069         buff.write(struct.pack('<I%sB'%length, length, *_x))
00070       else:
00071         buff.write(struct.pack('<I%ss'%length, length, _x))
00072     except struct.error as se: self._check_types(se)
00073     except TypeError as te: self._check_types(te)
00074 
00075   def deserialize(self, str):
00076     """
00077     unpack serialized message in str into this message instance
00078     :param str: byte array of serialized message, ``str``
00079     """
00080     try:
00081       end = 0
00082       start = end
00083       end += 4
00084       (length,) = _struct_I.unpack(str[start:end])
00085       start = end
00086       end += length
00087       if python3:
00088         self.format = str[start:end].decode('utf-8')
00089       else:
00090         self.format = str[start:end]
00091       start = end
00092       end += 4
00093       (length,) = _struct_I.unpack(str[start:end])
00094       start = end
00095       end += length
00096       if python3:
00097         self.data = str[start:end].decode('utf-8')
00098       else:
00099         self.data = str[start:end]
00100       return self
00101     except struct.error as e:
00102       raise genpy.DeserializationError(e) #most likely buffer underfill
00103 
00104 
00105   def serialize_numpy(self, buff, numpy):
00106     """
00107     serialize message with numpy array types into buffer
00108     :param buff: buffer, ``StringIO``
00109     :param numpy: numpy python module
00110     """
00111     try:
00112       _x = self.format
00113       length = len(_x)
00114       if python3 or type(_x) == unicode:
00115         _x = _x.encode('utf-8')
00116         length = len(_x)
00117       buff.write(struct.pack('<I%ss'%length, length, _x))
00118       _x = self.data
00119       length = len(_x)
00120       # - if encoded as a list instead, serialize as bytes instead of string
00121       if type(_x) in [list, tuple]:
00122         buff.write(struct.pack('<I%sB'%length, length, *_x))
00123       else:
00124         buff.write(struct.pack('<I%ss'%length, length, _x))
00125     except struct.error as se: self._check_types(se)
00126     except TypeError as te: self._check_types(te)
00127 
00128   def deserialize_numpy(self, str, numpy):
00129     """
00130     unpack serialized message in str into this message instance using numpy for array types
00131     :param str: byte array of serialized message, ``str``
00132     :param numpy: numpy python module
00133     """
00134     try:
00135       end = 0
00136       start = end
00137       end += 4
00138       (length,) = _struct_I.unpack(str[start:end])
00139       start = end
00140       end += length
00141       if python3:
00142         self.format = str[start:end].decode('utf-8')
00143       else:
00144         self.format = str[start:end]
00145       start = end
00146       end += 4
00147       (length,) = _struct_I.unpack(str[start:end])
00148       start = end
00149       end += length
00150       if python3:
00151         self.data = str[start:end].decode('utf-8')
00152       else:
00153         self.data = str[start:end]
00154       return self
00155     except struct.error as e:
00156       raise genpy.DeserializationError(e) #most likely buffer underfill
00157 
00158 _struct_I = genpy.struct_I


app_manager
Author(s): Jeremy Leibs, Ken Conley
autogenerated on Mon Dec 2 2013 11:36:52