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,
"LShoulderPitch=%lf", (
double) self->LShoulderPitch);
134 if (len >= bufferSize) {
137 len = gu_strlcat(descString,
", ", bufferSize);
138 if (len >= bufferSize) {
141 len += snprintf(descString + len, bufferSize - len,
"LShoulderRoll=%lf", (
double) self->LShoulderRoll);
142 if (len >= bufferSize) {
145 len = gu_strlcat(descString,
", ", bufferSize);
146 if (len >= bufferSize) {
149 len += snprintf(descString + len, bufferSize - len,
"LElbowRoll=%lf", (
double) self->LElbowRoll);
150 if (len >= bufferSize) {
153 len = gu_strlcat(descString,
", ", bufferSize);
154 if (len >= bufferSize) {
157 len += snprintf(descString + len, bufferSize - len,
"LElbowYaw=%lf", (
double) self->LElbowYaw);
158 if (len >= bufferSize) {
161 len = gu_strlcat(descString,
", ", bufferSize);
162 if (len >= bufferSize) {
165 len += snprintf(descString + len, bufferSize - len,
"RShoulderPitch=%lf", (
double) self->RShoulderPitch);
166 if (len >= bufferSize) {
169 len = gu_strlcat(descString,
", ", bufferSize);
170 if (len >= bufferSize) {
173 len += snprintf(descString + len, bufferSize - len,
"RShoulderRoll=%lf", (
double) self->RShoulderRoll);
174 if (len >= bufferSize) {
177 len = gu_strlcat(descString,
", ", bufferSize);
178 if (len >= bufferSize) {
181 len += snprintf(descString + len, bufferSize - len,
"RElbowRoll=%lf", (
double) self->RElbowRoll);
182 if (len >= bufferSize) {
185 len = gu_strlcat(descString,
", ", bufferSize);
186 if (len >= bufferSize) {
189 len += snprintf(descString + len, bufferSize - len,
"RElbowYaw=%lf", (
double) self->RElbowYaw);
190 if (len >= bufferSize) {
193 len = gu_strlcat(descString,
", ", bufferSize);
194 if (len >= bufferSize) {
197 len += snprintf(descString + len, bufferSize - len,
"LWristYaw=%lf", (
double) self->LWristYaw);
198 if (len >= bufferSize) {
201 len = gu_strlcat(descString,
", ", bufferSize);
202 if (len >= bufferSize) {
205 len += snprintf(descString + len, bufferSize - len,
"RWristYaw=%lf", (
double) self->RWristYaw);
207#pragma clang diagnostic pop
215#pragma clang diagnostic push
216#pragma clang diagnostic ignored "-Wunused-variable"
218 if (len >= bufferSize) {
221 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->LShoulderPitch);
222 if (len >= bufferSize) {
225 len = gu_strlcat(toString,
", ", bufferSize);
226 if (len >= bufferSize) {
229 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->LShoulderRoll);
230 if (len >= bufferSize) {
233 len = gu_strlcat(toString,
", ", bufferSize);
234 if (len >= bufferSize) {
237 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->LElbowRoll);
238 if (len >= bufferSize) {
241 len = gu_strlcat(toString,
", ", bufferSize);
242 if (len >= bufferSize) {
245 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->LElbowYaw);
246 if (len >= bufferSize) {
249 len = gu_strlcat(toString,
", ", bufferSize);
250 if (len >= bufferSize) {
253 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->RShoulderPitch);
254 if (len >= bufferSize) {
257 len = gu_strlcat(toString,
", ", bufferSize);
258 if (len >= bufferSize) {
261 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->RShoulderRoll);
262 if (len >= bufferSize) {
265 len = gu_strlcat(toString,
", ", bufferSize);
266 if (len >= bufferSize) {
269 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->RElbowRoll);
270 if (len >= bufferSize) {
273 len = gu_strlcat(toString,
", ", bufferSize);
274 if (len >= bufferSize) {
277 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->RElbowYaw);
278 if (len >= bufferSize) {
281 len = gu_strlcat(toString,
", ", bufferSize);
282 if (len >= bufferSize) {
285 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->LWristYaw);
286 if (len >= bufferSize) {
289 len = gu_strlcat(toString,
", ", bufferSize);
290 if (len >= bufferSize) {
293 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->RWristYaw);
295#pragma clang diagnostic pop
303 size_t temp_length = strlen(str);
304 int length = (temp_length <= INT_MAX) ? ((
int)((ssize_t)temp_length)) : -1;
309 char* var_str = &var_str_buffer[0];
311 char* key = &key_buffer[0];
318 if (index == 0 && str[0] ==
'{') {
324 for (
int i = index; i < length; i++) {
326 if (bracecount == 0 && str[i] ==
'=') {
331 if (bracecount == 0 && isspace(str[i])) {
338 if (bracecount == 0 && str[i] ==
',') {
348 if (bracecount < 0) {
353 if (i == length - 1) {
357 if (endKey >= startKey && endKey - startKey < length) {
358 strncpy(key, str + startKey, ((
size_t)(endKey - startKey) + 1));
359 key[(endKey - startKey) + 1] = 0;
363 strncpy(var_str, str + startVar, ((
size_t)(index - startVar) + 1));
364 var_str[(index - startVar) + 1] = 0;
370 if (strlen(key) > 0) {
371 if (0 == strcmp(
"LShoulderPitch", key)) {
373 }
else if (0 == strcmp(
"LShoulderRoll", key)) {
375 }
else if (0 == strcmp(
"LElbowRoll", key)) {
377 }
else if (0 == strcmp(
"LElbowYaw", key)) {
379 }
else if (0 == strcmp(
"RShoulderPitch", key)) {
381 }
else if (0 == strcmp(
"RShoulderRoll", key)) {
383 }
else if (0 == strcmp(
"RElbowRoll", key)) {
385 }
else if (0 == strcmp(
"RElbowYaw", key)) {
387 }
else if (0 == strcmp(
"LWristYaw", key)) {
389 }
else if (0 == strcmp(
"RWristYaw", key)) {
399 self->LShoulderPitch = ((float)atof(var_str));
404 self->LShoulderRoll = ((float)atof(var_str));
409 self->LElbowRoll = ((float)atof(var_str));
414 self->LElbowYaw = ((float)atof(var_str));
419 self->RShoulderPitch = ((float)atof(var_str));
424 self->RShoulderRoll = ((float)atof(var_str));
429 self->RElbowRoll = ((float)atof(var_str));
434 self->RElbowYaw = ((float)atof(var_str));
439 self->LWristYaw = ((float)atof(var_str));
444 self->RWristYaw = ((float)atof(var_str));
451 }
while(index < length);
462 uint16_t bit_offset = 0;
493 uint16_t bit_offset = 0;
WHITEBOARD_POSTER_STRING_CONVERSION.
const char * wb_sensors_armjointsensors_to_string(const struct wb_sensors_armjointsensors *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_sensors_armjointsensors * wb_sensors_armjointsensors_from_string(struct wb_sensors_armjointsensors *self, const char *str)
Convert from a string.
const char * wb_sensors_armjointsensors_description(const struct wb_sensors_armjointsensors *self, char *descString, size_t bufferSize)
Convert to a description string.
size_t wb_sensors_armjointsensors_from_network_serialised(const char *src, struct wb_sensors_armjointsensors *dst)
Convert from a compressed, serialised, network byte order byte stream.
size_t wb_sensors_armjointsensors_to_network_serialised(const struct wb_sensors_armjointsensors *self, char *dst)
Convert to a compressed, serialised, network byte order byte stream.
#define SENSORS_ARMJOINTSENSORS_DESC_BUFFER_SIZE