60#ifndef guWhiteboard_VisionDetectionLineArray_h
61#define guWhiteboard_VisionDetectionLineArray_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_VisionDetectionLineArray_DEFINED
73#define guWhiteboard_VisionDetectionLineArray_DEFINED
75#undef VisionDetectionLineArray_DEFINED
76#define VisionDetectionLineArray_DEFINED
94 if (t_lines != NULLPTR) {
108 this->init(t_numLines, t_lines);
147 for (
int lines_0_index = 0; lines_0_index < 7; lines_0_index++)
156 return !(*
this == t_other);
166 return !(*
this == t_other);
214#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
224#ifdef USE_WB_VISION_DETECTION_LINE_ARRAY_C_CONVERSION
227 std::string descr = buffer;
230 std::ostringstream ss;
231 ss <<
"numLines=" <<
static_cast<unsigned>(this->
numLines());
233 bool lines_first =
true;
245#ifdef USE_WB_VISION_DETECTION_LINE_ARRAY_C_CONVERSION
248 std::string toString = buffer;
251 std::ostringstream ss;
252 ss << static_cast<unsigned>(this->
numLines());
254 bool lines_first =
true;
265#ifdef USE_WB_VISION_DETECTION_LINE_ARRAY_C_CONVERSION
270 char * str_cstr =
const_cast<char *
>(t_str.c_str());
271 size_t temp_length = strlen(str_cstr);
272 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
277 char* var_str = &var_str_buffer[0];
279 char* key = &key_buffer[0];
287 if (index == 0 && str_cstr[0] ==
'{') {
293 for (
int i = index; i < length; i++) {
295 if (bracecount == 0 && str_cstr[i] ==
'=') {
300 if (bracecount == 0 && isspace(str_cstr[i])) {
307 if (bracecount == 0 && str_cstr[i] ==
',') {
311 if (str_cstr[i] ==
'{') {
313 if (bracecount == 1) {
318 if (str_cstr[i] ==
'}') {
320 if (bracecount < 0) {
325 if (i == length - 1) {
329 if (endKey >= startKey && endKey - startKey < length) {
330 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
331 key[(endKey - startKey) + 1] = 0;
335 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
336 var_str[(index - startVar) + 1] = 0;
342 if (strlen(key) > 0) {
343 if (0 == strcmp(
"numLines", key)) {
345 }
else if (0 == strcmp(
"lines", key)) {
355 this->
set_numLines(
static_cast<uint8_t
>(atoi(var_str)));
360 int restartIndex = index;
361 index = lastBrace + 1;
367 for (
int i = index; i < length; i++) {
369 if (bracecount == 0 && str_cstr[i] ==
'=') {
374 if (bracecount == 0 && isspace(str_cstr[i])) {
381 if (bracecount == 0 && str_cstr[i] ==
',') {
385 if (str_cstr[i] ==
'{') {
389 if (str_cstr[i] ==
'}') {
391 if (bracecount < 0) {
396 if (i == length - 1) {
400 if (endKey >= startKey && endKey - startKey < length) {
401 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
402 key[(endKey - startKey) + 1] = 0;
406 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
407 var_str[(index - startVar) + 1] = 0;
418 index = restartIndex;
425 }
while(index < length);
Provides a C++ wrapper around wb_pixel_coordinate_line.
void from_string(const std::string &t_str)
Provides a C++ wrapper around wb_vision_detection_line_array.
void from_string(const std::string &t_str)
const PixelCoordinateLine & lines(int t_i) const
const uint8_t & numLines() const
VisionDetectionLineArray(const struct wb_vision_detection_line_array &t_other)
Copy Constructor.
size_t lines_size() const
std::string description()
VisionDetectionLineArray & operator=(const VisionDetectionLineArray &t_other)
Copy Assignment Operator.
PixelCoordinateLine & lines(int t_i)
void set_numLines(const uint8_t &t_newValue)
bool operator!=(const VisionDetectionLineArray &t_other) const
VisionDetectionLineArray(const std::string &t_str)
String Constructor.
bool operator==(const VisionDetectionLineArray &t_other) const
const PixelCoordinateLine * lines() const
VisionDetectionLineArray(const VisionDetectionLineArray &t_other)
Copy Constructor.
void set_lines(const PixelCoordinateLine &t_newValue, int t_i)
void set_lines(const PixelCoordinateLine *t_newValue)
VisionDetectionLineArray(uint8_t t_numLines=0, const struct wb_pixel_coordinate_line t_lines[7]=NULLPTR)
Create a new VisionDetectionLineArray.
WHITEBOARD_POSTER_STRING_CONVERSION.
Results for the Line Ray Tracer (guvision).
uint8_t numLines
The number of lines reported on the camera.
struct wb_pixel_coordinate_line lines[7]
Lines reported from the camera.
const char * wb_vision_detection_line_array_description(const struct wb_vision_detection_line_array *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_vision_detection_line_array * wb_vision_detection_line_array_from_string(struct wb_vision_detection_line_array *self, const char *str)
Convert from a string.
const char * wb_vision_detection_line_array_to_string(const struct wb_vision_detection_line_array *self, char *toString, size_t bufferSize)
Convert to a string.
#define VISION_DETECTION_LINE_ARRAY_DESC_BUFFER_SIZE
#define VISION_DETECTION_LINE_ARRAY_TO_STRING_BUFFER_SIZE
#define VISION_DETECTION_LINE_ARRAY_LINES_ARRAY_SIZE
WHITEBOARD_POSTER_STRING_CONVERSION.