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 = gu_strlcat(descString, self->LHand_Touch_Left ?
"LHand_Touch_Left=true" :
"LHand_Touch_Left=false", bufferSize);
134 if (len >= bufferSize) {
137 len = gu_strlcat(descString,
", ", bufferSize);
138 if (len >= bufferSize) {
141 len = gu_strlcat(descString, self->LHand_Touch_Back ?
"LHand_Touch_Back=true" :
"LHand_Touch_Back=false", bufferSize);
142 if (len >= bufferSize) {
145 len = gu_strlcat(descString,
", ", bufferSize);
146 if (len >= bufferSize) {
149 len = gu_strlcat(descString, self->LHand_Touch_Right ?
"LHand_Touch_Right=true" :
"LHand_Touch_Right=false", bufferSize);
150 if (len >= bufferSize) {
153 len = gu_strlcat(descString,
", ", bufferSize);
154 if (len >= bufferSize) {
157 len = gu_strlcat(descString, self->RHand_Touch_Left ?
"RHand_Touch_Left=true" :
"RHand_Touch_Left=false", bufferSize);
158 if (len >= bufferSize) {
161 len = gu_strlcat(descString,
", ", bufferSize);
162 if (len >= bufferSize) {
165 len = gu_strlcat(descString, self->RHand_Touch_Back ?
"RHand_Touch_Back=true" :
"RHand_Touch_Back=false", bufferSize);
166 if (len >= bufferSize) {
169 len = gu_strlcat(descString,
", ", bufferSize);
170 if (len >= bufferSize) {
173 len = gu_strlcat(descString, self->RHand_Touch_Right ?
"RHand_Touch_Right=true" :
"RHand_Touch_Right=false", bufferSize);
175#pragma clang diagnostic pop
183#pragma clang diagnostic push
184#pragma clang diagnostic ignored "-Wunused-variable"
186 if (len >= bufferSize) {
189 len = gu_strlcat(toString, self->LHand_Touch_Left ?
"true" :
"false", bufferSize);
190 if (len >= bufferSize) {
193 len = gu_strlcat(toString,
", ", bufferSize);
194 if (len >= bufferSize) {
197 len = gu_strlcat(toString, self->LHand_Touch_Back ?
"true" :
"false", bufferSize);
198 if (len >= bufferSize) {
201 len = gu_strlcat(toString,
", ", bufferSize);
202 if (len >= bufferSize) {
205 len = gu_strlcat(toString, self->LHand_Touch_Right ?
"true" :
"false", bufferSize);
206 if (len >= bufferSize) {
209 len = gu_strlcat(toString,
", ", bufferSize);
210 if (len >= bufferSize) {
213 len = gu_strlcat(toString, self->RHand_Touch_Left ?
"true" :
"false", bufferSize);
214 if (len >= bufferSize) {
217 len = gu_strlcat(toString,
", ", bufferSize);
218 if (len >= bufferSize) {
221 len = gu_strlcat(toString, self->RHand_Touch_Back ?
"true" :
"false", bufferSize);
222 if (len >= bufferSize) {
225 len = gu_strlcat(toString,
", ", bufferSize);
226 if (len >= bufferSize) {
229 len = gu_strlcat(toString, self->RHand_Touch_Right ?
"true" :
"false", bufferSize);
231#pragma clang diagnostic pop
239 size_t temp_length = strlen(str);
240 int length = (temp_length <= INT_MAX) ? ((
int)((ssize_t)temp_length)) : -1;
245 char* var_str = &var_str_buffer[0];
247 char* key = &key_buffer[0];
254 if (index == 0 && str[0] ==
'{') {
260 for (
int i = index; i < length; i++) {
262 if (bracecount == 0 && str[i] ==
'=') {
267 if (bracecount == 0 && isspace(str[i])) {
274 if (bracecount == 0 && str[i] ==
',') {
284 if (bracecount < 0) {
289 if (i == length - 1) {
293 if (endKey >= startKey && endKey - startKey < length) {
294 strncpy(key, str + startKey, ((
size_t)(endKey - startKey) + 1));
295 key[(endKey - startKey) + 1] = 0;
299 strncpy(var_str, str + startVar, ((
size_t)(index - startVar) + 1));
300 var_str[(index - startVar) + 1] = 0;
306 if (strlen(key) > 0) {
307 if (0 == strcmp(
"LHand_Touch_Left", key)) {
309 }
else if (0 == strcmp(
"LHand_Touch_Back", key)) {
311 }
else if (0 == strcmp(
"LHand_Touch_Right", key)) {
313 }
else if (0 == strcmp(
"RHand_Touch_Left", key)) {
315 }
else if (0 == strcmp(
"RHand_Touch_Back", key)) {
317 }
else if (0 == strcmp(
"RHand_Touch_Right", key)) {
327 self->LHand_Touch_Left = strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0;
332 self->LHand_Touch_Back = strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0;
337 self->LHand_Touch_Right = strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0;
342 self->RHand_Touch_Left = strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0;
347 self->RHand_Touch_Back = strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0;
352 self->RHand_Touch_Right = strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0;
359 }
while(index < length);
370 uint16_t bit_offset = 0;
372 uint16_t
byte = bit_offset / 8;
373 uint16_t bit = 7 - (bit_offset % 8);
374 unsigned long newbit = !!(
self->LHand_Touch_Left ? 1U : 0U);
375 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
376 bit_offset = bit_offset + 1;
380 uint16_t
byte = bit_offset / 8;
381 uint16_t bit = 7 - (bit_offset % 8);
382 unsigned long newbit = !!(
self->LHand_Touch_Back ? 1U : 0U);
383 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
384 bit_offset = bit_offset + 1;
388 uint16_t
byte = bit_offset / 8;
389 uint16_t bit = 7 - (bit_offset % 8);
390 unsigned long newbit = !!(
self->LHand_Touch_Right ? 1U : 0U);
391 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
392 bit_offset = bit_offset + 1;
396 uint16_t
byte = bit_offset / 8;
397 uint16_t bit = 7 - (bit_offset % 8);
398 unsigned long newbit = !!(
self->RHand_Touch_Left ? 1U : 0U);
399 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
400 bit_offset = bit_offset + 1;
404 uint16_t
byte = bit_offset / 8;
405 uint16_t bit = 7 - (bit_offset % 8);
406 unsigned long newbit = !!(
self->RHand_Touch_Back ? 1U : 0U);
407 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
408 bit_offset = bit_offset + 1;
412 uint16_t
byte = bit_offset / 8;
413 uint16_t bit = 7 - (bit_offset % 8);
414 unsigned long newbit = !!(
self->RHand_Touch_Right ? 1U : 0U);
415 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
416 bit_offset = bit_offset + 1;
429 uint16_t bit_offset = 0;
431 uint16_t
byte = bit_offset / 8;
432 uint16_t bit = 7 - (bit_offset % 8);
433 char dataByte = src[byte];
434 unsigned char bitValue = (dataByte >> bit) & 1U;
436 bit_offset = bit_offset + 1;
440 uint16_t
byte = bit_offset / 8;
441 uint16_t bit = 7 - (bit_offset % 8);
442 char dataByte = src[byte];
443 unsigned char bitValue = (dataByte >> bit) & 1U;
445 bit_offset = bit_offset + 1;
449 uint16_t
byte = bit_offset / 8;
450 uint16_t bit = 7 - (bit_offset % 8);
451 char dataByte = src[byte];
452 unsigned char bitValue = (dataByte >> bit) & 1U;
454 bit_offset = bit_offset + 1;
458 uint16_t
byte = bit_offset / 8;
459 uint16_t bit = 7 - (bit_offset % 8);
460 char dataByte = src[byte];
461 unsigned char bitValue = (dataByte >> bit) & 1U;
463 bit_offset = bit_offset + 1;
467 uint16_t
byte = bit_offset / 8;
468 uint16_t bit = 7 - (bit_offset % 8);
469 char dataByte = src[byte];
470 unsigned char bitValue = (dataByte >> bit) & 1U;
472 bit_offset = bit_offset + 1;
476 uint16_t
byte = bit_offset / 8;
477 uint16_t bit = 7 - (bit_offset % 8);
478 char dataByte = src[byte];
479 unsigned char bitValue = (dataByte >> bit) & 1U;
481 bit_offset = bit_offset + 1;
WHITEBOARD_POSTER_STRING_CONVERSION.
bool RHand_Touch_Back
state of the hand capacitive sensor on the Back of Right Hand, on / off.
bool RHand_Touch_Right
state of the hand capacitive sensor on the Right side of Right Hand, on / off.
bool LHand_Touch_Right
state of the hand capacitive sensor on the Right side of Left Hand, on / off.
bool RHand_Touch_Left
state of the hand capacitive sensor on the Left side of Right Hand, on / off.
bool LHand_Touch_Left
state of the hand capacitive sensor on the Left side of Left Hand, on / off.
bool LHand_Touch_Back
state of the hand capacitive sensor on the Back of Left Hand, on / off.
size_t wb_sensors_hand_sensors_to_network_serialised(const struct wb_sensors_hand_sensors *self, char *dst)
Convert to a compressed, serialised, network byte order byte stream.
const char * wb_sensors_hand_sensors_description(const struct wb_sensors_hand_sensors *self, char *descString, size_t bufferSize)
Convert to a description string.
size_t wb_sensors_hand_sensors_from_network_serialised(const char *src, struct wb_sensors_hand_sensors *dst)
Convert from a compressed, serialised, network byte order byte stream.
const char * wb_sensors_hand_sensors_to_string(const struct wb_sensors_hand_sensors *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_sensors_hand_sensors * wb_sensors_hand_sensors_from_string(struct wb_sensors_hand_sensors *self, const char *str)
Convert from a string.
#define SENSORS_HAND_SENSORS_DESC_BUFFER_SIZE