Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
dynamic_reconfigure/StrParameter.h@2:fa426560b283, 2021-05-27 (annotated)
- Committer:
- krogedal
- Date:
- Thu May 27 19:25:46 2021 +0000
- Revision:
- 2:fa426560b283
- Parent:
- 0:04ac6be8229a
no change
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| Gary Servin | 0:04ac6be8229a | 1 | #ifndef _ROS_dynamic_reconfigure_StrParameter_h | 
| Gary Servin | 0:04ac6be8229a | 2 | #define _ROS_dynamic_reconfigure_StrParameter_h | 
| Gary Servin | 0:04ac6be8229a | 3 | |
| Gary Servin | 0:04ac6be8229a | 4 | #include <stdint.h> | 
| Gary Servin | 0:04ac6be8229a | 5 | #include <string.h> | 
| Gary Servin | 0:04ac6be8229a | 6 | #include <stdlib.h> | 
| Gary Servin | 0:04ac6be8229a | 7 | #include "ros/msg.h" | 
| Gary Servin | 0:04ac6be8229a | 8 | |
| Gary Servin | 0:04ac6be8229a | 9 | namespace dynamic_reconfigure | 
| Gary Servin | 0:04ac6be8229a | 10 | { | 
| Gary Servin | 0:04ac6be8229a | 11 | |
| Gary Servin | 0:04ac6be8229a | 12 | class StrParameter : public ros::Msg | 
| Gary Servin | 0:04ac6be8229a | 13 | { | 
| Gary Servin | 0:04ac6be8229a | 14 | public: | 
| Gary Servin | 0:04ac6be8229a | 15 | typedef const char* _name_type; | 
| Gary Servin | 0:04ac6be8229a | 16 | _name_type name; | 
| Gary Servin | 0:04ac6be8229a | 17 | typedef const char* _value_type; | 
| Gary Servin | 0:04ac6be8229a | 18 | _value_type value; | 
| Gary Servin | 0:04ac6be8229a | 19 | |
| Gary Servin | 0:04ac6be8229a | 20 | StrParameter(): | 
| Gary Servin | 0:04ac6be8229a | 21 | name(""), | 
| Gary Servin | 0:04ac6be8229a | 22 | value("") | 
| Gary Servin | 0:04ac6be8229a | 23 | { | 
| Gary Servin | 0:04ac6be8229a | 24 | } | 
| Gary Servin | 0:04ac6be8229a | 25 | |
| Gary Servin | 0:04ac6be8229a | 26 | virtual int serialize(unsigned char *outbuffer) const | 
| Gary Servin | 0:04ac6be8229a | 27 | { | 
| Gary Servin | 0:04ac6be8229a | 28 | int offset = 0; | 
| Gary Servin | 0:04ac6be8229a | 29 | uint32_t length_name = strlen(this->name); | 
| Gary Servin | 0:04ac6be8229a | 30 | varToArr(outbuffer + offset, length_name); | 
| Gary Servin | 0:04ac6be8229a | 31 | offset += 4; | 
| Gary Servin | 0:04ac6be8229a | 32 | memcpy(outbuffer + offset, this->name, length_name); | 
| Gary Servin | 0:04ac6be8229a | 33 | offset += length_name; | 
| Gary Servin | 0:04ac6be8229a | 34 | uint32_t length_value = strlen(this->value); | 
| Gary Servin | 0:04ac6be8229a | 35 | varToArr(outbuffer + offset, length_value); | 
| Gary Servin | 0:04ac6be8229a | 36 | offset += 4; | 
| Gary Servin | 0:04ac6be8229a | 37 | memcpy(outbuffer + offset, this->value, length_value); | 
| Gary Servin | 0:04ac6be8229a | 38 | offset += length_value; | 
| Gary Servin | 0:04ac6be8229a | 39 | return offset; | 
| Gary Servin | 0:04ac6be8229a | 40 | } | 
| Gary Servin | 0:04ac6be8229a | 41 | |
| Gary Servin | 0:04ac6be8229a | 42 | virtual int deserialize(unsigned char *inbuffer) | 
| Gary Servin | 0:04ac6be8229a | 43 | { | 
| Gary Servin | 0:04ac6be8229a | 44 | int offset = 0; | 
| Gary Servin | 0:04ac6be8229a | 45 | uint32_t length_name; | 
| Gary Servin | 0:04ac6be8229a | 46 | arrToVar(length_name, (inbuffer + offset)); | 
| Gary Servin | 0:04ac6be8229a | 47 | offset += 4; | 
| Gary Servin | 0:04ac6be8229a | 48 | for(unsigned int k= offset; k< offset+length_name; ++k){ | 
| Gary Servin | 0:04ac6be8229a | 49 | inbuffer[k-1]=inbuffer[k]; | 
| Gary Servin | 0:04ac6be8229a | 50 | } | 
| Gary Servin | 0:04ac6be8229a | 51 | inbuffer[offset+length_name-1]=0; | 
| Gary Servin | 0:04ac6be8229a | 52 | this->name = (char *)(inbuffer + offset-1); | 
| Gary Servin | 0:04ac6be8229a | 53 | offset += length_name; | 
| Gary Servin | 0:04ac6be8229a | 54 | uint32_t length_value; | 
| Gary Servin | 0:04ac6be8229a | 55 | arrToVar(length_value, (inbuffer + offset)); | 
| Gary Servin | 0:04ac6be8229a | 56 | offset += 4; | 
| Gary Servin | 0:04ac6be8229a | 57 | for(unsigned int k= offset; k< offset+length_value; ++k){ | 
| Gary Servin | 0:04ac6be8229a | 58 | inbuffer[k-1]=inbuffer[k]; | 
| Gary Servin | 0:04ac6be8229a | 59 | } | 
| Gary Servin | 0:04ac6be8229a | 60 | inbuffer[offset+length_value-1]=0; | 
| Gary Servin | 0:04ac6be8229a | 61 | this->value = (char *)(inbuffer + offset-1); | 
| Gary Servin | 0:04ac6be8229a | 62 | offset += length_value; | 
| Gary Servin | 0:04ac6be8229a | 63 | return offset; | 
| Gary Servin | 0:04ac6be8229a | 64 | } | 
| Gary Servin | 0:04ac6be8229a | 65 | |
| Gary Servin | 0:04ac6be8229a | 66 | const char * getType(){ return "dynamic_reconfigure/StrParameter"; }; | 
| Gary Servin | 0:04ac6be8229a | 67 | const char * getMD5(){ return "bc6ccc4a57f61779c8eaae61e9f422e0"; }; | 
| Gary Servin | 0:04ac6be8229a | 68 | |
| Gary Servin | 0:04ac6be8229a | 69 | }; | 
| Gary Servin | 0:04ac6be8229a | 70 | |
| Gary Servin | 0:04ac6be8229a | 71 | } | 
| Gary Servin | 0:04ac6be8229a | 72 | #endif |