Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / std_msgs / String.h @ c1426757

History | View | Annotate | Download (1.12 KB)

1
#ifndef _ROS_std_msgs_String_h
2
#define _ROS_std_msgs_String_h
3

    
4
#include <stdint.h>
5
#include <string.h>
6
#include <stdlib.h>
7
#include "ros/msg.h"
8

    
9
namespace std_msgs
10
{
11

    
12
  class String : public ros::Msg
13
  {
14
    public:
15
      char * data;
16

    
17
    virtual int serialize(unsigned char *outbuffer) const
18
    {
19
      int offset = 0;
20
      uint32_t * length_data = (uint32_t *)(outbuffer + offset);
21
      *length_data = strlen( (const char*) this->data);
22
      offset += 4;
23
      memcpy(outbuffer + offset, this->data, *length_data);
24
      offset += *length_data;
25
      return offset;
26
    }
27

    
28
    virtual int deserialize(unsigned char *inbuffer)
29
    {
30
      int offset = 0;
31
      uint32_t length_data = *(uint32_t *)(inbuffer + offset);
32
      offset += 4;
33
      for(unsigned int k= offset; k< offset+length_data; ++k){
34
          inbuffer[k-1]=inbuffer[k];
35
      }
36
      inbuffer[offset+length_data-1]=0;
37
      this->data = (char *)(inbuffer + offset-1);
38
      offset += length_data;
39
     return offset;
40
    }
41

    
42
    const char * getType(){ return "std_msgs/String"; };
43
    const char * getMD5(){ return "992ce8a1687cec8c8bd883ec73ca41d1"; };
44

    
45
  };
46

    
47
}
48
#endif