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


hrl_msgs
Author(s): Advait Jain
autogenerated on Wed Nov 27 2013 11:33:25