Go to the documentation of this file.00001 #ifndef _ROS_rospy_tutorials_HeaderString_h
00002 #define _ROS_rospy_tutorials_HeaderString_h
00003
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "std_msgs/Header.h"
00009
00010 namespace rospy_tutorials
00011 {
00012
00013 class HeaderString : public ros::Msg
00014 {
00015 public:
00016 std_msgs::Header header;
00017 char * data;
00018
00019 virtual int serialize(unsigned char *outbuffer) const
00020 {
00021 int offset = 0;
00022 offset += this->header.serialize(outbuffer + offset);
00023 uint32_t length_data = strlen( (const char*) this->data);
00024 memcpy(outbuffer + offset, &length_data, sizeof(uint32_t));
00025 offset += 4;
00026 memcpy(outbuffer + offset, this->data, length_data);
00027 offset += length_data;
00028 return offset;
00029 }
00030
00031 virtual int deserialize(unsigned char *inbuffer)
00032 {
00033 int offset = 0;
00034 offset += this->header.deserialize(inbuffer + offset);
00035 uint32_t length_data;
00036 memcpy(&length_data, (inbuffer + offset), sizeof(uint32_t));
00037 offset += 4;
00038 for(unsigned int k= offset; k< offset+length_data; ++k){
00039 inbuffer[k-1]=inbuffer[k];
00040 }
00041 inbuffer[offset+length_data-1]=0;
00042 this->data = (char *)(inbuffer + offset-1);
00043 offset += length_data;
00044 return offset;
00045 }
00046
00047 const char * getType(){ return "rospy_tutorials/HeaderString"; };
00048 const char * getMD5(){ return "c99a9440709e4d4a9716d55b8270d5e7"; };
00049
00050 };
00051
00052 }
00053 #endif