gusimplewhiteboard
MemoryImageControlStatus.hpp
Go to the documentation of this file.
1/*
2 * file MemoryImageControlStatus.hpp
3 *
4 * This file was generated by classgenerator from memory_image_control_status.gen.
5 * DO NOT CHANGE MANUALLY!
6 *
7 * Copyright © 2021 Callum McColl. 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 Callum McColl.
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_MemoryImageControlStatus_h
61#define guWhiteboard_MemoryImageControlStatus_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_MemoryImageControlStatus_DEFINED
73#define guWhiteboard_MemoryImageControlStatus_DEFINED
74
75#undef MemoryImageControlStatus_DEFINED
76#define MemoryImageControlStatus_DEFINED
77
78namespace guWhiteboard {
79
84
85 private:
86
90 void init(uint16_t t_res_width = 0, uint16_t t_res_height = 0, enum MemoryImagePixelFormat t_pixelFormat = MI_RGBA) {
91 set_res_width(t_res_width);
92 set_res_height(t_res_height);
93 set_pixelFormat(t_pixelFormat);
94 }
95
96 public:
97
101 MemoryImageControlStatus(uint16_t t_res_width = 0, uint16_t t_res_height = 0, enum MemoryImagePixelFormat t_pixelFormat = MI_RGBA) {
102 this->init(t_res_width, t_res_height, t_pixelFormat);
103 }
104
109 this->init(t_other.res_width(), t_other.res_height(), t_other.pixelFormat());
110 }
111
116 this->init(t_other.res_width, t_other.res_height, t_other.pixelFormat);
117 }
118
123 this->init(t_other.res_width(), t_other.res_height(), t_other.pixelFormat());
124 return *this;
125 }
126
131 this->init(t_other.res_width, t_other.res_height, t_other.pixelFormat);
132 return *this;
133 }
134
135 bool operator ==(const MemoryImageControlStatus &t_other) const
136 {
137 return res_width() == t_other.res_width()
138 && res_height() == t_other.res_height()
139 && pixelFormat() == t_other.pixelFormat();
140 }
141
142 bool operator !=(const MemoryImageControlStatus &t_other) const
143 {
144 return !(*this == t_other);
145 }
146
148 {
149 return *this == MemoryImageControlStatus(t_other);
150 }
151
153 {
154 return !(*this == t_other);
155 }
156
157 uint16_t & res_width()
158 {
160 }
161
162 const uint16_t & res_width() const
163 {
165 }
166
167 void set_res_width(const uint16_t &t_newValue)
168 {
170 }
171
172 uint16_t & res_height()
173 {
175 }
176
177 const uint16_t & res_height() const
178 {
180 }
181
182 void set_res_height(const uint16_t &t_newValue)
183 {
185 }
186
188 {
190 }
191
193 {
195 }
196
197 void set_pixelFormat(const enum MemoryImagePixelFormat &t_newValue)
198 {
200 }
201
202#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
206 MemoryImageControlStatus(const std::string &t_str) {
207 this->init();
208 this->from_string(t_str);
209 }
210
211 std::string description() {
212#ifdef USE_WB_MEMORY_IMAGE_CONTROL_STATUS_C_CONVERSION
214 wb_memory_image_control_status_description(this, buffer, sizeof(buffer));
215 std::string descr = buffer;
216 return descr;
217#else
218 std::ostringstream ss;
219 ss << "res_width=" << static_cast<unsigned>(this->res_width());
220 ss << ", ";
221 ss << "res_height=" << static_cast<unsigned>(this->res_height());
222 ss << ", ";
223 switch (this->pixelFormat()) {
224 case MI_BGRA:
225 {
226 ss << "pixelFormat=" << "MI_BGRA";
227 break;
228 }
229 case MI_RGBA:
230 {
231 ss << "pixelFormat=" << "MI_RGBA";
232 break;
233 }
234 case MI_UYV422:
235 {
236 ss << "pixelFormat=" << "MI_UYV422";
237 break;
238 }
239 }
240 return ss.str();
241#endif
242 }
243
244 std::string to_string() {
245#ifdef USE_WB_MEMORY_IMAGE_CONTROL_STATUS_C_CONVERSION
247 wb_memory_image_control_status_to_string(this, buffer, sizeof(buffer));
248 std::string toString = buffer;
249 return toString;
250#else
251 std::ostringstream ss;
252 ss << static_cast<unsigned>(this->res_width());
253 ss << ", ";
254 ss << static_cast<unsigned>(this->res_height());
255 ss << ", ";
256 switch (this->pixelFormat()) {
257 case MI_BGRA:
258 {
259 ss << "MI_BGRA";
260 break;
261 }
262 case MI_RGBA:
263 {
264 ss << "MI_RGBA";
265 break;
266 }
267 case MI_UYV422:
268 {
269 ss << "MI_UYV422";
270 break;
271 }
272 }
273 return ss.str();
274#endif
275 }
276
277#ifdef USE_WB_MEMORY_IMAGE_CONTROL_STATUS_C_CONVERSION
278 void from_string(const std::string &t_str) {
280#else
281 void from_string(const std::string &t_str) {
282 char * str_cstr = const_cast<char *>(t_str.c_str());
283 size_t temp_length = strlen(str_cstr);
284 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
285 if (length < 1 || length > MEMORY_IMAGE_CONTROL_STATUS_DESC_BUFFER_SIZE) {
286 return;
287 }
288 char var_str_buffer[MEMORY_IMAGE_CONTROL_STATUS_DESC_BUFFER_SIZE + 1];
289 char* var_str = &var_str_buffer[0];
290 char key_buffer[12];
291 char* key = &key_buffer[0];
292 int bracecount = 0;
293 int startVar = 0;
294 int index = 0;
295 int startKey = 0;
296 int endKey = -1;
297 int varIndex = 0;
298 if (index == 0 && str_cstr[0] == '{') {
299 index = 1;
300 }
301 startVar = index;
302 startKey = startVar;
303 do {
304 for (int i = index; i < length; i++) {
305 index = i + 1;
306 if (bracecount == 0 && str_cstr[i] == '=') {
307 endKey = i - 1;
308 startVar = index;
309 continue;
310 }
311 if (bracecount == 0 && isspace(str_cstr[i])) {
312 startVar = index;
313 if (endKey == -1) {
314 startKey = index;
315 }
316 continue;
317 }
318 if (bracecount == 0 && str_cstr[i] == ',') {
319 index = i - 1;
320 break;
321 }
322 if (str_cstr[i] == '{') {
323 bracecount++;
324 continue;
325 }
326 if (str_cstr[i] == '}') {
327 bracecount--;
328 if (bracecount < 0) {
329 index = i - 1;
330 break;
331 }
332 }
333 if (i == length - 1) {
334 index = i;
335 }
336 }
337 if (endKey >= startKey && endKey - startKey < length) {
338 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
339 key[(endKey - startKey) + 1] = 0;
340 } else {
341 key[0] = 0;
342 }
343 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
344 var_str[(index - startVar) + 1] = 0;
345 bracecount = 0;
346 index += 2;
347 startVar = index;
348 startKey = startVar;
349 endKey = -1;
350 if (strlen(key) > 0) {
351 if (0 == strcmp("res_width", key)) {
352 varIndex = 0;
353 } else if (0 == strcmp("res_height", key)) {
354 varIndex = 1;
355 } else if (0 == strcmp("pixelFormat", key)) {
356 varIndex = 2;
357 } else {
358 varIndex = -1;
359 }
360 }
361 switch (varIndex) {
362 case -1: { break; }
363 case 0:
364 {
365 this->set_res_width(static_cast<uint16_t>(atoi(var_str)));
366 break;
367 }
368 case 1:
369 {
370 this->set_res_height(static_cast<uint16_t>(atoi(var_str)));
371 break;
372 }
373 case 2:
374 {
375 if (strcmp("MI_BGRA", var_str) == 0) {
376#pragma clang diagnostic push
377#pragma clang diagnostic ignored "-Wbad-function-cast"
379#pragma clang diagnostic pop
380 } else if (strcmp("MI_RGBA", var_str) == 0) {
381#pragma clang diagnostic push
382#pragma clang diagnostic ignored "-Wbad-function-cast"
384#pragma clang diagnostic pop
385 } else if (strcmp("MI_UYV422", var_str) == 0) {
386#pragma clang diagnostic push
387#pragma clang diagnostic ignored "-Wbad-function-cast"
389#pragma clang diagnostic pop
390 } else {
391#pragma clang diagnostic push
392#pragma clang diagnostic ignored "-Wbad-function-cast"
393 this->set_pixelFormat(static_cast<enum MemoryImagePixelFormat>(atoi(var_str)));
394#pragma clang diagnostic pop
395 }
396 break;
397 }
398 }
399 if (varIndex >= 0) {
400 varIndex++;
401 }
402 } while(index < length);
403#endif
404 }
405#endif
406 };
407
408}
409
410#endif
Provides a C++ wrapper around wb_memory_image_control_status.
MemoryImageControlStatus(const std::string &t_str)
String Constructor.
MemoryImageControlStatus(uint16_t t_res_width=0, uint16_t t_res_height=0, enum MemoryImagePixelFormat t_pixelFormat=MI_RGBA)
Create a new MemoryImageControlStatus.
MemoryImageControlStatus(const MemoryImageControlStatus &t_other)
Copy Constructor.
void set_pixelFormat(const enum MemoryImagePixelFormat &t_newValue)
MemoryImageControlStatus & operator=(const MemoryImageControlStatus &t_other)
Copy Assignment Operator.
void set_res_height(const uint16_t &t_newValue)
MemoryImageControlStatus(const struct wb_memory_image_control_status &t_other)
Copy Constructor.
enum MemoryImagePixelFormat & pixelFormat() const
void set_res_width(const uint16_t &t_newValue)
bool operator!=(const MemoryImageControlStatus &t_other) const
bool operator==(const MemoryImageControlStatus &t_other) const
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
uint16_t res_height
The resolution height.
enum MemoryImagePixelFormat pixelFormat
The pixel format of the images.
const char * wb_memory_image_control_status_to_string(const struct wb_memory_image_control_status *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_memory_image_control_status_description(const struct wb_memory_image_control_status *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_memory_image_control_status * wb_memory_image_control_status_from_string(struct wb_memory_image_control_status *self, const char *str)
Convert from a string.
#define MEMORY_IMAGE_CONTROL_STATUS_TO_STRING_BUFFER_SIZE
#define MEMORY_IMAGE_CONTROL_STATUS_DESC_BUFFER_SIZE