60#ifndef guWhiteboard_PolarCoordinate_h
61#define guWhiteboard_PolarCoordinate_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_PolarCoordinate_DEFINED
73#define guWhiteboard_PolarCoordinate_DEFINED
75#undef PolarCoordinate_DEFINED
76#define PolarCoordinate_DEFINED
90 void init(int16_t t_direction = 0, uint16_t t_distance = 0) {
101 this->init(t_direction, t_distance);
142 return !(*
this == t_other);
152 return !(*
this == t_other);
185#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
195#ifdef USE_WB_POLAR_COORDINATE_C_CONVERSION
198 std::string descr = buffer;
201 std::ostringstream ss;
202 ss <<
"direction=" <<
static_cast<signed>(this->
direction());
204 ss <<
"distance=" <<
static_cast<unsigned>(this->
distance());
210#ifdef USE_WB_POLAR_COORDINATE_C_CONVERSION
213 std::string toString = buffer;
216 std::ostringstream ss;
217 ss << static_cast<signed>(this->
direction());
219 ss << static_cast<unsigned>(this->
distance());
224#ifdef USE_WB_POLAR_COORDINATE_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(
"direction", key)) {
300 }
else if (0 == strcmp(
"distance", key)) {
315 this->
set_distance(
static_cast<uint16_t
>(atoi(var_str)));
322 }
while(index < length);
Provides a C++ wrapper around wb_polar_coordinate.
void set_distance(const uint16_t &t_newValue)
void from_string(const std::string &t_str)
void set_direction(const int16_t &t_newValue)
std::string description()
const uint16_t & distance() const
PolarCoordinate(const std::string &t_str)
String Constructor.
PolarCoordinate(int16_t t_direction=0, uint16_t t_distance=0)
Create a new PolarCoordinate.
PolarCoordinate(const struct wb_polar_coordinate &t_other)
Copy Constructor.
PolarCoordinate(const PolarCoordinate &t_other)
Copy Constructor.
bool operator!=(const PolarCoordinate &t_other) const
bool operator==(const PolarCoordinate &t_other) const
const int16_t & direction() const
PolarCoordinate & operator=(const PolarCoordinate &t_other)
Copy Assignment Operator.
WHITEBOARD_POSTER_STRING_CONVERSION.
int16_t direction
degrees, relative to the center of the nao torso.
uint16_t distance
CM distance to the center point of the sighting.
struct wb_polar_coordinate * wb_polar_coordinate_from_string(struct wb_polar_coordinate *self, const char *str)
Convert from a string.
const char * wb_polar_coordinate_to_string(const struct wb_polar_coordinate *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_polar_coordinate_description(const struct wb_polar_coordinate *self, char *descString, size_t bufferSize)
Convert to a description string.
#define POLAR_COORDINATE_DESC_BUFFER_SIZE
#define POLAR_COORDINATE_TO_STRING_BUFFER_SIZE