00001 """autogenerated by genmsg_py from EmbeddedVariableLength.msg. Do not edit."""
00002 import roslib.message
00003 import struct
00004
00005 import test_roscpp_serialization.msg
00006
00007 class EmbeddedVariableLength(roslib.message.Message):
00008 _md5sum = "e7404d454a50b82c426a3a2c76fbcefd"
00009 _type = "test_roscpp_serialization/EmbeddedVariableLength"
00010 _has_header = False
00011 _full_text = """VariableLength a
00012
00013 ================================================================================
00014 MSG: test_roscpp_serialization/VariableLength
00015 uint32[] a
00016
00017 """
00018 __slots__ = ['a']
00019 _slot_types = ['test_roscpp_serialization/VariableLength']
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 a
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(EmbeddedVariableLength, self).__init__(*args, **kwds)
00037
00038 if self.a is None:
00039 self.a = test_roscpp_serialization.msg.VariableLength()
00040 else:
00041 self.a = test_roscpp_serialization.msg.VariableLength()
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
00053 @type buff: StringIO
00054 """
00055 try:
00056 length = len(self.a.a)
00057 buff.write(_struct_I.pack(length))
00058 pattern = '<%sI'%length
00059 buff.write(struct.pack(pattern, *self.a.a))
00060 except struct.error, se: self._check_types(se)
00061 except TypeError, 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
00067 @type str: str
00068 """
00069 try:
00070 if self.a is None:
00071 self.a = test_roscpp_serialization.msg.VariableLength()
00072 end = 0
00073 start = end
00074 end += 4
00075 (length,) = _struct_I.unpack(str[start:end])
00076 pattern = '<%sI'%length
00077 start = end
00078 end += struct.calcsize(pattern)
00079 self.a.a = struct.unpack(pattern, str[start:end])
00080 return self
00081 except struct.error, e:
00082 raise roslib.message.DeserializationError(e)
00083
00084
00085 def serialize_numpy(self, buff, numpy):
00086 """
00087 serialize message with numpy array types into buffer
00088 @param buff: buffer
00089 @type buff: StringIO
00090 @param numpy: numpy python module
00091 @type numpy module
00092 """
00093 try:
00094 length = len(self.a.a)
00095 buff.write(_struct_I.pack(length))
00096 pattern = '<%sI'%length
00097 buff.write(self.a.a.tostring())
00098 except struct.error, se: self._check_types(se)
00099 except TypeError, te: self._check_types(te)
00100
00101 def deserialize_numpy(self, str, numpy):
00102 """
00103 unpack serialized message in str into this message instance using numpy for array types
00104 @param str: byte array of serialized message
00105 @type str: str
00106 @param numpy: numpy python module
00107 @type numpy: module
00108 """
00109 try:
00110 if self.a is None:
00111 self.a = test_roscpp_serialization.msg.VariableLength()
00112 end = 0
00113 start = end
00114 end += 4
00115 (length,) = _struct_I.unpack(str[start:end])
00116 pattern = '<%sI'%length
00117 start = end
00118 end += struct.calcsize(pattern)
00119 self.a.a = numpy.frombuffer(str[start:end], dtype=numpy.uint32, count=length)
00120 return self
00121 except struct.error, e:
00122 raise roslib.message.DeserializationError(e)
00123
00124 _struct_I = roslib.message.struct_I