_TBoxObject.py
Go to the documentation of this file.
00001 """autogenerated by genpy from srs_knowledge/TBoxObject.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 TBoxObject(genpy.Message):
00009   _md5sum = "fbdf9bcb056031485032d3fa4ff08d71"
00010   _type = "srs_knowledge/TBoxObject"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """int32 class_id
00013 string name
00014 string description
00015 string[] properties
00016 int32[] subjects
00017 """
00018   __slots__ = ['class_id','name','description','properties','subjects']
00019   _slot_types = ['int32','string','string','string[]','int32[]']
00020 
00021   def __init__(self, *args, **kwds):
00022     """
00023     Constructor. Any message fields that are implicitly/explicitly
00024     set to None will be assigned a default value. The recommend
00025     use is keyword arguments as this is more robust to future message
00026     changes.  You cannot mix in-order arguments and keyword arguments.
00027 
00028     The available fields are:
00029        class_id,name,description,properties,subjects
00030 
00031     :param args: complete set of field values, in .msg order
00032     :param kwds: use keyword arguments corresponding to message field names
00033     to set specific fields.
00034     """
00035     if args or kwds:
00036       super(TBoxObject, self).__init__(*args, **kwds)
00037       #message fields cannot be None, assign default values for those that are
00038       if self.class_id is None:
00039         self.class_id = 0
00040       if self.name is None:
00041         self.name = ''
00042       if self.description is None:
00043         self.description = ''
00044       if self.properties is None:
00045         self.properties = []
00046       if self.subjects is None:
00047         self.subjects = []
00048     else:
00049       self.class_id = 0
00050       self.name = ''
00051       self.description = ''
00052       self.properties = []
00053       self.subjects = []
00054 
00055   def _get_types(self):
00056     """
00057     internal API method
00058     """
00059     return self._slot_types
00060 
00061   def serialize(self, buff):
00062     """
00063     serialize message into buffer
00064     :param buff: buffer, ``StringIO``
00065     """
00066     try:
00067       buff.write(_struct_i.pack(self.class_id))
00068       _x = self.name
00069       length = len(_x)
00070       if python3 or type(_x) == unicode:
00071         _x = _x.encode('utf-8')
00072         length = len(_x)
00073       buff.write(struct.pack('<I%ss'%length, length, _x))
00074       _x = self.description
00075       length = len(_x)
00076       if python3 or type(_x) == unicode:
00077         _x = _x.encode('utf-8')
00078         length = len(_x)
00079       buff.write(struct.pack('<I%ss'%length, length, _x))
00080       length = len(self.properties)
00081       buff.write(_struct_I.pack(length))
00082       for val1 in self.properties:
00083         length = len(val1)
00084         if python3 or type(val1) == unicode:
00085           val1 = val1.encode('utf-8')
00086           length = len(val1)
00087         buff.write(struct.pack('<I%ss'%length, length, val1))
00088       length = len(self.subjects)
00089       buff.write(_struct_I.pack(length))
00090       pattern = '<%si'%length
00091       buff.write(struct.pack(pattern, *self.subjects))
00092     except struct.error as se: self._check_types(se)
00093     except TypeError as te: self._check_types(te)
00094 
00095   def deserialize(self, str):
00096     """
00097     unpack serialized message in str into this message instance
00098     :param str: byte array of serialized message, ``str``
00099     """
00100     try:
00101       end = 0
00102       start = end
00103       end += 4
00104       (self.class_id,) = _struct_i.unpack(str[start:end])
00105       start = end
00106       end += 4
00107       (length,) = _struct_I.unpack(str[start:end])
00108       start = end
00109       end += length
00110       if python3:
00111         self.name = str[start:end].decode('utf-8')
00112       else:
00113         self.name = str[start:end]
00114       start = end
00115       end += 4
00116       (length,) = _struct_I.unpack(str[start:end])
00117       start = end
00118       end += length
00119       if python3:
00120         self.description = str[start:end].decode('utf-8')
00121       else:
00122         self.description = str[start:end]
00123       start = end
00124       end += 4
00125       (length,) = _struct_I.unpack(str[start:end])
00126       self.properties = []
00127       for i in range(0, length):
00128         start = end
00129         end += 4
00130         (length,) = _struct_I.unpack(str[start:end])
00131         start = end
00132         end += length
00133         if python3:
00134           val1 = str[start:end].decode('utf-8')
00135         else:
00136           val1 = str[start:end]
00137         self.properties.append(val1)
00138       start = end
00139       end += 4
00140       (length,) = _struct_I.unpack(str[start:end])
00141       pattern = '<%si'%length
00142       start = end
00143       end += struct.calcsize(pattern)
00144       self.subjects = struct.unpack(pattern, str[start:end])
00145       return self
00146     except struct.error as e:
00147       raise genpy.DeserializationError(e) #most likely buffer underfill
00148 
00149 
00150   def serialize_numpy(self, buff, numpy):
00151     """
00152     serialize message with numpy array types into buffer
00153     :param buff: buffer, ``StringIO``
00154     :param numpy: numpy python module
00155     """
00156     try:
00157       buff.write(_struct_i.pack(self.class_id))
00158       _x = self.name
00159       length = len(_x)
00160       if python3 or type(_x) == unicode:
00161         _x = _x.encode('utf-8')
00162         length = len(_x)
00163       buff.write(struct.pack('<I%ss'%length, length, _x))
00164       _x = self.description
00165       length = len(_x)
00166       if python3 or type(_x) == unicode:
00167         _x = _x.encode('utf-8')
00168         length = len(_x)
00169       buff.write(struct.pack('<I%ss'%length, length, _x))
00170       length = len(self.properties)
00171       buff.write(_struct_I.pack(length))
00172       for val1 in self.properties:
00173         length = len(val1)
00174         if python3 or type(val1) == unicode:
00175           val1 = val1.encode('utf-8')
00176           length = len(val1)
00177         buff.write(struct.pack('<I%ss'%length, length, val1))
00178       length = len(self.subjects)
00179       buff.write(_struct_I.pack(length))
00180       pattern = '<%si'%length
00181       buff.write(self.subjects.tostring())
00182     except struct.error as se: self._check_types(se)
00183     except TypeError as te: self._check_types(te)
00184 
00185   def deserialize_numpy(self, str, numpy):
00186     """
00187     unpack serialized message in str into this message instance using numpy for array types
00188     :param str: byte array of serialized message, ``str``
00189     :param numpy: numpy python module
00190     """
00191     try:
00192       end = 0
00193       start = end
00194       end += 4
00195       (self.class_id,) = _struct_i.unpack(str[start:end])
00196       start = end
00197       end += 4
00198       (length,) = _struct_I.unpack(str[start:end])
00199       start = end
00200       end += length
00201       if python3:
00202         self.name = str[start:end].decode('utf-8')
00203       else:
00204         self.name = str[start:end]
00205       start = end
00206       end += 4
00207       (length,) = _struct_I.unpack(str[start:end])
00208       start = end
00209       end += length
00210       if python3:
00211         self.description = str[start:end].decode('utf-8')
00212       else:
00213         self.description = str[start:end]
00214       start = end
00215       end += 4
00216       (length,) = _struct_I.unpack(str[start:end])
00217       self.properties = []
00218       for i in range(0, length):
00219         start = end
00220         end += 4
00221         (length,) = _struct_I.unpack(str[start:end])
00222         start = end
00223         end += length
00224         if python3:
00225           val1 = str[start:end].decode('utf-8')
00226         else:
00227           val1 = str[start:end]
00228         self.properties.append(val1)
00229       start = end
00230       end += 4
00231       (length,) = _struct_I.unpack(str[start:end])
00232       pattern = '<%si'%length
00233       start = end
00234       end += struct.calcsize(pattern)
00235       self.subjects = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=length)
00236       return self
00237     except struct.error as e:
00238       raise genpy.DeserializationError(e) #most likely buffer underfill
00239 
00240 _struct_I = genpy.struct_I
00241 _struct_i = struct.Struct("<i")


srs_knowledge
Author(s): Ze Ji
autogenerated on Sun Jan 5 2014 12:03:27