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 switch (self->featureType) {
136 len += snprintf(descString + len, bufferSize - len,
"featureType=FeatureTypeCircle");
141 len += snprintf(descString + len, bufferSize - len,
"featureType=FeatureTypeL");
146 len += snprintf(descString + len, bufferSize - len,
"featureType=FeatureTypeT");
151 len += snprintf(descString + len, bufferSize - len,
"featureType=FeatureTypeX");
156 len += snprintf(descString + len, bufferSize - len,
"featureType=NUMBER_OF_FEATURE_TYPES");
160 if (len >= bufferSize) {
163 len = gu_strlcat(descString,
", ", bufferSize);
164 if (len >= bufferSize) {
167 len = gu_strlcat(descString,
"coordinate={", bufferSize);
168 if (len >= bufferSize) {
172 char* coordinate_p = coordinate_buffer;
174 len = gu_strlcat(descString, coordinate_p, bufferSize);
175 if (len >= bufferSize) {
178 len = gu_strlcat(descString,
"}", bufferSize);
180#pragma clang diagnostic pop
188#pragma clang diagnostic push
189#pragma clang diagnostic ignored "-Wunused-variable"
191 if (len >= bufferSize) {
194 switch (self->featureType) {
197 len += snprintf(toString + len, bufferSize - len,
"FeatureTypeCircle");
202 len += snprintf(toString + len, bufferSize - len,
"FeatureTypeL");
207 len += snprintf(toString + len, bufferSize - len,
"FeatureTypeT");
212 len += snprintf(toString + len, bufferSize - len,
"FeatureTypeX");
217 len += snprintf(toString + len, bufferSize - len,
"NUMBER_OF_FEATURE_TYPES");
221 if (len >= bufferSize) {
224 len = gu_strlcat(toString,
", ", bufferSize);
225 if (len >= bufferSize) {
228 len = gu_strlcat(toString,
"{", bufferSize);
229 if (len >= bufferSize) {
233 char* coordinate_p = coordinate_buffer;
235 len = gu_strlcat(toString, coordinate_p, bufferSize);
236 if (len >= bufferSize) {
239 len = gu_strlcat(toString,
"}", bufferSize);
241#pragma clang diagnostic pop
249 size_t temp_length = strlen(str);
250 int length = (temp_length <= INT_MAX) ? ((
int)((ssize_t)temp_length)) : -1;
255 char* var_str = &var_str_buffer[0];
257 char* key = &key_buffer[0];
264 if (index == 0 && str[0] ==
'{') {
270 for (
int i = index; i < length; i++) {
272 if (bracecount == 0 && str[i] ==
'=') {
277 if (bracecount == 0 && isspace(str[i])) {
284 if (bracecount == 0 && str[i] ==
',') {
294 if (bracecount < 0) {
299 if (i == length - 1) {
303 if (endKey >= startKey && endKey - startKey < length) {
304 strncpy(key, str + startKey, ((
size_t)(endKey - startKey) + 1));
305 key[(endKey - startKey) + 1] = 0;
309 strncpy(var_str, str + startVar, ((
size_t)(index - startVar) + 1));
310 var_str[(index - startVar) + 1] = 0;
316 if (strlen(key) > 0) {
317 if (0 == strcmp(
"featureType", key)) {
319 }
else if (0 == strcmp(
"coordinate", key)) {
329 if (strcmp(
"FeatureTypeCircle", var_str) == 0) {
330#pragma clang diagnostic push
331#pragma clang diagnostic ignored "-Wbad-function-cast"
333#pragma clang diagnostic pop
334 }
else if (strcmp(
"FeatureTypeL", var_str) == 0) {
335#pragma clang diagnostic push
336#pragma clang diagnostic ignored "-Wbad-function-cast"
338#pragma clang diagnostic pop
339 }
else if (strcmp(
"FeatureTypeT", var_str) == 0) {
340#pragma clang diagnostic push
341#pragma clang diagnostic ignored "-Wbad-function-cast"
343#pragma clang diagnostic pop
344 }
else if (strcmp(
"FeatureTypeX", var_str) == 0) {
345#pragma clang diagnostic push
346#pragma clang diagnostic ignored "-Wbad-function-cast"
348#pragma clang diagnostic pop
349 }
else if (strcmp(
"NUMBER_OF_FEATURE_TYPES", var_str) == 0) {
350#pragma clang diagnostic push
351#pragma clang diagnostic ignored "-Wbad-function-cast"
353#pragma clang diagnostic pop
355#pragma clang diagnostic push
356#pragma clang diagnostic ignored "-Wbad-function-cast"
358#pragma clang diagnostic pop
371 }
while(index < length);
382 uint16_t bit_offset = 0;
386 for (b = (32 - 1); b >= 0; b--) {
388 uint16_t
byte = bit_offset / 8;
389 uint16_t bit = 7 - (bit_offset % 8);
390 unsigned long newbit = !!((featureType_nbo >> b) & 1U);
391 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
392 bit_offset = bit_offset + 1;
407 uint16_t bit_offset = 0;
410 for (b = (32 - 1); b >= 0; b--) {
412 uint16_t
byte = bit_offset / 8;
413 uint16_t bit = 7 - (bit_offset % 8);
414 char dataByte = src[byte];
415 unsigned char bitValue = (dataByte >> bit) & 1U;
417 bit_offset = bit_offset + 1;
WHITEBOARD_POSTER_STRING_CONVERSION.
enum FeatureTypes featureType
Type of the Feature.
struct wb_polar_coordinate * wb_polar_coordinate_from_string(struct wb_polar_coordinate *self, const char *str)
Convert from a string.
const char * wb_polar_coordinate_to_string(const struct wb_polar_coordinate *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_polar_coordinate_description(const struct wb_polar_coordinate *self, char *descString, size_t bufferSize)
Convert to a description string.
#define POLAR_COORDINATE_DESC_BUFFER_SIZE
#define POLAR_COORDINATE_TO_STRING_BUFFER_SIZE
size_t wb_vision_detection_feature_from_network_serialised(const char *src, struct wb_vision_detection_feature *dst)
Convert from a compressed, serialised, network byte order byte stream.
const char * wb_vision_detection_feature_to_string(const struct wb_vision_detection_feature *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_vision_detection_feature * wb_vision_detection_feature_from_string(struct wb_vision_detection_feature *self, const char *str)
Convert from a string.
size_t wb_vision_detection_feature_to_network_serialised(const struct wb_vision_detection_feature *self, char *dst)
Convert to a compressed, serialised, network byte order byte stream.
const char * wb_vision_detection_feature_description(const struct wb_vision_detection_feature *self, char *descString, size_t bufferSize)
Convert to a description string.
#define VISION_DETECTION_FEATURE_DESC_BUFFER_SIZE
@ NUMBER_OF_FEATURE_TYPES