gusimplewhiteboard
TeleoperationStatus.hpp
Go to the documentation of this file.
1/*
2 * file TeleoperationStatus.hpp
3 *
4 * This file was generated by classgenerator from teleoperationStatus.gen.
5 * DO NOT CHANGE MANUALLY!
6 *
7 * Copyright © 2021 Carl Lusty. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials
19 * provided with the distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgement:
23 *
24 * This product includes software developed by Carl Lusty.
25 *
26 * 4. Neither the name of the author nor the names of contributors
27 * may be used to endorse or promote products derived from this
28 * software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
34 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
37 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
38 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
39 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 *
42 * -----------------------------------------------------------------------
43 * This program is free software; you can redistribute it and/or
44 * modify it under the above terms or under the terms of the GNU
45 * General Public License as published by the Free Software Foundation;
46 * either version 2 of the License, or (at your option) any later version.
47 *
48 * This program is distributed in the hope that it will be useful,
49 * but WITHOUT ANY WARRANTY; without even the implied warranty of
50 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51 * GNU General Public License for more details.
52 *
53 * You should have received a copy of the GNU General Public License
54 * along with this program; if not, see http://www.gnu.org/licenses/
55 * or write to the Free Software Foundation, Inc., 51 Franklin Street,
56 * Fifth Floor, Boston, MA 02110-1301, USA.
57 *
58 */
59
60#ifndef guWhiteboard_TeleoperationStatus_h
61#define guWhiteboard_TeleoperationStatus_h
62
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
64#include <cstdlib>
65#include <string.h>
66#include <sstream>
67#endif
68
69#include <gu_util.h>
71
72#undef guWhiteboard_TeleoperationStatus_DEFINED
73#define guWhiteboard_TeleoperationStatus_DEFINED
74
75#undef TeleoperationStatus_DEFINED
76#define TeleoperationStatus_DEFINED
77
78namespace guWhiteboard {
79
84
85 private:
86
90 void init(std::string t_sayString = "") {
91 gu_strlcpy(const_cast<char *>(this->sayString()), t_sayString.c_str(), 30);
92 }
93
94 public:
95
99 TeleoperationStatus(std::string t_sayString = "") {
100 this->init(t_sayString);
101 }
102
107 this->init(t_other.sayString());
108 }
109
114 this->init(t_other.sayString);
115 }
116
121 this->init(t_other.sayString());
122 return *this;
123 }
124
129 this->init(t_other.sayString);
130 return *this;
131 }
132
133 bool operator ==(const TeleoperationStatus &t_other) const
134 {
135 return 0 == strncmp(sayString(), t_other.sayString(), 30);
136 }
137
138 bool operator !=(const TeleoperationStatus &t_other) const
139 {
140 return !(*this == t_other);
141 }
142
143 bool operator ==(const wb_teleoperation_status &t_other) const
144 {
145 return *this == TeleoperationStatus(t_other);
146 }
147
148 bool operator !=(const wb_teleoperation_status &t_other) const
149 {
150 return !(*this == t_other);
151 }
152
153 const char * sayString() const
154 {
156 }
157
158 size_t sayString_size() const
159 {
160 return 30;
161 }
162
163 char & sayString(int t_i)
164 {
166 }
167
168 const char & sayString(int t_i) const
169 {
171 }
172
173 void set_sayString(const char *t_newValue)
174 {
175 strncpy(wb_teleoperation_status::sayString, t_newValue, 30);
176 }
177
178#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
182 TeleoperationStatus(const std::string &t_str) {
183 this->init();
184 this->from_string(t_str);
185 }
186
187 std::string description() {
188#ifdef USE_WB_TELEOPERATION_STATUS_C_CONVERSION
190 wb_teleoperation_status_description(this, buffer, sizeof(buffer));
191 std::string descr = buffer;
192 return descr;
193#else
194 std::ostringstream ss;
195 if (0 == strncmp("", this->sayString(), 1)) {
196 ss << "sayString=" << "";
197 } else {
198 ss << "sayString=" << this->sayString();
199 }
200 return ss.str();
201#endif
202 }
203
204 std::string to_string() {
205#ifdef USE_WB_TELEOPERATION_STATUS_C_CONVERSION
207 wb_teleoperation_status_to_string(this, buffer, sizeof(buffer));
208 std::string toString = buffer;
209 return toString;
210#else
211 std::ostringstream ss;
212 if (0 == strncmp("", this->sayString(), 1)) {
213 ss << "";
214 } else {
215 ss << this->sayString();
216 }
217 return ss.str();
218#endif
219 }
220
221#ifdef USE_WB_TELEOPERATION_STATUS_C_CONVERSION
222 void from_string(const std::string &t_str) {
223 wb_teleoperation_status_from_string(this, t_str.c_str());
224#else
225 void from_string(const std::string &t_str) {
226 char * str_cstr = const_cast<char *>(t_str.c_str());
227 size_t temp_length = strlen(str_cstr);
228 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
229 if (length < 1 || length > TELEOPERATIONSTATUS_DESC_BUFFER_SIZE) {
230 return;
231 }
232 char var_str_buffer[TELEOPERATIONSTATUS_DESC_BUFFER_SIZE + 1];
233 char* var_str = &var_str_buffer[0];
234 char key_buffer[10];
235 char* key = &key_buffer[0];
236 int bracecount = 0;
237 int startVar = 0;
238 int index = 0;
239 int startKey = 0;
240 int endKey = -1;
241 int varIndex = 0;
242 if (index == 0 && str_cstr[0] == '{') {
243 index = 1;
244 }
245 startVar = index;
246 startKey = startVar;
247 do {
248 for (int i = index; i < length; i++) {
249 index = i + 1;
250 if (bracecount == 0 && str_cstr[i] == '=') {
251 endKey = i - 1;
252 startVar = index;
253 continue;
254 }
255 if (bracecount == 0 && isspace(str_cstr[i])) {
256 startVar = index;
257 if (endKey == -1) {
258 startKey = index;
259 }
260 continue;
261 }
262 if (bracecount == 0 && str_cstr[i] == ',') {
263 index = i - 1;
264 break;
265 }
266 if (str_cstr[i] == '{') {
267 bracecount++;
268 continue;
269 }
270 if (str_cstr[i] == '}') {
271 bracecount--;
272 if (bracecount < 0) {
273 index = i - 1;
274 break;
275 }
276 }
277 if (i == length - 1) {
278 index = i;
279 }
280 }
281 if (endKey >= startKey && endKey - startKey < length) {
282 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
283 key[(endKey - startKey) + 1] = 0;
284 } else {
285 key[0] = 0;
286 }
287 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
288 var_str[(index - startVar) + 1] = 0;
289 bracecount = 0;
290 index += 2;
291 startVar = index;
292 startKey = startVar;
293 endKey = -1;
294 if (strlen(key) > 0) {
295 if (0 == strcmp("sayString", key)) {
296 varIndex = 0;
297 } else {
298 varIndex = -1;
299 }
300 }
301 switch (varIndex) {
302 case -1: { break; }
303 case 0:
304 {
305 strncpy(wb_teleoperation_status::sayString, var_str, 30);
306 break;
307 }
308 }
309 if (varIndex >= 0) {
310 varIndex++;
311 }
312 } while(index < length);
313#endif
314 }
315#endif
316 };
317
318}
319
320#endif
Provides a C++ wrapper around wb_teleoperation_status.
TeleoperationStatus(const std::string &t_str)
String Constructor.
TeleoperationStatus(std::string t_sayString="")
Create a new TeleoperationStatus.
TeleoperationStatus & operator=(const TeleoperationStatus &t_other)
Copy Assignment Operator.
TeleoperationStatus(const TeleoperationStatus &t_other)
Copy Constructor.
bool operator==(const TeleoperationStatus &t_other) const
TeleoperationStatus(const struct wb_teleoperation_status &t_other)
Copy Constructor.
bool operator!=(const TeleoperationStatus &t_other) const
const char & sayString(int t_i) const
void from_string(const std::string &t_str)
void set_sayString(const char *t_newValue)
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
char sayString[30]
String passed to Say_t.
const char * wb_teleoperation_status_description(const struct wb_teleoperation_status *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_teleoperation_status_to_string(const struct wb_teleoperation_status *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_teleoperation_status * wb_teleoperation_status_from_string(struct wb_teleoperation_status *self, const char *str)
Convert from a string.
#define TELEOPERATIONSTATUS_TO_STRING_BUFFER_SIZE
#define TELEOPERATIONSTATUS_DESC_BUFFER_SIZE