Go to the documentation of this file.00001 """autogenerated by genpy from hrl_haptic_manipulation_in_clutter_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 = "51789d20146e565223d0963361aecda1"
00010 _type = "hrl_haptic_manipulation_in_clutter_msgs/StringArray"
00011 _has_header = False
00012 _full_text = """string[] strings
00013
00014 """
00015 __slots__ = ['strings']
00016 _slot_types = ['string[]']
00017
00018 def __init__(self, *args, **kwds):
00019 """
00020 Constructor. Any message fields that are implicitly/explicitly
00021 set to None will be assigned a default value. The recommend
00022 use is keyword arguments as this is more robust to future message
00023 changes. You cannot mix in-order arguments and keyword arguments.
00024
00025 The available fields are:
00026 strings
00027
00028 :param args: complete set of field values, in .msg order
00029 :param kwds: use keyword arguments corresponding to message field names
00030 to set specific fields.
00031 """
00032 if args or kwds:
00033 super(StringArray, self).__init__(*args, **kwds)
00034
00035 if self.strings is None:
00036 self.strings = []
00037 else:
00038 self.strings = []
00039
00040 def _get_types(self):
00041 """
00042 internal API method
00043 """
00044 return self._slot_types
00045
00046 def serialize(self, buff):
00047 """
00048 serialize message into buffer
00049 :param buff: buffer, ``StringIO``
00050 """
00051 try:
00052 length = len(self.strings)
00053 buff.write(_struct_I.pack(length))
00054 for val1 in self.strings:
00055 length = len(val1)
00056 if python3 or type(val1) == unicode:
00057 val1 = val1.encode('utf-8')
00058 length = len(val1)
00059 buff.write(struct.pack('<I%ss'%length, length, val1))
00060 except struct.error as se: self._check_types(se)
00061 except TypeError as te: self._check_types(te)
00062
00063 def deserialize(self, str):
00064 """
00065 unpack serialized message in str into this message instance
00066 :param str: byte array of serialized message, ``str``
00067 """
00068 try:
00069 end = 0
00070 start = end
00071 end += 4
00072 (length,) = _struct_I.unpack(str[start:end])
00073 self.strings = []
00074 for i in range(0, length):
00075 start = end
00076 end += 4
00077 (length,) = _struct_I.unpack(str[start:end])
00078 start = end
00079 end += length
00080 if python3:
00081 val1 = str[start:end].decode('utf-8')
00082 else:
00083 val1 = str[start:end]
00084 self.strings.append(val1)
00085 return self
00086 except struct.error as e:
00087 raise genpy.DeserializationError(e)
00088
00089
00090 def serialize_numpy(self, buff, numpy):
00091 """
00092 serialize message with numpy array types into buffer
00093 :param buff: buffer, ``StringIO``
00094 :param numpy: numpy python module
00095 """
00096 try:
00097 length = len(self.strings)
00098 buff.write(_struct_I.pack(length))
00099 for val1 in self.strings:
00100 length = len(val1)
00101 if python3 or type(val1) == unicode:
00102 val1 = val1.encode('utf-8')
00103 length = len(val1)
00104 buff.write(struct.pack('<I%ss'%length, length, val1))
00105 except struct.error as se: self._check_types(se)
00106 except TypeError as te: self._check_types(te)
00107
00108 def deserialize_numpy(self, str, numpy):
00109 """
00110 unpack serialized message in str into this message instance using numpy for array types
00111 :param str: byte array of serialized message, ``str``
00112 :param numpy: numpy python module
00113 """
00114 try:
00115 end = 0
00116 start = end
00117 end += 4
00118 (length,) = _struct_I.unpack(str[start:end])
00119 self.strings = []
00120 for i in range(0, length):
00121 start = end
00122 end += 4
00123 (length,) = _struct_I.unpack(str[start:end])
00124 start = end
00125 end += length
00126 if python3:
00127 val1 = str[start:end].decode('utf-8')
00128 else:
00129 val1 = str[start:end]
00130 self.strings.append(val1)
00131 return self
00132 except struct.error as e:
00133 raise genpy.DeserializationError(e)
00134
00135 _struct_I = genpy.struct_I