kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
KeyValue.h
Go to the documentation of this file.
1 #ifndef _ROS_diagnostic_msgs_KeyValue_h
2 #define _ROS_diagnostic_msgs_KeyValue_h
3 
4 #include <stdint.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include "ros/msg.h"
8 
9 namespace diagnostic_msgs
10 {
11 
12  class KeyValue : public ros::Msg
13  {
14  public:
15  const char* key;
16  const char* value;
17 
19  key(""),
20  value("")
21  {
22  }
23 
24  virtual int serialize(unsigned char *outbuffer) const
25  {
26  int offset = 0;
27  uint32_t length_key = strlen(this->key);
28  memcpy(outbuffer + offset, &length_key, sizeof(uint32_t));
29  offset += 4;
30  memcpy(outbuffer + offset, this->key, length_key);
31  offset += length_key;
32  uint32_t length_value = strlen(this->value);
33  memcpy(outbuffer + offset, &length_value, sizeof(uint32_t));
34  offset += 4;
35  memcpy(outbuffer + offset, this->value, length_value);
36  offset += length_value;
37  return offset;
38  }
39 
40  virtual int deserialize(unsigned char *inbuffer)
41  {
42  int offset = 0;
43  uint32_t length_key;
44  memcpy(&length_key, (inbuffer + offset), sizeof(uint32_t));
45  offset += 4;
46  for(unsigned int k= offset; k< offset+length_key; ++k){
47  inbuffer[k-1]=inbuffer[k];
48  }
49  inbuffer[offset+length_key-1]=0;
50  this->key = (char *)(inbuffer + offset-1);
51  offset += length_key;
52  uint32_t length_value;
53  memcpy(&length_value, (inbuffer + offset), sizeof(uint32_t));
54  offset += 4;
55  for(unsigned int k= offset; k< offset+length_value; ++k){
56  inbuffer[k-1]=inbuffer[k];
57  }
58  inbuffer[offset+length_value-1]=0;
59  this->value = (char *)(inbuffer + offset-1);
60  offset += length_value;
61  return offset;
62  }
63 
64  const char * getType(){ return "diagnostic_msgs/KeyValue"; };
65  const char * getMD5(){ return "cf57fdc6617a881a88c16e768132149c"; };
66 
67  };
68 
69 }
70 #endif
virtual int serialize(unsigned char *outbuffer) const
Definition: KeyValue.h:24
const char * getType()
Definition: KeyValue.h:64
const char * key
Definition: KeyValue.h:15
KeyValue()
Definition: KeyValue.h:18
const char * getMD5()
Definition: KeyValue.h:65
Definition: KeyValue.h:12
virtual int deserialize(unsigned char *inbuffer)
Definition: KeyValue.h:40
Definition: msg.h:43
const char * value
Definition: KeyValue.h:16