60#ifndef guWhiteboard_MyPosition_h
61#define guWhiteboard_MyPosition_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_MyPosition_DEFINED
73#define guWhiteboard_MyPosition_DEFINED
75#undef MyPosition_DEFINED
76#define MyPosition_DEFINED
90 void init(int16_t t_x = 0, int16_t t_y = 0, int16_t t_heading = 0) {
101 MyPosition(int16_t t_x = 0, int16_t t_y = 0, int16_t t_heading = 0) {
102 this->init(t_x, t_y, t_heading);
109 this->init(t_other.
x(), t_other.
y(), t_other.
heading());
116 this->init(t_other.
x, t_other.
y, t_other.
heading);
123 this->init(t_other.
x(), t_other.
y(), t_other.
heading());
131 this->init(t_other.
x, t_other.
y, t_other.
heading);
137 return x() == t_other.
x()
138 &&
y() == t_other.
y()
144 return !(*
this == t_other);
154 return !(*
this == t_other);
162 const int16_t &
x()
const
167 void set_x(
const int16_t &t_newValue)
177 const int16_t &
y()
const
182 void set_y(
const int16_t &t_newValue)
202#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
212#ifdef USE_WB_MY_POSITION_C_CONVERSION
215 std::string descr = buffer;
218 std::ostringstream ss;
219 ss <<
"x=" <<
static_cast<signed>(this->
x());
221 ss <<
"y=" <<
static_cast<signed>(this->
y());
223 ss <<
"heading=" <<
static_cast<signed>(this->
heading());
229#ifdef USE_WB_MY_POSITION_C_CONVERSION
232 std::string toString = buffer;
235 std::ostringstream ss;
236 ss << static_cast<signed>(this->
x());
238 ss << static_cast<signed>(this->
y());
240 ss << static_cast<signed>(this->
heading());
245#ifdef USE_WB_MY_POSITION_C_CONVERSION
250 char * str_cstr =
const_cast<char *
>(t_str.c_str());
251 size_t temp_length = strlen(str_cstr);
252 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
257 char* var_str = &var_str_buffer[0];
259 char* key = &key_buffer[0];
266 if (index == 0 && str_cstr[0] ==
'{') {
272 for (
int i = index; i < length; i++) {
274 if (bracecount == 0 && str_cstr[i] ==
'=') {
279 if (bracecount == 0 && isspace(str_cstr[i])) {
286 if (bracecount == 0 && str_cstr[i] ==
',') {
290 if (str_cstr[i] ==
'{') {
294 if (str_cstr[i] ==
'}') {
296 if (bracecount < 0) {
301 if (i == length - 1) {
305 if (endKey >= startKey && endKey - startKey < length) {
306 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
307 key[(endKey - startKey) + 1] = 0;
311 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
312 var_str[(index - startVar) + 1] = 0;
318 if (strlen(key) > 0) {
319 if (0 == strcmp(
"x", key)) {
321 }
else if (0 == strcmp(
"y", key)) {
323 }
else if (0 == strcmp(
"heading", key)) {
333 this->
set_x(
static_cast<int16_t
>(atoi(var_str)));
338 this->
set_y(
static_cast<int16_t
>(atoi(var_str)));
343 this->
set_heading(
static_cast<int16_t
>(atoi(var_str)));
350 }
while(index < length);
Provides a C++ wrapper around wb_my_position.
void set_y(const int16_t &t_newValue)
MyPosition(int16_t t_x=0, int16_t t_y=0, int16_t t_heading=0)
Create a new MyPosition.
MyPosition(const MyPosition &t_other)
Copy Constructor.
bool operator!=(const MyPosition &t_other) const
bool operator==(const MyPosition &t_other) const
MyPosition & operator=(const MyPosition &t_other)
Copy Assignment Operator.
void set_heading(const int16_t &t_newValue)
void from_string(const std::string &t_str)
const int16_t & y() const
const int16_t & heading() const
const int16_t & x() const
MyPosition(const struct wb_my_position &t_other)
Copy Constructor.
void set_x(const int16_t &t_newValue)
std::string description()
MyPosition(const std::string &t_str)
String Constructor.
WHITEBOARD_POSTER_STRING_CONVERSION.
struct wb_my_position * wb_my_position_from_string(struct wb_my_position *self, const char *str)
Convert from a string.
const char * wb_my_position_description(const struct wb_my_position *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_my_position_to_string(const struct wb_my_position *self, char *toString, size_t bufferSize)
Convert to a string.
#define MY_POSITION_DESC_BUFFER_SIZE
#define MY_POSITION_TO_STRING_BUFFER_SIZE