60#ifndef WHITEBOARD_POSTER_STRING_CONVERSION
61#define WHITEBOARD_POSTER_STRING_CONVERSION
72#pragma clang diagnostic push
73#pragma clang diagnostic ignored "-Wunused-macros"
77#elif defined(__APPLE__)
78# include <machine/endian.h>
79# include <architecture/byte_order.h>
80# define bswap_16(x) NXSwapShort(x)
81# define bswap_32(x) NXSwapInt(x)
82# define bswap_64(x) NXSwapLongLong(x)
84# define bswap_16(x) __builtin_bswap16(x)
85# define bswap_32(x) __builtin_bswap32(x)
86# define bswap_64(x) __builtin_bswap64(x)
91#if (!defined(__BYTE_ORDER) && !defined(__LITTLE_ENDIAN)) || (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN)
92# if !defined(htonll) && !defined(ntohll)
93# define htonll(x) bswap_64(x)
94# define ntohll(x) bswap_64(x)
96# if !defined(htonl) && !defined(ntohl)
97# define htonl(x) bswap_32(x)
98# define ntohl(x) bswap_32(x)
100# if !defined(htons) && !defined(ntohs)
101# define htons(x) bswap_16(x)
102# define ntohs(x) bswap_16(x)
105# if !defined(htonll) && !defined(ntohll)
106# define htonll(x) (x)
107# define ntohll(x) (x)
109# if !defined(htonl) && !defined(ntohl)
113# if !defined(htons) && !defined(ntohs)
118#pragma clang diagnostic pop
127#pragma clang diagnostic push
128#pragma clang diagnostic ignored "-Wunused-variable"
130 if (len >= bufferSize) {
133 len += snprintf(descString + len, bufferSize - len,
"forward=%lf", (
double) self->forward);
134 if (len >= bufferSize) {
137 len = gu_strlcat(descString,
", ", bufferSize);
138 if (len >= bufferSize) {
141 len += snprintf(descString + len, bufferSize - len,
"left=%lf", (
double) self->left);
142 if (len >= bufferSize) {
145 len = gu_strlcat(descString,
", ", bufferSize);
146 if (len >= bufferSize) {
149 len += snprintf(descString + len, bufferSize - len,
"turn=%lf", (
double) self->turn);
151#pragma clang diagnostic pop
159#pragma clang diagnostic push
160#pragma clang diagnostic ignored "-Wunused-variable"
162 if (len >= bufferSize) {
165 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->forward);
166 if (len >= bufferSize) {
169 len = gu_strlcat(toString,
", ", bufferSize);
170 if (len >= bufferSize) {
173 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->left);
174 if (len >= bufferSize) {
177 len = gu_strlcat(toString,
", ", bufferSize);
178 if (len >= bufferSize) {
181 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->turn);
183#pragma clang diagnostic pop
191 size_t temp_length = strlen(str);
192 int length = (temp_length <= INT_MAX) ? ((
int)((ssize_t)temp_length)) : -1;
197 char* var_str = &var_str_buffer[0];
199 char* key = &key_buffer[0];
206 if (index == 0 && str[0] ==
'{') {
212 for (
int i = index; i < length; i++) {
214 if (bracecount == 0 && str[i] ==
'=') {
219 if (bracecount == 0 && isspace(str[i])) {
226 if (bracecount == 0 && str[i] ==
',') {
236 if (bracecount < 0) {
241 if (i == length - 1) {
245 if (endKey >= startKey && endKey - startKey < length) {
246 strncpy(key, str + startKey, ((
size_t)(endKey - startKey) + 1));
247 key[(endKey - startKey) + 1] = 0;
251 strncpy(var_str, str + startVar, ((
size_t)(index - startVar) + 1));
252 var_str[(index - startVar) + 1] = 0;
258 if (strlen(key) > 0) {
259 if (0 == strcmp(
"forward", key)) {
261 }
else if (0 == strcmp(
"left", key)) {
263 }
else if (0 == strcmp(
"turn", key)) {
273 self->forward = ((float)atof(var_str));
278 self->left = ((float)atof(var_str));
283 self->turn = ((float)atof(var_str));
290 }
while(index < length);
301 uint16_t bit_offset = 0;
318 uint16_t bit_offset = 0;
WHITEBOARD_POSTER_STRING_CONVERSION.
const char * wb_odometry_to_string(const struct wb_odometry *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_odometry_description(const struct wb_odometry *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_odometry * wb_odometry_from_string(struct wb_odometry *self, const char *str)
Convert from a string.
size_t wb_odometry_to_network_serialised(const struct wb_odometry *self, char *dst)
Convert to a compressed, serialised, network byte order byte stream.
size_t wb_odometry_from_network_serialised(const char *src, struct wb_odometry *dst)
Convert from a compressed, serialised, network byte order byte stream.
#define ODOMETRY_DESC_BUFFER_SIZE