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,
"start={", bufferSize);
134 if (len >= bufferSize) {
138 char* start_p = start_buffer;
140 len = gu_strlcat(descString, start_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 = gu_strlcat(descString,
"end={", bufferSize);
153 if (len >= bufferSize) {
157 char* end_p = end_buffer;
159 len = gu_strlcat(descString, end_p, bufferSize);
160 if (len >= bufferSize) {
163 len = gu_strlcat(descString,
"}", bufferSize);
165#pragma clang diagnostic pop
173#pragma clang diagnostic push
174#pragma clang diagnostic ignored "-Wunused-variable"
176 if (len >= bufferSize) {
179 len = gu_strlcat(toString,
"{", bufferSize);
180 if (len >= bufferSize) {
184 char* start_p = start_buffer;
186 len = gu_strlcat(toString, start_p, bufferSize);
187 if (len >= bufferSize) {
190 len = gu_strlcat(toString,
"}", bufferSize);
191 if (len >= bufferSize) {
194 len = gu_strlcat(toString,
", ", bufferSize);
195 if (len >= bufferSize) {
198 len = gu_strlcat(toString,
"{", bufferSize);
199 if (len >= bufferSize) {
203 char* end_p = end_buffer;
205 len = gu_strlcat(toString, end_p, bufferSize);
206 if (len >= bufferSize) {
209 len = gu_strlcat(toString,
"}", bufferSize);
211#pragma clang diagnostic pop
219 size_t temp_length = strlen(str);
220 int length = (temp_length <= INT_MAX) ? ((
int)((ssize_t)temp_length)) : -1;
225 char* var_str = &var_str_buffer[0];
227 char* key = &key_buffer[0];
234 if (index == 0 && str[0] ==
'{') {
240 for (
int i = index; i < length; i++) {
242 if (bracecount == 0 && str[i] ==
'=') {
247 if (bracecount == 0 && isspace(str[i])) {
254 if (bracecount == 0 && str[i] ==
',') {
264 if (bracecount < 0) {
269 if (i == length - 1) {
273 if (endKey >= startKey && endKey - startKey < length) {
274 strncpy(key, str + startKey, ((
size_t)(endKey - startKey) + 1));
275 key[(endKey - startKey) + 1] = 0;
279 strncpy(var_str, str + startVar, ((
size_t)(index - startVar) + 1));
280 var_str[(index - startVar) + 1] = 0;
286 if (strlen(key) > 0) {
287 if (0 == strcmp(
"start", key)) {
289 }
else if (0 == strcmp(
"end", key)) {
311 }
while(index < length);
322 uint16_t bit_offset = 0;
335 uint16_t bit_offset = 0;
WHITEBOARD_POSTER_STRING_CONVERSION.
struct wb_pixel_coordinate end
End point of the line.
struct wb_pixel_coordinate start
Start point of the line.
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
struct wb_pixel_coordinate_line * wb_pixel_coordinate_line_from_string(struct wb_pixel_coordinate_line *self, const char *str)
Convert from a string.
const char * wb_pixel_coordinate_line_to_string(const struct wb_pixel_coordinate_line *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_pixel_coordinate_line_description(const struct wb_pixel_coordinate_line *self, char *descString, size_t bufferSize)
Convert to a description string.
gu_pixel_coordinate wb_pixel_coordinate_line_start_px_coord(const struct wb_pixel_coordinate_line self, const uint16_t resWidth, const uint16_t resHeight)
WHITEBOARD_POSTER_STRING_CONVERSION.
size_t wb_pixel_coordinate_line_to_network_serialised(const struct wb_pixel_coordinate_line *self, char *dst)
Convert to a compressed, serialised, network byte order byte stream.
gu_pixel_coordinate wb_pixel_coordinate_line_end_px_coord(const struct wb_pixel_coordinate_line self, const uint16_t resWidth, const uint16_t resHeight)
size_t wb_pixel_coordinate_line_from_network_serialised(const char *src, struct wb_pixel_coordinate_line *dst)
Convert from a compressed, serialised, network byte order byte stream.
#define PIXEL_COORDINATE_LINE_DESC_BUFFER_SIZE