60#ifndef guWhiteboard_MicrowaveStatus_h
61#define guWhiteboard_MicrowaveStatus_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_MicrowaveStatus_DEFINED
73#define guWhiteboard_MicrowaveStatus_DEFINED
75#undef MicrowaveStatus_DEFINED
76#define MicrowaveStatus_DEFINED
90 void init(
bool t_timeLeft =
true,
bool t_doorOpen =
true,
bool t_buttonPushed =
true) {
101 MicrowaveStatus(
bool t_timeLeft =
true,
bool t_doorOpen =
true,
bool t_buttonPushed =
true) {
102 this->init(t_timeLeft, t_doorOpen, t_buttonPushed);
144 return !(*
this == t_other);
154 return !(*
this == t_other);
202#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
212#ifdef USE_WB_MICROWAVE_STATUS_C_CONVERSION
215 std::string descr = buffer;
218 std::ostringstream ss;
219 ss <<
"timeLeft=" << (this->
timeLeft() ?
"true" :
"false");
221 ss <<
"doorOpen=" << (this->
doorOpen() ?
"true" :
"false");
223 ss <<
"buttonPushed=" << (this->
buttonPushed() ?
"true" :
"false");
229#ifdef USE_WB_MICROWAVE_STATUS_C_CONVERSION
232 std::string toString = buffer;
235 std::ostringstream ss;
236 ss << (this->
timeLeft() ?
"true" :
"false");
238 ss << (this->
doorOpen() ?
"true" :
"false");
245#ifdef USE_WB_MICROWAVE_STATUS_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(
"timeLeft", key)) {
321 }
else if (0 == strcmp(
"doorOpen", key)) {
323 }
else if (0 == strcmp(
"buttonPushed", key)) {
333 this->
set_timeLeft(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
338 this->
set_doorOpen(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
343 this->
set_buttonPushed(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
350 }
while(index < length);
Provides a C++ wrapper around wb_microwave_status.
void set_doorOpen(const bool &t_newValue)
const bool & buttonPushed() const
const bool & timeLeft() const
MicrowaveStatus & operator=(const MicrowaveStatus &t_other)
Copy Assignment Operator.
MicrowaveStatus(const MicrowaveStatus &t_other)
Copy Constructor.
MicrowaveStatus(const struct wb_microwave_status &t_other)
Copy Constructor.
void set_buttonPushed(const bool &t_newValue)
void from_string(const std::string &t_str)
void set_timeLeft(const bool &t_newValue)
MicrowaveStatus(bool t_timeLeft=true, bool t_doorOpen=true, bool t_buttonPushed=true)
Create a new MicrowaveStatus.
bool operator==(const MicrowaveStatus &t_other) const
std::string description()
const bool & doorOpen() const
bool operator!=(const MicrowaveStatus &t_other) const
MicrowaveStatus(const std::string &t_str)
String Constructor.
WHITEBOARD_POSTER_STRING_CONVERSION.
bool buttonPushed
Has the button been pushed?
bool timeLeft
Is the timer at zero?
bool doorOpen
Is the door open?
struct wb_microwave_status * wb_microwave_status_from_string(struct wb_microwave_status *self, const char *str)
Convert from a string.
const char * wb_microwave_status_description(const struct wb_microwave_status *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_microwave_status_to_string(const struct wb_microwave_status *self, char *toString, size_t bufferSize)
Convert to a string.
#define MICROWAVE_STATUS_DESC_BUFFER_SIZE
#define MICROWAVE_STATUS_TO_STRING_BUFFER_SIZE