GCC Code Coverage Report


Directory: src/gate/
File: src/gate/cxx_properties.cpp
Date: 2026-03-20 22:56:14
Exec Total Coverage
Lines: 248 305 81.3%
Functions: 57 65 87.7%
Branches: 108 237 45.6%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright (c) 2018-2026, Stefan Meislinger <sm@opengate.at> |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/properties.hpp"
30 #include "gate/exceptions.hpp"
31 #include "gate/mathematics.h"
32
33 namespace gate
34 {
35
36 62 Property::Property()
37 {
38 62 gate_property_create_empty(&this->impl);
39 62 }
40 3 Property::Property(bool_t const& bool_value)
41 {
42 3 gate_property_create_bool(&this->impl, bool_value);
43 3 }
44 5 Property::Property(int64_t int_value)
45 {
46 5 gate_property_create_int(&this->impl, int_value);
47 5 }
48 1 Property::Property(real32_t const& flt_value)
49 {
50 1 gate_property_create_real(&this->impl, flt_value);
51 1 }
52 3 Property::Property(real64_t const& dbl_value)
53 {
54 3 gate_property_create_real(&this->impl, dbl_value);
55 3 }
56 1 Property::Property(gate_string_t const* ptr_string)
57 {
58
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 if (NULL == gate_property_create_string(&this->impl, ptr_string))
59 {
60 GATEXX_RAISE_ERROR(results::OutOfMemory);
61 }
62 1 }
63 5 Property::Property(char const* c_string)
64 {
65
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 if (NULL == gate_property_create_text(&this->impl, c_string))
66 {
67 GATEXX_RAISE_ERROR(results::OutOfMemory);
68 }
69 5 }
70 7 Property::Property(String const& string_value)
71 {
72
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 if (NULL == gate_property_create_string(&this->impl, string_value.c_impl()))
73 {
74 GATEXX_RAISE_ERROR(results::OutOfMemory);
75 }
76 7 }
77 1 Property::Property(Array<Property> const& array_value)
78 {
79 gate_property_t* result;
80
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 if (array_value.empty())
81 {
82 result = gate_property_create_array(&this->impl, NULL, 0);
83 }
84 else
85 {
86 1 result = gate_property_create_array(&this->impl, array_value[0].c_impl(), array_value.length());
87 }
88
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (result == NULL)
89 {
90 GATEXX_RAISE_ERROR(results::OutOfMemory);
91 }
92 1 }
93 2 Property::Property(object_members_t const& object_value)
94 {
95
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
2 if (NULL == gate_property_create_object(&this->impl))
96 {
97 GATEXX_RAISE_ERROR(results::OutOfMemory);
98 }
99
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 ExceptionInfo xcptInfo;
100
7/16
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 2 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 4 times.
✗ Branch 16 not taken.
✓ Branch 19 taken 2 times.
✗ Branch 20 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
6 GATEXX_TRY_CATCHINFO(xcptInfo, {
101 object_members_t::enumerator_t e = object_value.enumerate();
102 while (e.valid())
103 {
104 this->addObjectMember(e->key(), e->value());
105 e.next();
106 }
107 });
108
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (xcptInfo.failed())
109 {
110 gate_property_destroy(&this->impl);
111 xcptInfo.raise();
112 }
113 2 }
114
115 68 Property::Property(gate_property_t const& src_base)
116 {
117
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
68 if (NULL == gate_property_copy(&this->impl, &src_base))
118 {
119 GATEXX_RAISE_ERROR(results::OutOfMemory);
120 }
121 68 }
122 Property::Property(gate_struct_t const* ptr_struct)
123 {
124 result_t result = gate_property_import(&this->impl, GATE_TYPE_STRUCT, ptr_struct);
125 GATEXX_CHECK_EXCEPTION(result);
126 }
127
128 46 Property::Property(Property const& src)
129 {
130
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
46 if (NULL == gate_property_copy(&this->impl, &src.impl))
131 {
132 GATEXX_RAISE_ERROR(results::OutOfMemory);
133 }
134 46 }
135 17 Property& Property::operator=(Property const& src)
136 {
137
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if (this != &src)
138 {
139 gate_property_t tmp;
140
2/4
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 17 times.
17 if (NULL == gate_property_copy(&tmp, &src.impl))
141 {
142 GATEXX_RAISE_ERROR(results::OutOfMemory);
143 }
144
1/2
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
17 gate_property_destroy(&this->impl);
145 17 this->impl = tmp;
146 }
147 17 return *this;
148 }
149 408 Property::~Property() noexcept
150 {
151 204 gate_property_destroy(&this->impl);
152 204 }
153
154 6 void Property::swap(Property& that) noexcept
155 {
156 6 gate::swapRefs(this->impl, that.impl);
157 6 }
158
159
160 33 gate_property_t* Property::c_impl()
161 {
162 33 return &this->impl;
163 }
164 32 gate_property_t const* Property::c_impl() const
165 {
166 32 return &this->impl;
167 }
168
169 36 Property::TypeEnum Property::getType() const
170 {
171 36 return TypeEnum(this->impl.value_type);
172 }
173
174 12 bool_t Property::getBool() const
175 {
176 bool_t ret;
177
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 result_t result = gate_property_get_bool(&this->impl, &ret);
178
3/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 1 times.
12 return GATE_SUCCEEDED(result) ? ret : false;
179 }
180 30 int64_t Property::getInt() const
181 {
182 int64_t ret;
183
1/2
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
30 result_t result = gate_property_get_int(&this->impl, &ret);
184
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 return GATE_SUCCEEDED(result) ? ret : 0;
185 }
186 11 real64_t Property::getReal() const
187 {
188 real64_t ret;
189
1/2
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
11 result_t result = gate_property_get_real(&this->impl, &ret);
190
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 return GATE_SUCCEEDED(result) ? ret : 0.0;
191 }
192 21 String Property::getString() const
193 {
194 gate_string_t str;
195
1/2
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
21 result_t result = gate_property_get_string(&this->impl, &str);
196
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
42 return GATE_SUCCEEDED(result) ? String::createFrom(str) : String();
197 }
198 7 Array<Property> Property::getArray() const
199 {
200
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
14 ArrayList<Property> list;
201
202
4/5
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
7 switch (this->getType())
203 {
204 1 case Property::Type_Empty:
205 {
206 1 break;
207 }
208 1 case Property::Type_Bool:
209 case Property::Type_Int:
210 case Property::Type_Real:
211 case Property::Type_String:
212 {
213
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 list.add(*this);
214 1 break;
215 }
216
217 4 case Property::Type_Array:
218 {
219
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 size_t array_len = gate_property_array_length(&this->impl);
220
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
17 for (size_t ndx = 0; ndx != array_len; ++ndx)
221 {
222
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 gate_property_t const* var_item = gate_property_array_get(&this->impl, ndx);
223
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (var_item != NULL)
224 {
225
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
26 Property var(*var_item);
226
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 list.add(var);
227 }
228 }
229 4 break;
230 }
231 1 case Property::Type_Object:
232 {
233 2 GenericArray names;
234
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if (NULL == gate_property_member_names(&this->impl, names.c_impl()))
235 {
236 GATEXX_RAISE_ERROR(results::OutOfMemory);
237 }
238 1 size_t array_len = names.length();
239
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (size_t ndx = 0; ndx != array_len; ++ndx)
240 {
241 4 gate_string_t const* name = (gate_string_t const*)names.getItemPtr(ndx);
242
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (name != NULL)
243 {
244
2/4
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
4 list.add(String::duplicate(*name));
245 }
246 }
247 1 break;
248 }
249 }
250
251
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
14 return list.toArray();
252 }
253 5 Property::object_members_t Property::getObjectMembers() const
254 {
255 5 Property::object_members_t ret;
256
2/4
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
5 switch (this->getType())
257 {
258 case Property::Type_Empty:
259 case Property::Type_Bool:
260 case Property::Type_Int:
261 case Property::Type_Real:
262 case Property::Type_String:
263 {
264 break;
265 }
266 1 case Property::Type_Array:
267 {
268
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 size_t array_len = gate_property_array_length(&this->impl);
269
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (size_t ndx = 0; ndx != array_len; ++ndx)
270 {
271
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 gate_property_t const* ptr_var = gate_property_array_get(&this->impl, ndx);
272
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (ptr_var != NULL)
273 {
274 char buffer[256];
275
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
8 Property local_var(*ptr_var);
276
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 gate_size_t buffer_used = gate_str_print_int64(buffer, sizeof(buffer), (int64_t)ndx);
277 8 String key = String::createStatic(buffer, buffer_used);
278
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 ret.add(key, local_var);
279 }
280 }
281 1 break;
282 }
283 4 case Property::Type_Object:
284 {
285 8 GenericArray names;
286
2/4
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 if (NULL != gate_property_member_names(&this->impl, names.c_impl()))
287 {
288 4 size_t const names_count = names.length();
289
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 4 times.
13 for (size_t ndx = 0; ndx != names_count; ++ndx)
290 {
291 9 gate_string_t const* name = (gate_string_t const*)names.getItemPtr(ndx);
292
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (NULL != name)
293 {
294
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 gate_property_t const* ptr_var = gate_property_member_get(&this->impl, name);
295
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (ptr_var != NULL)
296 {
297
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
18 Property local_var(*ptr_var);
298 18 String key = String::duplicate(*name);
299
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 ret.add(key, local_var);
300 }
301 }
302 }
303 }
304 4 break;
305 }
306 }
307 5 return ret;
308 }
309
310 4 size_t Property::getArrayLength() const
311 {
312 4 return gate_property_array_length(&this->impl);
313 }
314 7 Property Property::getArrayItem(size_t index) const
315 {
316 7 gate_property_t const* ptr_var = gate_property_array_get(&this->impl, index);
317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if (NULL == ptr_var)
318 {
319 return Property();
320 }
321 else
322 {
323 7 return Property(*ptr_var);
324 }
325 }
326 5 void Property::addArrayItem(Property const& item)
327 {
328
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if (NULL == gate_property_array_add(&this->impl, item.c_impl()))
329 {
330 GATEXX_RAISE_ERROR(results::OutOfMemory);
331 }
332 5 }
333 1 bool_t Property::removeArrayItem(size_t index)
334 {
335 1 return gate_property_array_remove(&this->impl, index);
336 }
337
338 3 Array<String> Property::getObjectMemberNames() const
339 {
340
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 ArrayList<String> name_list;
341 6 GenericArray names;
342
2/4
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 if (NULL != gate_property_member_names(&this->impl, names.c_impl()))
343 {
344 3 size_t const names_count = names.length();
345
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 3 times.
14 for (size_t ndx = 0; ndx != names_count; ++ndx)
346 {
347 11 gate_string_t const* name = (gate_string_t const*)names.getItemPtr(ndx);
348
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (NULL != name)
349 {
350
1/2
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 name_list.add(String::duplicate(*name));
351 }
352 }
353 }
354
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 return name_list.toArray();
355 }
356 24 Property Property::getObjectMember(String const& name) noexcept
357 {
358 24 gate_property_t const* ptr_var = gate_property_member_get(&this->impl, name.c_impl());
359
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (ptr_var != NULL)
360 {
361 24 return Property(*ptr_var);
362 }
363 else
364 {
365 return Property();
366 }
367 }
368 9 void Property::addObjectMember(String const& name, Property const& value)
369 {
370
1/2
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
9 if (NULL == gate_property_member_add(&this->impl, name.c_impl(), value.c_impl()))
371 {
372 GATEXX_RAISE_ERROR(results::OutOfMemory);
373 }
374 9 }
375 VoidResult Property::tryAddObjectMember(String const& name, Property const& value)
376 {
377 if (NULL == gate_property_member_add(&this->impl, name.c_impl(), value.c_impl()))
378 {
379 return makeErr(results::OutOfMemory);
380 }
381 else
382 {
383 return makeOk();
384 }
385 }
386
387 2 bool_t Property::removeObjectMember(String const& name) noexcept
388 {
389 2 return gate_property_member_remove(&this->impl, name.c_impl());
390 }
391
392 void Property::exportToStruct(gate_struct_t* ptr_struct)
393 {
394 if (this->getType() != Property::Type_Object)
395 {
396 GATEXX_RAISE_ERROR(results::IncorrectType);
397 }
398 result_t result = gate_property_export(this->c_impl(), GATE_TYPE_STRUCT, ptr_struct);
399 GATEXX_CHECK_EXCEPTION(result);
400 }
401
402 5 Property Property::createFrom(gate_property_t& movableProp)
403 {
404 5 Property ret;
405 5 ret.impl = movableProp;
406 5 Mem::clear(movableProp);
407 5 return ret;
408 }
409
410 1 void Property::createCopy(gate_property_t& target, Property const& source)
411 {
412
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if (NULL == gate_property_copy(&target, source.c_impl()))
413 {
414 GATEXX_RAISE_ERROR(results::OutOfMemory);
415 }
416 1 }
417 1 void Property::assignCopy(gate_property_t& target, Property const& source)
418 {
419 gate_property_t tmp;
420
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Property::createCopy(tmp, source);
421
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gate_property_destroy(&target);
422 1 target = tmp;
423 1 }
424
425 1 Property Property::createArray()
426 {
427 1 Property p;
428
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
1 if (NULL == gate_property_create_array(&p.impl, NULL, 0))
429 {
430 GATEXX_RAISE_ERROR(results::OutOfMemory);
431 }
432 1 return p;
433 }
434 1 Property Property::createObject()
435 {
436 1 Property p;
437
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
1 if (NULL == gate_property_create_object(&p.impl))
438 {
439 GATEXX_RAISE_ERROR(results::OutOfMemory);
440 }
441 1 return p;
442 }
443
444 5 Property& Property::operator<<(Property const& newArrayItem)
445 {
446 5 this->addArrayItem(newArrayItem);
447 5 return *this;
448 }
449
450
451
452
453
454
455
456 size_t const PropTable::InvalidIndex = GATE_PROPTABLE_INVALID_INDEX;
457
458 1 PropTable::PropTable()
459 {
460
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 if (NULL == gate_proptable_create(&this->impl))
461 {
462 GATEXX_RAISE_ERROR(results::OutOfMemory);
463 }
464 1 }
465 PropTable::PropTable(PropTable const& src)
466 {
467 if (NULL == gate_proptable_copy(&this->impl, &src.impl))
468 {
469 GATEXX_RAISE_ERROR(results::OutOfMemory);
470 }
471 }
472 PropTable& PropTable::operator=(PropTable const& src)
473 {
474 PropTable that(src);
475 this->swap(that);
476 return *this;
477 }
478 2 PropTable::~PropTable() noexcept
479 {
480 1 gate_proptable_destroy(&this->impl);
481 1 }
482
483 void PropTable::swap(PropTable& table) noexcept
484 {
485 gate::swapRefsNoExcept(this->impl, table.impl);
486 }
487 1 gate_proptable_t* PropTable::c_impl() noexcept
488 {
489 1 return &this->impl;
490 }
491 gate_proptable_t const* PropTable::c_impl() const noexcept
492 {
493 return &this->impl;
494 }
495
496 4 size_t PropTable::insertColumn(String const& columnName, Property::TypeEnum columnType, size_t insertAt)
497 {
498 4 result_t result = gate_proptable_insert_column(&this->impl, columnName.c_impl(), columnType, insertAt);
499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 GATEXX_CHECK_EXCEPTION(result);
500 4 size_t colIndex = gate_proptable_get_column_count(&this->impl) - 1;
501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (insertAt < colIndex)
502 {
503 colIndex = insertAt;
504 }
505 4 return colIndex;
506 }
507 1 void PropTable::removeColumn(String const& columnName)
508 {
509 1 result_t result = gate_proptable_remove_column(&this->impl, columnName.c_impl());
510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(result);
511 1 }
512 1 void PropTable::removeColumnAt(size_t columnIndex)
513 {
514 1 result_t result = gate_proptable_remove_column_at(&this->impl, columnIndex);
515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(result);
516 1 }
517 2 void PropTable::setColumnName(size_t columnIndex, String const& newName)
518 {
519 2 result_t result = gate_proptable_set_column_name(&this->impl, columnIndex, newName.c_impl());
520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 GATEXX_CHECK_EXCEPTION(result);
521 2 }
522 1 size_t PropTable::resolveColumnIndex(String const& columnName)
523 {
524 1 size_t matchIndex = InvalidIndex;
525
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 result_t result = gate_proptable_resolve_column(&this->impl, columnName.c_impl(), &matchIndex);
526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_EXCEPTION(result);
527 1 return matchIndex;
528 }
529
530 6 size_t PropTable::getColumnCount() const
531 {
532 6 return gate_proptable_get_column_count(&this->impl);
533 }
534 1 String PropTable::getColumnName(size_t columnIndex) const
535 {
536 1 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
537
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 result_t result = gate_proptable_get_column_name(&this->impl, columnIndex, &tmp);
538
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_EXCEPTION(result);
539 2 return String::createFrom(tmp);
540 }
541 Property::TypeEnum PropTable::getColumnType(size_t columnIndex) const
542 {
543 return Property::TypeEnum(gate_proptable_get_column_type(&this->impl, columnIndex));
544 }
545
546 3 size_t PropTable::getRowCount() const
547 {
548 3 return gate_proptable_get_row_count(&this->impl);
549 }
550 3 Property PropTable::getItemAt(size_t rowIndex, size_t columnIndex) const
551 {
552 3 gate_property_t const* ptr_prop = gate_proptable_get_item_at(&this->impl, rowIndex, columnIndex);
553
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (ptr_prop)
554 {
555 3 return Property(*ptr_prop);
556 }
557 else
558 {
559 GATEXX_RAISE_ERROR(results::OutOfBounds);
560 return Property();
561 }
562 }
563 4 Property PropTable::getItem(size_t rowIndex, String const& columnName) const
564 {
565 4 gate_property_t const* ptr_prop = gate_proptable_get_item(&this->impl, rowIndex, columnName.c_impl());
566
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (ptr_prop)
567 {
568 4 return Property(*ptr_prop);
569 }
570 else
571 {
572 GATEXX_RAISE_EXCEPTION(results::NoMatch, "Cannot resolve column", 0);
573 return Property();
574 }
575 }
576
577 2 size_t PropTable::insertRow(size_t insertAt)
578 {
579 2 result_t result = gate_proptable_insert_row(&this->impl, insertAt);
580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 GATEXX_CHECK_EXCEPTION(result);
581 2 size_t rowIndex = gate_proptable_get_row_count(&this->impl) - 1;
582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (insertAt < rowIndex)
583 {
584 rowIndex = insertAt;
585 }
586 2 return rowIndex;
587 }
588 1 void PropTable::removeRow(size_t rowIndex)
589 {
590 1 result_t result = gate_proptable_remove_row(&this->impl, rowIndex);
591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(result);
592 1 }
593
594 1 void PropTable::setItemAt(size_t rowIndex, size_t columnIndex, Property const& prop)
595 {
596 1 result_t result = gate_proptable_set_item_at(&this->impl, rowIndex, columnIndex, prop.c_impl());
597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(result);
598 1 }
599
600 2 void PropTable::setItem(size_t rowIndex, String const& columnName, Property const& prop)
601 {
602 2 result_t result = gate_proptable_set_item(&this->impl, rowIndex, columnName.c_impl(), prop.c_impl());
603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 GATEXX_CHECK_EXCEPTION(result);
604 2 }
605
606 1 Property PropTable::operator()(size_t rowIndex, size_t columnIndex) const
607 {
608 1 return this->getItemAt(rowIndex, columnIndex);
609 }
610 2 Property PropTable::operator()(size_t rowIndex, String const& columnName) const
611 {
612 2 return this->getItem(rowIndex, columnName);
613 }
614
615
616 } // end of namespace gate
617