_TestMsgArray.py
Go to the documentation of this file.
00001 """autogenerated by genpy from genpy/TestMsgArray.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006 
00007 import genpy.msg
00008 
00009 class TestMsgArray(genpy.Message):
00010   _md5sum = "e75eac49334a57b5055be2d573580cc2"
00011   _type = "genpy/TestMsgArray"
00012   _has_header = False #flag to mark the presence of a Header object
00013   _full_text = """TestString[] strings
00014 TestString[1] fixed_strings
00015 
00016 ================================================================================
00017 MSG: genpy/TestString
00018 string data
00019 
00020 """
00021   __slots__ = ['strings','fixed_strings']
00022   _slot_types = ['genpy/TestString[]','genpy/TestString[1]']
00023 
00024   def __init__(self, *args, **kwds):
00025     """
00026     Constructor. Any message fields that are implicitly/explicitly
00027     set to None will be assigned a default value. The recommend
00028     use is keyword arguments as this is more robust to future message
00029     changes.  You cannot mix in-order arguments and keyword arguments.
00030 
00031     The available fields are:
00032        strings,fixed_strings
00033 
00034     :param args: complete set of field values, in .msg order
00035     :param kwds: use keyword arguments corresponding to message field names
00036     to set specific fields.
00037     """
00038     if args or kwds:
00039       super(TestMsgArray, self).__init__(*args, **kwds)
00040       #message fields cannot be None, assign default values for those that are
00041       if self.strings is None:
00042         self.strings = []
00043       if self.fixed_strings is None:
00044         self.fixed_strings = [genpy.msg.TestString()]
00045     else:
00046       self.strings = []
00047       self.fixed_strings = [genpy.msg.TestString()]
00048 
00049   def _get_types(self):
00050     """
00051     internal API method
00052     """
00053     return self._slot_types
00054 
00055   def serialize(self, buff):
00056     """
00057     serialize message into buffer
00058     :param buff: buffer, ``StringIO``
00059     """
00060     try:
00061       length = len(self.strings)
00062       buff.write(_struct_I.pack(length))
00063       for val1 in self.strings:
00064         _x = val1.data
00065         length = len(_x)
00066         if python3 or type(_x) == unicode:
00067           _x = _x.encode('utf-8')
00068           length = len(_x)
00069         buff.write(struct.pack('<I%ss'%length, length, _x))
00070       for val1 in self.fixed_strings:
00071         _x = val1.data
00072         length = len(_x)
00073         if python3 or type(_x) == unicode:
00074           _x = _x.encode('utf-8')
00075           length = len(_x)
00076         buff.write(struct.pack('<I%ss'%length, length, _x))
00077     except struct.error as se: self._check_types(se)
00078     except TypeError as te: self._check_types(te)
00079 
00080   def deserialize(self, str):
00081     """
00082     unpack serialized message in str into this message instance
00083     :param str: byte array of serialized message, ``str``
00084     """
00085     try:
00086       if self.strings is None:
00087         self.strings = None
00088       if self.fixed_strings is None:
00089         self.fixed_strings = None
00090       end = 0
00091       start = end
00092       end += 4
00093       (length,) = _struct_I.unpack(str[start:end])
00094       self.strings = []
00095       for i in range(0, length):
00096         val1 = genpy.msg.TestString()
00097         start = end
00098         end += 4
00099         (length,) = _struct_I.unpack(str[start:end])
00100         start = end
00101         end += length
00102         if python3:
00103           val1.data = str[start:end].decode('utf-8')
00104         else:
00105           val1.data = str[start:end]
00106         self.strings.append(val1)
00107       self.fixed_strings = []
00108       for i in range(0, 1):
00109         val1 = genpy.msg.TestString()
00110         start = end
00111         end += 4
00112         (length,) = _struct_I.unpack(str[start:end])
00113         start = end
00114         end += length
00115         if python3:
00116           val1.data = str[start:end].decode('utf-8')
00117         else:
00118           val1.data = str[start:end]
00119         self.fixed_strings.append(val1)
00120       return self
00121     except struct.error as e:
00122       raise genpy.DeserializationError(e) #most likely buffer underfill
00123 
00124 
00125   def serialize_numpy(self, buff, numpy):
00126     """
00127     serialize message with numpy array types into buffer
00128     :param buff: buffer, ``StringIO``
00129     :param numpy: numpy python module
00130     """
00131     try:
00132       length = len(self.strings)
00133       buff.write(_struct_I.pack(length))
00134       for val1 in self.strings:
00135         _x = val1.data
00136         length = len(_x)
00137         if python3 or type(_x) == unicode:
00138           _x = _x.encode('utf-8')
00139           length = len(_x)
00140         buff.write(struct.pack('<I%ss'%length, length, _x))
00141       for val1 in self.fixed_strings:
00142         _x = val1.data
00143         length = len(_x)
00144         if python3 or type(_x) == unicode:
00145           _x = _x.encode('utf-8')
00146           length = len(_x)
00147         buff.write(struct.pack('<I%ss'%length, length, _x))
00148     except struct.error as se: self._check_types(se)
00149     except TypeError as te: self._check_types(te)
00150 
00151   def deserialize_numpy(self, str, numpy):
00152     """
00153     unpack serialized message in str into this message instance using numpy for array types
00154     :param str: byte array of serialized message, ``str``
00155     :param numpy: numpy python module
00156     """
00157     try:
00158       if self.strings is None:
00159         self.strings = None
00160       if self.fixed_strings is None:
00161         self.fixed_strings = None
00162       end = 0
00163       start = end
00164       end += 4
00165       (length,) = _struct_I.unpack(str[start:end])
00166       self.strings = []
00167       for i in range(0, length):
00168         val1 = genpy.msg.TestString()
00169         start = end
00170         end += 4
00171         (length,) = _struct_I.unpack(str[start:end])
00172         start = end
00173         end += length
00174         if python3:
00175           val1.data = str[start:end].decode('utf-8')
00176         else:
00177           val1.data = str[start:end]
00178         self.strings.append(val1)
00179       self.fixed_strings = []
00180       for i in range(0, 1):
00181         val1 = genpy.msg.TestString()
00182         start = end
00183         end += 4
00184         (length,) = _struct_I.unpack(str[start:end])
00185         start = end
00186         end += length
00187         if python3:
00188           val1.data = str[start:end].decode('utf-8')
00189         else:
00190           val1.data = str[start:end]
00191         self.fixed_strings.append(val1)
00192       return self
00193     except struct.error as e:
00194       raise genpy.DeserializationError(e) #most likely buffer underfill
00195 
00196 _struct_I = genpy.struct_I


firos
Author(s): IƱigo Gonzalez, igonzalez@ikergune.com
autogenerated on Thu Jun 6 2019 17:51:04