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,
"HeadYaw=%lf", (
double) self->HeadYaw);
134 if (len >= bufferSize) {
137 len = gu_strlcat(descString,
", ", bufferSize);
138 if (len >= bufferSize) {
141 len += snprintf(descString + len, bufferSize - len,
"HeadPitch=%lf", (
double) self->HeadPitch);
142 if (len >= bufferSize) {
145 len = gu_strlcat(descString,
", ", bufferSize);
146 if (len >= bufferSize) {
149 len += snprintf(descString + len, bufferSize - len,
"LShoulderPitch=%lf", (
double) self->LShoulderPitch);
150 if (len >= bufferSize) {
153 len = gu_strlcat(descString,
", ", bufferSize);
154 if (len >= bufferSize) {
157 len += snprintf(descString + len, bufferSize - len,
"LShoulderRoll=%lf", (
double) self->LShoulderRoll);
158 if (len >= bufferSize) {
161 len = gu_strlcat(descString,
", ", bufferSize);
162 if (len >= bufferSize) {
165 len += snprintf(descString + len, bufferSize - len,
"LElbowYaw=%lf", (
double) self->LElbowYaw);
166 if (len >= bufferSize) {
169 len = gu_strlcat(descString,
", ", bufferSize);
170 if (len >= bufferSize) {
173 len += snprintf(descString + len, bufferSize - len,
"LElbowRoll=%lf", (
double) self->LElbowRoll);
174 if (len >= bufferSize) {
177 len = gu_strlcat(descString,
", ", bufferSize);
178 if (len >= bufferSize) {
181 len += snprintf(descString + len, bufferSize - len,
"RShoulderPitch=%lf", (
double) self->RShoulderPitch);
182 if (len >= bufferSize) {
185 len = gu_strlcat(descString,
", ", bufferSize);
186 if (len >= bufferSize) {
189 len += snprintf(descString + len, bufferSize - len,
"RShoulderRoll=%lf", (
double) self->RShoulderRoll);
190 if (len >= bufferSize) {
193 len = gu_strlcat(descString,
", ", bufferSize);
194 if (len >= bufferSize) {
197 len += snprintf(descString + len, bufferSize - len,
"RElbowYaw=%lf", (
double) self->RElbowYaw);
198 if (len >= bufferSize) {
201 len = gu_strlcat(descString,
", ", bufferSize);
202 if (len >= bufferSize) {
205 len += snprintf(descString + len, bufferSize - len,
"RElbowRoll=%lf", (
double) self->RElbowRoll);
206 if (len >= bufferSize) {
209 len = gu_strlcat(descString,
", ", bufferSize);
210 if (len >= bufferSize) {
213 len += snprintf(descString + len, bufferSize - len,
"LWristYaw=%lf", (
double) self->LWristYaw);
214 if (len >= bufferSize) {
217 len = gu_strlcat(descString,
", ", bufferSize);
218 if (len >= bufferSize) {
221 len += snprintf(descString + len, bufferSize - len,
"RWristYaw=%lf", (
double) self->RWristYaw);
223#pragma clang diagnostic pop
231#pragma clang diagnostic push
232#pragma clang diagnostic ignored "-Wunused-variable"
234 if (len >= bufferSize) {
237 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->HeadYaw);
238 if (len >= bufferSize) {
241 len = gu_strlcat(toString,
", ", bufferSize);
242 if (len >= bufferSize) {
245 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->HeadPitch);
246 if (len >= bufferSize) {
249 len = gu_strlcat(toString,
", ", bufferSize);
250 if (len >= bufferSize) {
253 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->LShoulderPitch);
254 if (len >= bufferSize) {
257 len = gu_strlcat(toString,
", ", bufferSize);
258 if (len >= bufferSize) {
261 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->LShoulderRoll);
262 if (len >= bufferSize) {
265 len = gu_strlcat(toString,
", ", bufferSize);
266 if (len >= bufferSize) {
269 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->LElbowYaw);
270 if (len >= bufferSize) {
273 len = gu_strlcat(toString,
", ", bufferSize);
274 if (len >= bufferSize) {
277 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->LElbowRoll);
278 if (len >= bufferSize) {
281 len = gu_strlcat(toString,
", ", bufferSize);
282 if (len >= bufferSize) {
285 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->RShoulderPitch);
286 if (len >= bufferSize) {
289 len = gu_strlcat(toString,
", ", bufferSize);
290 if (len >= bufferSize) {
293 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->RShoulderRoll);
294 if (len >= bufferSize) {
297 len = gu_strlcat(toString,
", ", bufferSize);
298 if (len >= bufferSize) {
301 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->RElbowYaw);
302 if (len >= bufferSize) {
305 len = gu_strlcat(toString,
", ", bufferSize);
306 if (len >= bufferSize) {
309 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->RElbowRoll);
310 if (len >= bufferSize) {
313 len = gu_strlcat(toString,
", ", bufferSize);
314 if (len >= bufferSize) {
317 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->LWristYaw);
318 if (len >= bufferSize) {
321 len = gu_strlcat(toString,
", ", bufferSize);
322 if (len >= bufferSize) {
325 len += snprintf(toString + len, bufferSize - len,
"%lf", (
double) self->RWristYaw);
327#pragma clang diagnostic pop
335 size_t temp_length = strlen(str);
336 int length = (temp_length <= INT_MAX) ? ((
int)((ssize_t)temp_length)) : -1;
341 char* var_str = &var_str_buffer[0];
343 char* key = &key_buffer[0];
350 if (index == 0 && str[0] ==
'{') {
356 for (
int i = index; i < length; i++) {
358 if (bracecount == 0 && str[i] ==
'=') {
363 if (bracecount == 0 && isspace(str[i])) {
370 if (bracecount == 0 && str[i] ==
',') {
380 if (bracecount < 0) {
385 if (i == length - 1) {
389 if (endKey >= startKey && endKey - startKey < length) {
390 strncpy(key, str + startKey, ((
size_t)(endKey - startKey) + 1));
391 key[(endKey - startKey) + 1] = 0;
395 strncpy(var_str, str + startVar, ((
size_t)(index - startVar) + 1));
396 var_str[(index - startVar) + 1] = 0;
402 if (strlen(key) > 0) {
403 if (0 == strcmp(
"HeadYaw", key)) {
405 }
else if (0 == strcmp(
"HeadPitch", key)) {
407 }
else if (0 == strcmp(
"LShoulderPitch", key)) {
409 }
else if (0 == strcmp(
"LShoulderRoll", key)) {
411 }
else if (0 == strcmp(
"LElbowYaw", key)) {
413 }
else if (0 == strcmp(
"LElbowRoll", key)) {
415 }
else if (0 == strcmp(
"RShoulderPitch", key)) {
417 }
else if (0 == strcmp(
"RShoulderRoll", key)) {
419 }
else if (0 == strcmp(
"RElbowYaw", key)) {
421 }
else if (0 == strcmp(
"RElbowRoll", key)) {
423 }
else if (0 == strcmp(
"LWristYaw", key)) {
425 }
else if (0 == strcmp(
"RWristYaw", key)) {
435 self->HeadYaw = ((float)atof(var_str));
440 self->HeadPitch = ((float)atof(var_str));
445 self->LShoulderPitch = ((float)atof(var_str));
450 self->LShoulderRoll = ((float)atof(var_str));
455 self->LElbowYaw = ((float)atof(var_str));
460 self->LElbowRoll = ((float)atof(var_str));
465 self->RShoulderPitch = ((float)atof(var_str));
470 self->RShoulderRoll = ((float)atof(var_str));
475 self->RElbowYaw = ((float)atof(var_str));
480 self->RElbowRoll = ((float)atof(var_str));
485 self->LWristYaw = ((float)atof(var_str));
490 self->RWristYaw = ((float)atof(var_str));
497 }
while(index < length);
508 uint16_t bit_offset = 0;
543 uint16_t bit_offset = 0;
WHITEBOARD_POSTER_STRING_CONVERSION.
struct wb_sensors_torsojointsensors * wb_sensors_torsojointsensors_from_string(struct wb_sensors_torsojointsensors *self, const char *str)
Convert from a string.
size_t wb_sensors_torsojointsensors_to_network_serialised(const struct wb_sensors_torsojointsensors *self, char *dst)
Convert to a compressed, serialised, network byte order byte stream.
const char * wb_sensors_torsojointsensors_to_string(const struct wb_sensors_torsojointsensors *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_sensors_torsojointsensors_description(const struct wb_sensors_torsojointsensors *self, char *descString, size_t bufferSize)
Convert to a description string.
size_t wb_sensors_torsojointsensors_from_network_serialised(const char *src, struct wb_sensors_torsojointsensors *dst)
Convert from a compressed, serialised, network byte order byte stream.
#define SENSORS_TORSOJOINTSENSORS_DESC_BUFFER_SIZE