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,
"coordinate={", bufferSize);
134 if (len >= bufferSize) {
138 char* coordinate_p = coordinate_buffer;
140 len = gu_strlcat(descString, coordinate_p, bufferSize);
141 if (len >= bufferSize) {
144 len = gu_strlcat(descString,
"}", bufferSize);
145 if (len >= bufferSize) {
148 len = gu_strlcat(descString,
", ", bufferSize);
149 if (len >= bufferSize) {
152 len += snprintf(descString + len, bufferSize - len,
"camera=%u", self->camera);
154#pragma clang diagnostic pop
162#pragma clang diagnostic push
163#pragma clang diagnostic ignored "-Wunused-variable"
165 if (len >= bufferSize) {
168 len = gu_strlcat(toString,
"{", bufferSize);
169 if (len >= bufferSize) {
173 char* coordinate_p = coordinate_buffer;
175 len = gu_strlcat(toString, coordinate_p, bufferSize);
176 if (len >= bufferSize) {
179 len = gu_strlcat(toString,
"}", bufferSize);
180 if (len >= bufferSize) {
183 len = gu_strlcat(toString,
", ", bufferSize);
184 if (len >= bufferSize) {
187 len += snprintf(toString + len, bufferSize - len,
"%u", self->camera);
189#pragma clang diagnostic pop
197 size_t temp_length = strlen(str);
198 int length = (temp_length <= INT_MAX) ? ((
int)((ssize_t)temp_length)) : -1;
203 char* var_str = &var_str_buffer[0];
205 char* key = &key_buffer[0];
212 if (index == 0 && str[0] ==
'{') {
218 for (
int i = index; i < length; i++) {
220 if (bracecount == 0 && str[i] ==
'=') {
225 if (bracecount == 0 && isspace(str[i])) {
232 if (bracecount == 0 && str[i] ==
',') {
242 if (bracecount < 0) {
247 if (i == length - 1) {
251 if (endKey >= startKey && endKey - startKey < length) {
252 strncpy(key, str + startKey, ((
size_t)(endKey - startKey) + 1));
253 key[(endKey - startKey) + 1] = 0;
257 strncpy(var_str, str + startVar, ((
size_t)(index - startVar) + 1));
258 var_str[(index - startVar) + 1] = 0;
264 if (strlen(key) > 0) {
265 if (0 == strcmp(
"coordinate", key)) {
267 }
else if (0 == strcmp(
"camera", key)) {
282 self->camera = ((uint8_t)atoi(var_str));
289 }
while(index < length);
300 uint16_t bit_offset = 0;
301 uint8_t camera_nbo = (
self->camera);
304 for (b = (8 - 1); b >= 0; b--) {
306 uint16_t
byte = bit_offset / 8;
307 uint16_t bit = 7 - (bit_offset % 8);
308 unsigned long newbit = !!((camera_nbo >> b) & 1U);
309 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
310 bit_offset = bit_offset + 1;
325 uint16_t bit_offset = 0;
328 for (b = (8 - 1); b >= 0; b--) {
330 uint16_t
byte = bit_offset / 8;
331 uint16_t bit = 7 - (bit_offset % 8);
332 char dataByte = src[byte];
333 unsigned char bitValue = (dataByte >> bit) & 1U;
335 bit_offset = bit_offset + 1;
WHITEBOARD_POSTER_STRING_CONVERSION.
struct wb_pixel_coordinate coordinate
The pixel coordinate.
uint8_t camera
camera it was seen on
const char * wb_pixel_coordinate_description(const struct wb_pixel_coordinate *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_pixel_coordinate * wb_pixel_coordinate_from_string(struct wb_pixel_coordinate *self, const char *str)
Convert from a string.
const char * wb_pixel_coordinate_to_string(const struct wb_pixel_coordinate *self, char *toString, size_t bufferSize)
Convert to a string.
gu_pixel_coordinate wb_px_coord_to_px_coord(const struct wb_pixel_coordinate coord, const uint16_t resWidth, const uint16_t resHeight)
#define PIXEL_COORDINATE_DESC_BUFFER_SIZE
#define PIXEL_COORDINATE_TO_STRING_BUFFER_SIZE
const char * wb_vision_field_feature_to_string(const struct wb_vision_field_feature *self, char *toString, size_t bufferSize)
Convert to a string.
gu_pixel_coordinate wb_vision_field_feature_coordinate_px_coord(const struct wb_vision_field_feature self, const uint16_t resWidth, const uint16_t resHeight)
WHITEBOARD_POSTER_STRING_CONVERSION.
const char * wb_vision_field_feature_description(const struct wb_vision_field_feature *self, char *descString, size_t bufferSize)
Convert to a description string.
size_t wb_vision_field_feature_to_network_serialised(const struct wb_vision_field_feature *self, char *dst)
Convert to a compressed, serialised, network byte order byte stream.
struct wb_vision_field_feature * wb_vision_field_feature_from_string(struct wb_vision_field_feature *self, const char *str)
Convert from a string.
size_t wb_vision_field_feature_from_network_serialised(const char *src, struct wb_vision_field_feature *dst)
Convert from a compressed, serialised, network byte order byte stream.
#define VISION_FIELD_FEATURE_DESC_BUFFER_SIZE