_TypeDef.py
Go to the documentation of this file.
00001 """autogenerated by genpy from rosapi/TypeDef.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 TypeDef(genpy.Message):
00009   _md5sum = "bd8529b0edb168fde8dd58032743f1f7"
00010   _type = "rosapi/TypeDef"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """string type
00013 string[] fieldnames
00014 string[] fieldtypes
00015 int32[] fieldarraylen
00016 string[] examples
00017 
00018 """
00019   __slots__ = ['type','fieldnames','fieldtypes','fieldarraylen','examples']
00020   _slot_types = ['string','string[]','string[]','int32[]','string[]']
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        type,fieldnames,fieldtypes,fieldarraylen,examples
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(TypeDef, self).__init__(*args, **kwds)
00038       #message fields cannot be None, assign default values for those that are
00039       if self.type is None:
00040         self.type = ''
00041       if self.fieldnames is None:
00042         self.fieldnames = []
00043       if self.fieldtypes is None:
00044         self.fieldtypes = []
00045       if self.fieldarraylen is None:
00046         self.fieldarraylen = []
00047       if self.examples is None:
00048         self.examples = []
00049     else:
00050       self.type = ''
00051       self.fieldnames = []
00052       self.fieldtypes = []
00053       self.fieldarraylen = []
00054       self.examples = []
00055 
00056   def _get_types(self):
00057     """
00058     internal API method
00059     """
00060     return self._slot_types
00061 
00062   def serialize(self, buff):
00063     """
00064     serialize message into buffer
00065     :param buff: buffer, ``StringIO``
00066     """
00067     try:
00068       _x = self.type
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       length = len(self.fieldnames)
00075       buff.write(_struct_I.pack(length))
00076       for val1 in self.fieldnames:
00077         length = len(val1)
00078         if python3 or type(val1) == unicode:
00079           val1 = val1.encode('utf-8')
00080           length = len(val1)
00081         buff.write(struct.pack('<I%ss'%length, length, val1))
00082       length = len(self.fieldtypes)
00083       buff.write(_struct_I.pack(length))
00084       for val1 in self.fieldtypes:
00085         length = len(val1)
00086         if python3 or type(val1) == unicode:
00087           val1 = val1.encode('utf-8')
00088           length = len(val1)
00089         buff.write(struct.pack('<I%ss'%length, length, val1))
00090       length = len(self.fieldarraylen)
00091       buff.write(_struct_I.pack(length))
00092       pattern = '<%si'%length
00093       buff.write(struct.pack(pattern, *self.fieldarraylen))
00094       length = len(self.examples)
00095       buff.write(_struct_I.pack(length))
00096       for val1 in self.examples:
00097         length = len(val1)
00098         if python3 or type(val1) == unicode:
00099           val1 = val1.encode('utf-8')
00100           length = len(val1)
00101         buff.write(struct.pack('<I%ss'%length, length, val1))
00102     except struct.error as se: self._check_types(se)
00103     except TypeError as te: self._check_types(te)
00104 
00105   def deserialize(self, str):
00106     """
00107     unpack serialized message in str into this message instance
00108     :param str: byte array of serialized message, ``str``
00109     """
00110     try:
00111       end = 0
00112       start = end
00113       end += 4
00114       (length,) = _struct_I.unpack(str[start:end])
00115       start = end
00116       end += length
00117       if python3:
00118         self.type = str[start:end].decode('utf-8')
00119       else:
00120         self.type = str[start:end]
00121       start = end
00122       end += 4
00123       (length,) = _struct_I.unpack(str[start:end])
00124       self.fieldnames = []
00125       for i in range(0, length):
00126         start = end
00127         end += 4
00128         (length,) = _struct_I.unpack(str[start:end])
00129         start = end
00130         end += length
00131         if python3:
00132           val1 = str[start:end].decode('utf-8')
00133         else:
00134           val1 = str[start:end]
00135         self.fieldnames.append(val1)
00136       start = end
00137       end += 4
00138       (length,) = _struct_I.unpack(str[start:end])
00139       self.fieldtypes = []
00140       for i in range(0, length):
00141         start = end
00142         end += 4
00143         (length,) = _struct_I.unpack(str[start:end])
00144         start = end
00145         end += length
00146         if python3:
00147           val1 = str[start:end].decode('utf-8')
00148         else:
00149           val1 = str[start:end]
00150         self.fieldtypes.append(val1)
00151       start = end
00152       end += 4
00153       (length,) = _struct_I.unpack(str[start:end])
00154       pattern = '<%si'%length
00155       start = end
00156       end += struct.calcsize(pattern)
00157       self.fieldarraylen = struct.unpack(pattern, str[start:end])
00158       start = end
00159       end += 4
00160       (length,) = _struct_I.unpack(str[start:end])
00161       self.examples = []
00162       for i in range(0, length):
00163         start = end
00164         end += 4
00165         (length,) = _struct_I.unpack(str[start:end])
00166         start = end
00167         end += length
00168         if python3:
00169           val1 = str[start:end].decode('utf-8')
00170         else:
00171           val1 = str[start:end]
00172         self.examples.append(val1)
00173       return self
00174     except struct.error as e:
00175       raise genpy.DeserializationError(e) #most likely buffer underfill
00176 
00177 
00178   def serialize_numpy(self, buff, numpy):
00179     """
00180     serialize message with numpy array types into buffer
00181     :param buff: buffer, ``StringIO``
00182     :param numpy: numpy python module
00183     """
00184     try:
00185       _x = self.type
00186       length = len(_x)
00187       if python3 or type(_x) == unicode:
00188         _x = _x.encode('utf-8')
00189         length = len(_x)
00190       buff.write(struct.pack('<I%ss'%length, length, _x))
00191       length = len(self.fieldnames)
00192       buff.write(_struct_I.pack(length))
00193       for val1 in self.fieldnames:
00194         length = len(val1)
00195         if python3 or type(val1) == unicode:
00196           val1 = val1.encode('utf-8')
00197           length = len(val1)
00198         buff.write(struct.pack('<I%ss'%length, length, val1))
00199       length = len(self.fieldtypes)
00200       buff.write(_struct_I.pack(length))
00201       for val1 in self.fieldtypes:
00202         length = len(val1)
00203         if python3 or type(val1) == unicode:
00204           val1 = val1.encode('utf-8')
00205           length = len(val1)
00206         buff.write(struct.pack('<I%ss'%length, length, val1))
00207       length = len(self.fieldarraylen)
00208       buff.write(_struct_I.pack(length))
00209       pattern = '<%si'%length
00210       buff.write(self.fieldarraylen.tostring())
00211       length = len(self.examples)
00212       buff.write(_struct_I.pack(length))
00213       for val1 in self.examples:
00214         length = len(val1)
00215         if python3 or type(val1) == unicode:
00216           val1 = val1.encode('utf-8')
00217           length = len(val1)
00218         buff.write(struct.pack('<I%ss'%length, length, val1))
00219     except struct.error as se: self._check_types(se)
00220     except TypeError as te: self._check_types(te)
00221 
00222   def deserialize_numpy(self, str, numpy):
00223     """
00224     unpack serialized message in str into this message instance using numpy for array types
00225     :param str: byte array of serialized message, ``str``
00226     :param numpy: numpy python module
00227     """
00228     try:
00229       end = 0
00230       start = end
00231       end += 4
00232       (length,) = _struct_I.unpack(str[start:end])
00233       start = end
00234       end += length
00235       if python3:
00236         self.type = str[start:end].decode('utf-8')
00237       else:
00238         self.type = str[start:end]
00239       start = end
00240       end += 4
00241       (length,) = _struct_I.unpack(str[start:end])
00242       self.fieldnames = []
00243       for i in range(0, length):
00244         start = end
00245         end += 4
00246         (length,) = _struct_I.unpack(str[start:end])
00247         start = end
00248         end += length
00249         if python3:
00250           val1 = str[start:end].decode('utf-8')
00251         else:
00252           val1 = str[start:end]
00253         self.fieldnames.append(val1)
00254       start = end
00255       end += 4
00256       (length,) = _struct_I.unpack(str[start:end])
00257       self.fieldtypes = []
00258       for i in range(0, length):
00259         start = end
00260         end += 4
00261         (length,) = _struct_I.unpack(str[start:end])
00262         start = end
00263         end += length
00264         if python3:
00265           val1 = str[start:end].decode('utf-8')
00266         else:
00267           val1 = str[start:end]
00268         self.fieldtypes.append(val1)
00269       start = end
00270       end += 4
00271       (length,) = _struct_I.unpack(str[start:end])
00272       pattern = '<%si'%length
00273       start = end
00274       end += struct.calcsize(pattern)
00275       self.fieldarraylen = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=length)
00276       start = end
00277       end += 4
00278       (length,) = _struct_I.unpack(str[start:end])
00279       self.examples = []
00280       for i in range(0, length):
00281         start = end
00282         end += 4
00283         (length,) = _struct_I.unpack(str[start:end])
00284         start = end
00285         end += length
00286         if python3:
00287           val1 = str[start:end].decode('utf-8')
00288         else:
00289           val1 = str[start:end]
00290         self.examples.append(val1)
00291       return self
00292     except struct.error as e:
00293       raise genpy.DeserializationError(e) #most likely buffer underfill
00294 
00295 _struct_I = genpy.struct_I


rosapi
Author(s): Jon
autogenerated on Thu Jan 2 2014 11:53:39