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,
"objects={", bufferSize);
135 if (len >= bufferSize) {
138 if (objects_index > 0) {
139 len = gu_strlcat(descString,
", ", bufferSize);
141 len = gu_strlcat(descString,
"{", bufferSize);
142 if (len >= bufferSize) {
146 char* objects_1_p = objects_1_buffer;
148 len = gu_strlcat(descString, objects_1_p, bufferSize);
149 if (len >= bufferSize) {
152 len = gu_strlcat(descString,
"}", bufferSize);
154 if (len >= bufferSize) {
157 len = gu_strlcat(descString,
"}", bufferSize);
159#pragma clang diagnostic pop
167#pragma clang diagnostic push
168#pragma clang diagnostic ignored "-Wunused-variable"
170 if (len >= bufferSize) {
173 len = gu_strlcat(toString,
"{", bufferSize);
175 if (len >= bufferSize) {
178 if (objects_index > 0) {
179 len = gu_strlcat(toString,
", ", bufferSize);
181 len = gu_strlcat(toString,
"{", bufferSize);
182 if (len >= bufferSize) {
186 char* objects_1_p = objects_1_buffer;
188 len = gu_strlcat(toString, objects_1_p, bufferSize);
189 if (len >= bufferSize) {
192 len = gu_strlcat(toString,
"}", bufferSize);
194 if (len >= bufferSize) {
197 len = gu_strlcat(toString,
"}", bufferSize);
199#pragma clang diagnostic pop
207 size_t temp_length = strlen(str);
208 int length = (temp_length <= INT_MAX) ? ((
int)((ssize_t)temp_length)) : -1;
213 char* var_str = &var_str_buffer[0];
215 char* key = &key_buffer[0];
223 if (index == 0 && str[0] ==
'{') {
229 for (
int i = index; i < length; i++) {
231 if (bracecount == 0 && str[i] ==
'=') {
236 if (bracecount == 0 && isspace(str[i])) {
243 if (bracecount == 0 && str[i] ==
',') {
249 if (bracecount == 1) {
256 if (bracecount < 0) {
261 if (i == length - 1) {
265 if (endKey >= startKey && endKey - startKey < length) {
266 strncpy(key, str + startKey, ((
size_t)(endKey - startKey) + 1));
267 key[(endKey - startKey) + 1] = 0;
271 strncpy(var_str, str + startVar, ((
size_t)(index - startVar) + 1));
272 var_str[(index - startVar) + 1] = 0;
278 if (strlen(key) > 0) {
279 if (0 == strcmp(
"objects", key)) {
289 int restartIndex = index;
290 index = lastBrace + 1;
296 for (
int i = index; i < length; i++) {
298 if (bracecount == 0 && str[i] ==
'=') {
303 if (bracecount == 0 && isspace(str[i])) {
310 if (bracecount == 0 && str[i] ==
',') {
320 if (bracecount < 0) {
325 if (i == length - 1) {
329 if (endKey >= startKey && endKey - startKey < length) {
330 strncpy(key, str + startKey, ((
size_t)(endKey - startKey) + 1));
331 key[(endKey - startKey) + 1] = 0;
335 strncpy(var_str, str + startVar, ((
size_t)(index - startVar) + 1));
336 var_str[(index - startVar) + 1] = 0;
344 self->objects[objects_0_index] = objects_0;
346 index = restartIndex;
353 }
while(index < length);
364 uint16_t bit_offset = 0;
370 const char *buf = (
const char *)&self->objects[0];
373 for (c = 0; c < bytes; c++) {
374 for (b = 7; b >= 0; b--) {
376 uint16_t
byte = bit_offset / 8;
377 uint16_t bit = 7 - (bit_offset % 8);
378 unsigned long newbit = !!((buf[c] >> b) & 1U);
379 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
380 bit_offset = bit_offset + 1;
396 uint16_t bit_offset = 0;
402 char *buf = (
char *)malloc(bytes);
405 for (c = 0; c < bytes; c++) {
406 for (b = 7; b >= 0; b--) {
408 uint16_t
byte = bit_offset / 8;
409 uint16_t bit = 7 - (bit_offset % 8);
410 char dataByte = src[byte];
411 unsigned char bitValue = (dataByte >> bit) & 1U;
412 buf[c] ^= (-bitValue ^ buf[c]) & (1UL << b);
413 bit_offset = bit_offset + 1;
417 memcpy(&dst->
objects[0], &buf[0], bytes);
The class of landmarks filtered regarding goal sightings.
struct wb_filtered_vision_object objects[4]
the array containing various filtered parts of the goals reported by vision FVO_NUM_OBJECTS =4
WHITEBOARD_POSTER_STRING_CONVERSION.
size_t wb_filtered_arrayonedimobjects_from_network_serialised(const char *src, struct wb_filtered_arrayonedimobjects *dst)
Convert from a compressed, serialised, network byte order byte stream.
size_t wb_filtered_arrayonedimobjects_to_network_serialised(const struct wb_filtered_arrayonedimobjects *self, char *dst)
Convert to a compressed, serialised, network byte order byte stream.
const char * wb_filtered_arrayonedimobjects_description(const struct wb_filtered_arrayonedimobjects *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_filtered_arrayonedimobjects_to_string(const struct wb_filtered_arrayonedimobjects *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_filtered_arrayonedimobjects * wb_filtered_arrayonedimobjects_from_string(struct wb_filtered_arrayonedimobjects *self, const char *str)
Convert from a string.
#define FILTERED_ARRAYONEDIMOBJECTS_DESC_BUFFER_SIZE
#define FILTERED_ARRAYONEDIMOBJECTS_OBJECTS_ARRAY_SIZE
WHITEBOARD_POSTER_STRING_CONVERSION.
const char * wb_filtered_vision_object_to_string(const struct wb_filtered_vision_object *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_filtered_vision_object_description(const struct wb_filtered_vision_object *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_filtered_vision_object * wb_filtered_vision_object_from_string(struct wb_filtered_vision_object *self, const char *str)
Convert from a string.
#define FILTERED_VISION_OBJECT_TO_STRING_BUFFER_SIZE
#define FILTERED_VISION_OBJECT_DESC_BUFFER_SIZE