GCC Code Coverage Report


Directory: src/gate/
File: src/gate/cxx_properties.cpp
Date: 2026-09-21 06:26:40
Exec Total Coverage
Lines: 266 313 85.0%
Functions: 62 67 92.5%
Branches: 111 237 46.8%

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 77 Property::Property()
37 {
38 77 gate_property_create_empty(&this->impl);
39 77 }
40 7 Property::Property(bool_t const& bool_value)
41 {
42 7 gate_property_create_bool(&this->impl, bool_value);
43 7 }
44 6 Property::Property(int64_t int_value)
45 {
46 6 gate_property_create_int(&this->impl, int_value);
47 6 }
48 1 Property::Property(real32_t const& flt_value)
49 {
50 1 gate_property_create_real(&this->impl, flt_value);
51 1 }
52 6 Property::Property(real64_t const& dbl_value)
53 {
54 6 gate_property_create_real(&this->impl, dbl_value);
55 6 }
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 6 Property::Property(char const* c_string)
64 {
65
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 if (NULL == gate_property_create_text(&this->impl, c_string))
66 {
67 GATEXX_RAISE_ERROR(results::OutOfMemory);
68 }
69 6 }
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 70 Property::Property(gate_property_t const& src_base)
116 {
117
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
70 if (NULL == gate_property_copy(&this->impl, &src_base))
118 {
119 GATEXX_RAISE_ERROR(results::OutOfMemory);
120 }
121 70 }
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 48 Property::Property(Property const& src)
129 {
130
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
48 if (NULL == gate_property_copy(&this->impl, &src.impl))
131 {
132 GATEXX_RAISE_ERROR(results::OutOfMemory);
133 }
134 48 }
135
136 #if defined(GATE_COMPILER_SUPPORTS_CPP_MOVEREFS)
137 Property::Property(Property&& src)
138 : impl(src.impl)
139 {
140 Mem::clear(src.impl);
141 }
142
143 16 Property& Property::operator=(Property&& src)
144 {
145 16 this->swap(src);
146 16 gate_property_destroy(&src.impl);
147 16 return *this;
148 }
149 #endif
150
151
152 2 Property& Property::operator=(Property const& src)
153 {
154
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (this != &src)
155 {
156 gate_property_t tmp;
157
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_copy(&tmp, &src.impl))
158 {
159 GATEXX_RAISE_ERROR(results::OutOfMemory);
160 }
161
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 gate_property_destroy(&this->impl);
162 2 this->impl = tmp;
163 }
164 2 return *this;
165 }
166 464 Property::~Property() noexcept
167 {
168 232 gate_property_destroy(&this->impl);
169 232 }
170
171 23 void Property::swap(Property& that) noexcept
172 {
173 23 gate::swapRefs(this->impl, that.impl);
174 23 }
175
176
177 36 gate_property_t* Property::c_impl()
178 {
179 36 return &this->impl;
180 }
181 41 gate_property_t const* Property::c_impl() const
182 {
183 41 return &this->impl;
184 }
185
186 42 Property::TypeEnum Property::getType() const
187 {
188 42 return TypeEnum(this->impl.value_type);
189 }
190
191 13 bool_t Property::getBool() const
192 {
193 bool_t ret;
194
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 result_t result = gate_property_get_bool(&this->impl, &ret);
195
3/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2 times.
13 return GATE_SUCCEEDED(result) ? ret : false;
196 }
197 30 int64_t Property::getInt() const
198 {
199 int64_t ret;
200
1/2
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
30 result_t result = gate_property_get_int(&this->impl, &ret);
201
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 return GATE_SUCCEEDED(result) ? ret : 0;
202 }
203 11 real64_t Property::getReal() const
204 {
205 real64_t ret;
206
1/2
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
11 result_t result = gate_property_get_real(&this->impl, &ret);
207
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 return GATE_SUCCEEDED(result) ? ret : 0.0;
208 }
209 22 String Property::getString() const
210 {
211 gate_string_t str;
212
1/2
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
22 result_t result = gate_property_get_string(&this->impl, &str);
213
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
44 return GATE_SUCCEEDED(result) ? String::createFrom(str) : String();
214 }
215 7 Array<Property> Property::getArray() const
216 {
217
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
14 ArrayList<Property> list;
218
219
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())
220 {
221 1 case Property::Type_Empty:
222 {
223 1 break;
224 }
225 1 case Property::Type_Bool:
226 case Property::Type_Int:
227 case Property::Type_Real:
228 case Property::Type_String:
229 {
230
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 list.add(*this);
231 1 break;
232 }
233
234 4 case Property::Type_Array:
235 {
236
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 size_t array_len = gate_property_array_length(&this->impl);
237
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
17 for (size_t ndx = 0; ndx != array_len; ++ndx)
238 {
239
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);
240
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (var_item != NULL)
241 {
242
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
26 Property var(*var_item);
243
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 list.add(var);
244 }
245 }
246 4 break;
247 }
248 1 case Property::Type_Object:
249 {
250 2 GenericArray names;
251
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()))
252 {
253 GATEXX_RAISE_ERROR(results::OutOfMemory);
254 }
255 1 size_t array_len = names.length();
256
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (size_t ndx = 0; ndx != array_len; ++ndx)
257 {
258 4 gate_string_t const* name = (gate_string_t const*)names.getItemPtr(ndx);
259
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (name != NULL)
260 {
261
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));
262 }
263 }
264 1 break;
265 }
266 }
267
268
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
14 return list.toArray();
269 }
270 10 Property::object_members_t Property::getObjectMembers() const
271 {
272 10 Property::object_members_t ret;
273
3/4
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
10 switch (this->getType())
274 {
275 5 case Property::Type_Empty:
276 case Property::Type_Bool:
277 case Property::Type_Int:
278 case Property::Type_Real:
279 case Property::Type_String:
280 {
281 5 break;
282 }
283 1 case Property::Type_Array:
284 {
285
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 size_t array_len = gate_property_array_length(&this->impl);
286
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (size_t ndx = 0; ndx != array_len; ++ndx)
287 {
288
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);
289
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (ptr_var != NULL)
290 {
291 char buffer[256];
292
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
8 Property local_var(*ptr_var);
293
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);
294 8 String key = String::createStatic(buffer, buffer_used);
295
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 ret.add(key, local_var);
296 }
297 }
298 1 break;
299 }
300 4 case Property::Type_Object:
301 {
302 8 GenericArray names;
303
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()))
304 {
305 4 size_t const names_count = names.length();
306
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 4 times.
13 for (size_t ndx = 0; ndx != names_count; ++ndx)
307 {
308 9 gate_string_t const* name = (gate_string_t const*)names.getItemPtr(ndx);
309
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (NULL != name)
310 {
311
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);
312
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (ptr_var != NULL)
313 {
314
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
18 Property local_var(*ptr_var);
315 18 String key = String::duplicate(*name);
316
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 ret.add(key, local_var);
317 }
318 }
319 }
320 }
321 4 break;
322 }
323 }
324 10 return ret;
325 }
326
327 4 size_t Property::getArrayLength() const
328 {
329 4 return gate_property_array_length(&this->impl);
330 }
331 8 Property Property::getArrayItem(size_t index) const
332 {
333 8 gate_property_t const* ptr_var = gate_property_array_get(&this->impl, index);
334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (NULL == ptr_var)
335 {
336 return Property();
337 }
338 else
339 {
340 8 return Property(*ptr_var);
341 }
342 }
343 6 void Property::addArrayItem(Property const& item)
344 {
345
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 if (NULL == gate_property_array_add(&this->impl, item.c_impl()))
346 {
347 GATEXX_RAISE_ERROR(results::OutOfMemory);
348 }
349 6 }
350 1 bool_t Property::removeArrayItem(size_t index)
351 {
352 1 return gate_property_array_remove(&this->impl, index);
353 }
354
355 3 Array<String> Property::getObjectMemberNames() const
356 {
357
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 ArrayList<String> name_list;
358 6 GenericArray names;
359
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()))
360 {
361 3 size_t const names_count = names.length();
362
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 3 times.
14 for (size_t ndx = 0; ndx != names_count; ++ndx)
363 {
364 11 gate_string_t const* name = (gate_string_t const*)names.getItemPtr(ndx);
365
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (NULL != name)
366 {
367
1/2
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 name_list.add(String::duplicate(*name));
368 }
369 }
370 }
371
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 return name_list.toArray();
372 }
373 25 Property Property::getObjectMember(String const& name) noexcept
374 {
375 25 gate_property_t const* ptr_var = gate_property_member_get(&this->impl, name.c_impl());
376
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (ptr_var != NULL)
377 {
378 25 return Property(*ptr_var);
379 }
380 else
381 {
382 return Property();
383 }
384 }
385 10 void Property::addObjectMember(String const& name, Property const& value)
386 {
387
1/2
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
10 if (NULL == gate_property_member_add(&this->impl, name.c_impl(), value.c_impl()))
388 {
389 GATEXX_RAISE_ERROR(results::OutOfMemory);
390 }
391 10 }
392 VoidResult Property::tryAddObjectMember(String const& name, Property const& value)
393 {
394 if (NULL == gate_property_member_add(&this->impl, name.c_impl(), value.c_impl()))
395 {
396 return makeErrResult(results::OutOfMemory);
397 }
398 else
399 {
400 return makeOk();
401 }
402 }
403
404 2 bool_t Property::removeObjectMember(String const& name) noexcept
405 {
406 2 return gate_property_member_remove(&this->impl, name.c_impl());
407 }
408
409 void Property::exportToStruct(gate_struct_t* ptr_struct)
410 {
411 if (this->getType() != Property::Type_Object)
412 {
413 GATEXX_RAISE_ERROR(results::IncorrectType);
414 }
415 result_t result = gate_property_export(this->c_impl(), GATE_TYPE_STRUCT, ptr_struct);
416 GATEXX_CHECK_EXCEPTION(result);
417 }
418
419 5 Property Property::createFrom(gate_property_t& movableProp)
420 {
421 5 Property ret;
422 5 ret.impl = movableProp;
423 5 Mem::clear(movableProp);
424 5 return ret;
425 }
426
427 1 void Property::createCopy(gate_property_t& target, Property const& source)
428 {
429
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if (NULL == gate_property_copy(&target, source.c_impl()))
430 {
431 GATEXX_RAISE_ERROR(results::OutOfMemory);
432 }
433 1 }
434 1 void Property::assignCopy(gate_property_t& target, Property const& source)
435 {
436 gate_property_t tmp;
437
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Property::createCopy(tmp, source);
438
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gate_property_destroy(&target);
439 1 target = tmp;
440 1 }
441
442 3 Property Property::createArray()
443 {
444 3 Property p;
445
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
3 if (NULL == gate_property_create_array(&p.impl, NULL, 0))
446 {
447 GATEXX_RAISE_ERROR(results::OutOfMemory);
448 }
449 3 return p;
450 }
451 6 Property Property::createObject()
452 {
453 6 Property p;
454
2/4
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
6 if (NULL == gate_property_create_object(&p.impl))
455 {
456 GATEXX_RAISE_ERROR(results::OutOfMemory);
457 }
458 6 return p;
459 }
460
461 5 Property& Property::operator<<(Property const& newArrayItem)
462 {
463 5 this->addArrayItem(newArrayItem);
464 5 return *this;
465 }
466
467
468
469
470
471
472
473 size_t const PropTable::InvalidIndex = GATE_PROPTABLE_INVALID_INDEX;
474
475 2 PropTable::PropTable()
476 {
477
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (NULL == gate_proptable_create(&this->impl))
478 {
479 GATEXX_RAISE_ERROR(results::OutOfMemory);
480 }
481 2 }
482 2 PropTable::PropTable(PropTable const& src)
483 {
484
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (NULL == gate_proptable_copy(&this->impl, &src.impl))
485 {
486 GATEXX_RAISE_ERROR(results::OutOfMemory);
487 }
488 2 }
489 1 PropTable& PropTable::operator=(PropTable const& src)
490 {
491
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 PropTable that(src);
492 1 this->swap(that);
493 2 return *this;
494 }
495 8 PropTable::~PropTable() noexcept
496 {
497 4 gate_proptable_destroy(&this->impl);
498 4 }
499
500 2 void PropTable::swap(PropTable& table) noexcept
501 {
502 2 gate::swapRefsNoExcept(this->impl, table.impl);
503 2 }
504 2 gate_proptable_t* PropTable::c_impl() noexcept
505 {
506 2 return &this->impl;
507 }
508 gate_proptable_t const* PropTable::c_impl() const noexcept
509 {
510 return &this->impl;
511 }
512
513 4 size_t PropTable::insertColumn(String const& columnName, Property::TypeEnum columnType, size_t insertAt)
514 {
515 4 result_t result = gate_proptable_insert_column(&this->impl, columnName.c_impl(), columnType, insertAt);
516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 GATEXX_CHECK_EXCEPTION(result);
517 4 size_t colIndex = gate_proptable_get_column_count(&this->impl) - 1;
518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (insertAt < colIndex)
519 {
520 colIndex = insertAt;
521 }
522 4 return colIndex;
523 }
524 1 void PropTable::removeColumn(String const& columnName)
525 {
526 1 result_t result = gate_proptable_remove_column(&this->impl, columnName.c_impl());
527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(result);
528 1 }
529 1 void PropTable::removeColumnAt(size_t columnIndex)
530 {
531 1 result_t result = gate_proptable_remove_column_at(&this->impl, columnIndex);
532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(result);
533 1 }
534 2 void PropTable::setColumnName(size_t columnIndex, String const& newName)
535 {
536 2 result_t result = gate_proptable_set_column_name(&this->impl, columnIndex, newName.c_impl());
537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 GATEXX_CHECK_EXCEPTION(result);
538 2 }
539 1 size_t PropTable::resolveColumnIndex(String const& columnName)
540 {
541 1 size_t matchIndex = InvalidIndex;
542
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);
543
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_EXCEPTION(result);
544 1 return matchIndex;
545 }
546
547 6 size_t PropTable::getColumnCount() const
548 {
549 6 return gate_proptable_get_column_count(&this->impl);
550 }
551 1 String PropTable::getColumnName(size_t columnIndex) const
552 {
553 1 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
554
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 result_t result = gate_proptable_get_column_name(&this->impl, columnIndex, &tmp);
555
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_EXCEPTION(result);
556 2 return String::createFrom(tmp);
557 }
558 1 Property::TypeEnum PropTable::getColumnType(size_t columnIndex) const
559 {
560 1 return Property::TypeEnum(gate_proptable_get_column_type(&this->impl, columnIndex));
561 }
562
563 3 size_t PropTable::getRowCount() const
564 {
565 3 return gate_proptable_get_row_count(&this->impl);
566 }
567 3 Property PropTable::getItemAt(size_t rowIndex, size_t columnIndex) const
568 {
569 3 gate_property_t const* ptr_prop = gate_proptable_get_item_at(&this->impl, rowIndex, columnIndex);
570
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (ptr_prop)
571 {
572 3 return Property(*ptr_prop);
573 }
574 else
575 {
576 GATEXX_RAISE_ERROR(results::OutOfBounds);
577 return Property();
578 }
579 }
580 4 Property PropTable::getItem(size_t rowIndex, String const& columnName) const
581 {
582 4 gate_property_t const* ptr_prop = gate_proptable_get_item(&this->impl, rowIndex, columnName.c_impl());
583
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (ptr_prop)
584 {
585 4 return Property(*ptr_prop);
586 }
587 else
588 {
589 GATEXX_RAISE_EXCEPTION(results::NoMatch, "Cannot resolve column", 0);
590 return Property();
591 }
592 }
593
594 2 size_t PropTable::insertRow(size_t insertAt)
595 {
596 2 result_t result = gate_proptable_insert_row(&this->impl, insertAt);
597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 GATEXX_CHECK_EXCEPTION(result);
598 2 size_t rowIndex = gate_proptable_get_row_count(&this->impl) - 1;
599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (insertAt < rowIndex)
600 {
601 rowIndex = insertAt;
602 }
603 2 return rowIndex;
604 }
605 1 void PropTable::removeRow(size_t rowIndex)
606 {
607 1 result_t result = gate_proptable_remove_row(&this->impl, rowIndex);
608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(result);
609 1 }
610
611 1 void PropTable::setItemAt(size_t rowIndex, size_t columnIndex, Property const& prop)
612 {
613 1 result_t result = gate_proptable_set_item_at(&this->impl, rowIndex, columnIndex, prop.c_impl());
614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(result);
615 1 }
616
617 2 void PropTable::setItem(size_t rowIndex, String const& columnName, Property const& prop)
618 {
619 2 result_t result = gate_proptable_set_item(&this->impl, rowIndex, columnName.c_impl(), prop.c_impl());
620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 GATEXX_CHECK_EXCEPTION(result);
621 2 }
622
623 1 Property PropTable::operator()(size_t rowIndex, size_t columnIndex) const
624 {
625 1 return this->getItemAt(rowIndex, columnIndex);
626 }
627 2 Property PropTable::operator()(size_t rowIndex, String const& columnName) const
628 {
629 2 return this->getItem(rowIndex, columnName);
630 }
631
632
633 } // end of namespace gate
634