Go to the documentation of this file.00001 #ifndef ros_std_msgs_MultiArrayDimension_h
00002 #define ros_std_msgs_MultiArrayDimension_h
00003
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "../ros/msg.h"
00008
00009 namespace std_msgs
00010 {
00011
00012 class MultiArrayDimension : public ros::Msg
00013 {
00014 public:
00015 char * label;
00016 unsigned long size;
00017 unsigned long stride;
00018
00019 virtual int serialize(unsigned char *outbuffer)
00020 {
00021 int offset = 0;
00022 long * length_label = (long *)(outbuffer + offset);
00023 *length_label = strlen( (const char*) this->label);
00024 offset += 4;
00025 memcpy(outbuffer + offset, this->label, *length_label);
00026 offset += *length_label;
00027 union {
00028 unsigned long real;
00029 unsigned long base;
00030 } u_size;
00031 u_size.real = this->size;
00032 *(outbuffer + offset + 0) = (u_size.base >> (8 * 0)) & 0xFF;
00033 *(outbuffer + offset + 1) = (u_size.base >> (8 * 1)) & 0xFF;
00034 *(outbuffer + offset + 2) = (u_size.base >> (8 * 2)) & 0xFF;
00035 *(outbuffer + offset + 3) = (u_size.base >> (8 * 3)) & 0xFF;
00036 offset += sizeof(this->size);
00037 union {
00038 unsigned long real;
00039 unsigned long base;
00040 } u_stride;
00041 u_stride.real = this->stride;
00042 *(outbuffer + offset + 0) = (u_stride.base >> (8 * 0)) & 0xFF;
00043 *(outbuffer + offset + 1) = (u_stride.base >> (8 * 1)) & 0xFF;
00044 *(outbuffer + offset + 2) = (u_stride.base >> (8 * 2)) & 0xFF;
00045 *(outbuffer + offset + 3) = (u_stride.base >> (8 * 3)) & 0xFF;
00046 offset += sizeof(this->stride);
00047 return offset;
00048 }
00049
00050 virtual int deserialize(unsigned char *inbuffer)
00051 {
00052 int offset = 0;
00053 uint32_t length_label = *(uint32_t *)(inbuffer + offset);
00054 offset += 4;
00055 for(unsigned int k= offset; k< offset+length_label; ++k){
00056 inbuffer[k-1]=inbuffer[k];
00057 }
00058 inbuffer[offset+length_label-1]=0;
00059 this->label = (char *)(inbuffer + offset-1);
00060 offset += length_label;
00061 union {
00062 unsigned long real;
00063 unsigned long base;
00064 } u_size;
00065 u_size.base = 0;
00066 u_size.base |= ((typeof(u_size.base)) (*(inbuffer + offset + 0))) << (8 * 0);
00067 u_size.base |= ((typeof(u_size.base)) (*(inbuffer + offset + 1))) << (8 * 1);
00068 u_size.base |= ((typeof(u_size.base)) (*(inbuffer + offset + 2))) << (8 * 2);
00069 u_size.base |= ((typeof(u_size.base)) (*(inbuffer + offset + 3))) << (8 * 3);
00070 this->size = u_size.real;
00071 offset += sizeof(this->size);
00072 union {
00073 unsigned long real;
00074 unsigned long base;
00075 } u_stride;
00076 u_stride.base = 0;
00077 u_stride.base |= ((typeof(u_stride.base)) (*(inbuffer + offset + 0))) << (8 * 0);
00078 u_stride.base |= ((typeof(u_stride.base)) (*(inbuffer + offset + 1))) << (8 * 1);
00079 u_stride.base |= ((typeof(u_stride.base)) (*(inbuffer + offset + 2))) << (8 * 2);
00080 u_stride.base |= ((typeof(u_stride.base)) (*(inbuffer + offset + 3))) << (8 * 3);
00081 this->stride = u_stride.real;
00082 offset += sizeof(this->stride);
00083 return offset;
00084 }
00085
00086 const char * getType(){ return "std_msgs/MultiArrayDimension"; };
00087
00088 };
00089
00090 }
00091 #endif