_StringArray.py
Go to the documentation of this file.
00001 """autogenerated by genpy from re_msgs/StringArray.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 StringArray(genpy.Message):
00009   _md5sum = "8e09fa9aad51508cfdcab3b64f048ce0"
00010   _type = "re_msgs/StringArray"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """# A StringArray message contains an array of strings. This is used by other 
00013 # message/service declarations in order to create 2-dimensional string 
00014 # arrays with different lengths for one dimension (StringArray[])
00015 string[] list   # array of strings
00016 
00017 """
00018   __slots__ = ['list']
00019   _slot_types = ['string[]']
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        list
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(StringArray, self).__init__(*args, **kwds)
00037       #message fields cannot be None, assign default values for those that are
00038       if self.list is None:
00039         self.list = []
00040     else:
00041       self.list = []
00042 
00043   def _get_types(self):
00044     """
00045     internal API method
00046     """
00047     return self._slot_types
00048 
00049   def serialize(self, buff):
00050     """
00051     serialize message into buffer
00052     :param buff: buffer, ``StringIO``
00053     """
00054     try:
00055       length = len(self.list)
00056       buff.write(_struct_I.pack(length))
00057       for val1 in self.list:
00058         length = len(val1)
00059         if python3 or type(val1) == unicode:
00060           val1 = val1.encode('utf-8')
00061           length = len(val1)
00062         buff.write(struct.pack('<I%ss'%length, length, val1))
00063     except struct.error as se: self._check_types(se)
00064     except TypeError as te: self._check_types(te)
00065 
00066   def deserialize(self, str):
00067     """
00068     unpack serialized message in str into this message instance
00069     :param str: byte array of serialized message, ``str``
00070     """
00071     try:
00072       end = 0
00073       start = end
00074       end += 4
00075       (length,) = _struct_I.unpack(str[start:end])
00076       self.list = []
00077       for i in range(0, length):
00078         start = end
00079         end += 4
00080         (length,) = _struct_I.unpack(str[start:end])
00081         start = end
00082         end += length
00083         if python3:
00084           val1 = str[start:end].decode('utf-8')
00085         else:
00086           val1 = str[start:end]
00087         self.list.append(val1)
00088       return self
00089     except struct.error as e:
00090       raise genpy.DeserializationError(e) #most likely buffer underfill
00091 
00092 
00093   def serialize_numpy(self, buff, numpy):
00094     """
00095     serialize message with numpy array types into buffer
00096     :param buff: buffer, ``StringIO``
00097     :param numpy: numpy python module
00098     """
00099     try:
00100       length = len(self.list)
00101       buff.write(_struct_I.pack(length))
00102       for val1 in self.list:
00103         length = len(val1)
00104         if python3 or type(val1) == unicode:
00105           val1 = val1.encode('utf-8')
00106           length = len(val1)
00107         buff.write(struct.pack('<I%ss'%length, length, val1))
00108     except struct.error as se: self._check_types(se)
00109     except TypeError as te: self._check_types(te)
00110 
00111   def deserialize_numpy(self, str, numpy):
00112     """
00113     unpack serialized message in str into this message instance using numpy for array types
00114     :param str: byte array of serialized message, ``str``
00115     :param numpy: numpy python module
00116     """
00117     try:
00118       end = 0
00119       start = end
00120       end += 4
00121       (length,) = _struct_I.unpack(str[start:end])
00122       self.list = []
00123       for i in range(0, length):
00124         start = end
00125         end += 4
00126         (length,) = _struct_I.unpack(str[start:end])
00127         start = end
00128         end += length
00129         if python3:
00130           val1 = str[start:end].decode('utf-8')
00131         else:
00132           val1 = str[start:end]
00133         self.list.append(val1)
00134       return self
00135     except struct.error as e:
00136       raise genpy.DeserializationError(e) #most likely buffer underfill
00137 
00138 _struct_I = genpy.struct_I


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