60#ifndef guWhiteboard_Point2D_h
61#define guWhiteboard_Point2D_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_Point2D_DEFINED
73#define guWhiteboard_Point2D_DEFINED
76#define Point2D_DEFINED
90 void init(int16_t t_x = 0, int16_t t_y = 0) {
101 this->init(t_x, t_y);
108 this->init(t_other.
x(), t_other.
y());
115 this->init(t_other.
x, t_other.
y);
122 this->init(t_other.
x(), t_other.
y());
130 this->init(t_other.
x, t_other.
y);
136 return x() == t_other.
x()
137 &&
y() == t_other.
y();
142 return !(*
this == t_other);
147 return *
this ==
Point2D(t_other);
152 return !(*
this == t_other);
160 const int16_t &
x()
const
165 void set_x(
const int16_t &t_newValue)
175 const int16_t &
y()
const
180 void set_y(
const int16_t &t_newValue)
185#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
195#ifdef USE_WB_POINT2D_C_CONVERSION
198 std::string descr = buffer;
201 std::ostringstream ss;
202 ss <<
"x=" <<
static_cast<signed>(this->
x());
204 ss <<
"y=" <<
static_cast<signed>(this->
y());
210#ifdef USE_WB_POINT2D_C_CONVERSION
213 std::string toString = buffer;
216 std::ostringstream ss;
217 ss << static_cast<signed>(this->
x());
219 ss << static_cast<signed>(this->
y());
224#ifdef USE_WB_POINT2D_C_CONVERSION
229 char * str_cstr =
const_cast<char *
>(t_str.c_str());
230 size_t temp_length = strlen(str_cstr);
231 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
236 char* var_str = &var_str_buffer[0];
238 char* key = &key_buffer[0];
245 if (index == 0 && str_cstr[0] ==
'{') {
251 for (
int i = index; i < length; i++) {
253 if (bracecount == 0 && str_cstr[i] ==
'=') {
258 if (bracecount == 0 && isspace(str_cstr[i])) {
265 if (bracecount == 0 && str_cstr[i] ==
',') {
269 if (str_cstr[i] ==
'{') {
273 if (str_cstr[i] ==
'}') {
275 if (bracecount < 0) {
280 if (i == length - 1) {
284 if (endKey >= startKey && endKey - startKey < length) {
285 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
286 key[(endKey - startKey) + 1] = 0;
290 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
291 var_str[(index - startVar) + 1] = 0;
297 if (strlen(key) > 0) {
298 if (0 == strcmp(
"x", key)) {
300 }
else if (0 == strcmp(
"y", key)) {
310 this->
set_x(
static_cast<int16_t
>(atoi(var_str)));
315 this->
set_y(
static_cast<int16_t
>(atoi(var_str)));
322 }
while(index < length);
Provides a C++ wrapper around wb_point2d.
Point2D(const std::string &t_str)
String Constructor.
bool operator!=(const Point2D &t_other) const
void set_y(const int16_t &t_newValue)
Point2D(const struct wb_point2d &t_other)
Copy Constructor.
void from_string(const std::string &t_str)
Point2D(int16_t t_x=0, int16_t t_y=0)
Create a new Point2D.
Point2D(const Point2D &t_other)
Copy Constructor.
std::string description()
const int16_t & y() const
bool operator==(const Point2D &t_other) const
const int16_t & x() const
void set_x(const int16_t &t_newValue)
Point2D & operator=(const Point2D &t_other)
Copy Assignment Operator.
WHITEBOARD_POSTER_STRING_CONVERSION.
struct wb_point2d * wb_point2d_from_string(struct wb_point2d *self, const char *str)
Convert from a string.
const char * wb_point2d_description(const struct wb_point2d *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_point2d_to_string(const struct wb_point2d *self, char *toString, size_t bufferSize)
Convert to a string.
#define POINT2D_DESC_BUFFER_SIZE
#define POINT2D_TO_STRING_BUFFER_SIZE