RequestParam.h
Go to the documentation of this file.
00001 #ifndef _ROS_SERVICE_RequestParam_h
00002 #define _ROS_SERVICE_RequestParam_h
00003 #include <stdint.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006 #include "ros/msg.h"
00007 
00008 namespace rosserial_msgs
00009 {
00010 
00011 static const char REQUESTPARAM[] = "rosserial_msgs/RequestParam";
00012 
00013   class RequestParamRequest : public ros::Msg
00014   {
00015     public:
00016       const char* name;
00017 
00018     virtual int serialize(unsigned char *outbuffer) const
00019     {
00020       int offset = 0;
00021       uint32_t length_name = strlen(this->name);
00022       memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
00023       offset += 4;
00024       memcpy(outbuffer + offset, this->name, length_name);
00025       offset += length_name;
00026       return offset;
00027     }
00028 
00029     virtual int deserialize(unsigned char *inbuffer)
00030     {
00031       int offset = 0;
00032       uint32_t length_name;
00033       memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
00034       offset += 4;
00035       for(unsigned int k= offset; k< offset+length_name; ++k){
00036           inbuffer[k-1]=inbuffer[k];
00037       }
00038       inbuffer[offset+length_name-1]=0;
00039       this->name = (char *)(inbuffer + offset-1);
00040       offset += length_name;
00041      return offset;
00042     }
00043 
00044     const char * getType(){ return REQUESTPARAM; };
00045     const char * getMD5(){ return "c1f3d28f1b044c871e6eff2e9fc3c667"; };
00046 
00047   };
00048 
00049   class RequestParamResponse : public ros::Msg
00050   {
00051     public:
00052       uint8_t ints_length;
00053       int32_t st_ints;
00054       int32_t * ints;
00055       uint8_t floats_length;
00056       float st_floats;
00057       float * floats;
00058       uint8_t strings_length;
00059       char* st_strings;
00060       char* * strings;
00061 
00062     virtual int serialize(unsigned char *outbuffer) const
00063     {
00064       int offset = 0;
00065       *(outbuffer + offset++) = ints_length;
00066       *(outbuffer + offset++) = 0;
00067       *(outbuffer + offset++) = 0;
00068       *(outbuffer + offset++) = 0;
00069       for( uint8_t i = 0; i < ints_length; i++){
00070       union {
00071         int32_t real;
00072         uint32_t base;
00073       } u_intsi;
00074       u_intsi.real = this->ints[i];
00075       *(outbuffer + offset + 0) = (u_intsi.base >> (8 * 0)) & 0xFF;
00076       *(outbuffer + offset + 1) = (u_intsi.base >> (8 * 1)) & 0xFF;
00077       *(outbuffer + offset + 2) = (u_intsi.base >> (8 * 2)) & 0xFF;
00078       *(outbuffer + offset + 3) = (u_intsi.base >> (8 * 3)) & 0xFF;
00079       offset += sizeof(this->ints[i]);
00080       }
00081       *(outbuffer + offset++) = floats_length;
00082       *(outbuffer + offset++) = 0;
00083       *(outbuffer + offset++) = 0;
00084       *(outbuffer + offset++) = 0;
00085       for( uint8_t i = 0; i < floats_length; i++){
00086       union {
00087         float real;
00088         uint32_t base;
00089       } u_floatsi;
00090       u_floatsi.real = this->floats[i];
00091       *(outbuffer + offset + 0) = (u_floatsi.base >> (8 * 0)) & 0xFF;
00092       *(outbuffer + offset + 1) = (u_floatsi.base >> (8 * 1)) & 0xFF;
00093       *(outbuffer + offset + 2) = (u_floatsi.base >> (8 * 2)) & 0xFF;
00094       *(outbuffer + offset + 3) = (u_floatsi.base >> (8 * 3)) & 0xFF;
00095       offset += sizeof(this->floats[i]);
00096       }
00097       *(outbuffer + offset++) = strings_length;
00098       *(outbuffer + offset++) = 0;
00099       *(outbuffer + offset++) = 0;
00100       *(outbuffer + offset++) = 0;
00101       for( uint8_t i = 0; i < strings_length; i++){
00102       uint32_t length_stringsi = strlen(this->strings[i]);
00103       memcpy(outbuffer + offset, &length_stringsi, sizeof(uint32_t));
00104       offset += 4;
00105       memcpy(outbuffer + offset, this->strings[i], length_stringsi);
00106       offset += length_stringsi;
00107       }
00108       return offset;
00109     }
00110 
00111     virtual int deserialize(unsigned char *inbuffer)
00112     {
00113       int offset = 0;
00114       uint8_t ints_lengthT = *(inbuffer + offset++);
00115       if(ints_lengthT > ints_length)
00116         this->ints = (int32_t*)realloc(this->ints, ints_lengthT * sizeof(int32_t));
00117       offset += 3;
00118       ints_length = ints_lengthT;
00119       for( uint8_t i = 0; i < ints_length; i++){
00120       union {
00121         int32_t real;
00122         uint32_t base;
00123       } u_st_ints;
00124       u_st_ints.base = 0;
00125       u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00126       u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00127       u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00128       u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00129       this->st_ints = u_st_ints.real;
00130       offset += sizeof(this->st_ints);
00131         memcpy( &(this->ints[i]), &(this->st_ints), sizeof(int32_t));
00132       }
00133       uint8_t floats_lengthT = *(inbuffer + offset++);
00134       if(floats_lengthT > floats_length)
00135         this->floats = (float*)realloc(this->floats, floats_lengthT * sizeof(float));
00136       offset += 3;
00137       floats_length = floats_lengthT;
00138       for( uint8_t i = 0; i < floats_length; i++){
00139       union {
00140         float real;
00141         uint32_t base;
00142       } u_st_floats;
00143       u_st_floats.base = 0;
00144       u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00145       u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00146       u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00147       u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00148       this->st_floats = u_st_floats.real;
00149       offset += sizeof(this->st_floats);
00150         memcpy( &(this->floats[i]), &(this->st_floats), sizeof(float));
00151       }
00152       uint8_t strings_lengthT = *(inbuffer + offset++);
00153       if(strings_lengthT > strings_length)
00154         this->strings = (char**)realloc(this->strings, strings_lengthT * sizeof(char*));
00155       offset += 3;
00156       strings_length = strings_lengthT;
00157       for( uint8_t i = 0; i < strings_length; i++){
00158       uint32_t length_st_strings;
00159       memcpy(&length_st_strings, (inbuffer + offset), sizeof(uint32_t));
00160       offset += 4;
00161       for(unsigned int k= offset; k< offset+length_st_strings; ++k){
00162           inbuffer[k-1]=inbuffer[k];
00163       }
00164       inbuffer[offset+length_st_strings-1]=0;
00165       this->st_strings = (char *)(inbuffer + offset-1);
00166       offset += length_st_strings;
00167         memcpy( &(this->strings[i]), &(this->st_strings), sizeof(char*));
00168       }
00169      return offset;
00170     }
00171 
00172     const char * getType(){ return REQUESTPARAM; };
00173     const char * getMD5(){ return "9f0e98bda65981986ddf53afa7a40e49"; };
00174 
00175   };
00176 
00177   class RequestParam {
00178     public:
00179     typedef RequestParamRequest Request;
00180     typedef RequestParamResponse Response;
00181   };
00182 
00183 }
00184 #endif


ric_mc
Author(s): RoboTiCan
autogenerated on Fri May 20 2016 03:48:56