GCC Code Coverage Report


Directory: src/gate/
File: src/gate/tech/cxx_contacts.cpp
Date: 2026-12-03 19:36:00
Exec Total Coverage
Lines: 252 255 98.8%
Functions: 98 99 99.0%
Branches: 11 28 39.3%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2026, Stefan Meislinger |
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/tech/contacts.hpp"
30 #include "gate/utilities.hpp"
31
32 namespace gate
33 {
34 namespace tech
35 {
36
37 4 ContactAddress::ContactAddress()
38 {
39 4 gate_contact_address_create_copy(&this->impl, NULL);
40 4 }
41 2 ContactAddress::ContactAddress(gate_contact_address_t const& src)
42 {
43 2 gate_contact_address_create_copy(&this->impl, &src);
44 2 }
45 4 ContactAddress::ContactAddress(ContactAddress const& src)
46 {
47 4 gate_contact_address_create_copy(&this->impl, &src.impl);
48 4 }
49 1 ContactAddress& ContactAddress::operator=(ContactAddress const& src)
50 {
51 1 gate_contact_address_destroy(&this->impl);
52 1 gate_contact_address_create_copy(&this->impl, &src.impl);
53 1 return *this;
54 }
55 20 ContactAddress::~ContactAddress() noexcept
56 {
57 10 gate_contact_address_destroy(&this->impl);
58 10 }
59 3 gate_contact_address_t const* ContactAddress::c_impl() const
60 {
61 3 return &this->impl;
62 }
63
64 21 ContactAddress& ContactAddress::writeString(gate_string_t& dest, String const& value)
65 {
66 21 String::assign(dest, value);
67 21 return *this;
68 }
69 1 gate_contact_address_type_t ContactAddress::getAddressType() const
70 {
71 1 return this->impl.address_type;
72 }
73 1 String ContactAddress::getPoBox() const
74 {
75 1 return String(this->impl.po_box);
76 }
77 1 String ContactAddress::getExtendedAddress() const
78 {
79 1 return String(this->impl.extended);
80 }
81 1 String ContactAddress::getStreet() const
82 {
83 1 return String(this->impl.street);
84 }
85 1 String ContactAddress::getLocality() const
86 {
87 1 return String(this->impl.locality);
88 }
89 1 String ContactAddress::getRegion() const
90 {
91 1 return String(this->impl.region);
92 }
93 1 String ContactAddress::getCode() const
94 {
95 1 return String(this->impl.code);
96 }
97 1 String ContactAddress::getCountry() const
98 {
99 1 return String(this->impl.country);
100 }
101
102 3 ContactAddress& ContactAddress::setAddressType(gate_contact_address_type_t value)
103 {
104 3 this->impl.address_type = value;
105 3 return *this;
106 }
107 3 ContactAddress& ContactAddress::setPoBox(String const& value)
108 {
109 3 return this->writeString(this->impl.po_box, value);
110 }
111 3 ContactAddress& ContactAddress::setExtendedAddress(String const& value)
112 {
113 3 return this->writeString(this->impl.extended, value);
114 }
115 3 ContactAddress& ContactAddress::setStreet(String const& value)
116 {
117 3 return this->writeString(this->impl.street, value);
118 }
119 3 ContactAddress& ContactAddress::setLocality(String const& value)
120 {
121 3 return this->writeString(this->impl.locality, value);
122 }
123 3 ContactAddress& ContactAddress::setRegion(String const& value)
124 {
125 3 return this->writeString(this->impl.region, value);
126 }
127 3 ContactAddress& ContactAddress::setCode(String const& value)
128 {
129 3 return this->writeString(this->impl.code, value);
130 }
131 3 ContactAddress& ContactAddress::setCountry(String const& value)
132 {
133 3 return this->writeString(this->impl.country, value);
134 }
135
136
137
138 4 ContactTelephone::ContactTelephone()
139 {
140 4 gate_contact_telephone_create_copy(&this->impl, NULL);
141 4 }
142 2 ContactTelephone::ContactTelephone(gate_contact_telephone_t const& src)
143 {
144 2 gate_contact_telephone_create_copy(&this->impl, &src);
145 2 }
146 4 ContactTelephone::ContactTelephone(ContactTelephone const& src)
147 {
148 4 gate_contact_telephone_create_copy(&this->impl, &src.impl);
149 4 }
150 1 ContactTelephone& ContactTelephone::operator=(ContactTelephone const& src)
151 {
152 1 gate_contact_telephone_destroy(&this->impl);
153 1 gate_contact_telephone_create_copy(&this->impl, &src.impl);
154 1 return *this;
155 }
156 20 ContactTelephone::~ContactTelephone() noexcept
157 {
158 10 gate_contact_telephone_destroy(&this->impl);
159 10 }
160 3 gate_contact_telephone_t const* ContactTelephone::c_impl() const
161 {
162 3 return &this->impl;
163 }
164
165 1 gate_contact_recipient_type_t ContactTelephone::getRecipientType() const
166 {
167 1 return this->impl.telephone_type;
168 }
169 1 String ContactTelephone::getNumber() const
170 {
171 1 return String(this->impl.number);
172 }
173
174 3 ContactTelephone& ContactTelephone::setRecipientType(gate_contact_recipient_type_t value)
175 {
176 3 this->impl.telephone_type = value;
177 3 return *this;
178 }
179 3 ContactTelephone& ContactTelephone::setNumber(String const& value)
180 {
181 3 String::assign(this->impl.number, value);
182 3 return *this;
183 }
184
185
186
187 4 ContactEmail::ContactEmail()
188 {
189 4 gate_contact_email_create_copy(&this->impl, NULL);
190 4 }
191 2 ContactEmail::ContactEmail(gate_contact_email_t const& src)
192 {
193 2 gate_contact_email_create_copy(&this->impl, &src);
194 2 }
195 4 ContactEmail::ContactEmail(ContactEmail const& src)
196 {
197 4 gate_contact_email_create_copy(&this->impl, &src.impl);
198 4 }
199 1 ContactEmail& ContactEmail::operator=(ContactEmail const& src)
200 {
201 1 gate_contact_email_destroy(&this->impl);
202 1 gate_contact_email_create_copy(&this->impl, &src.impl);
203 1 return *this;
204 }
205 20 ContactEmail::~ContactEmail() noexcept
206 {
207 10 gate_contact_email_destroy(&this->impl);
208 10 }
209 3 gate_contact_email_t const* ContactEmail::c_impl() const
210 {
211 3 return &this->impl;
212 }
213
214 1 gate_contact_recipient_type_t ContactEmail::getRecipientType() const
215 {
216 1 return this->impl.email_type;
217 }
218 1 String ContactEmail::getAddress() const
219 {
220 1 return String(this->impl.address);
221 }
222
223 3 ContactEmail& ContactEmail::setRecipientType(gate_contact_recipient_type_t value)
224 {
225 3 this->impl.email_type = value;
226 3 return *this;
227 }
228 3 ContactEmail& ContactEmail::setAddress(String const& value)
229 {
230 3 String::assign(this->impl.address, value);
231 3 return *this;
232 }
233
234
235
236 4 ContactOrganization::ContactOrganization()
237 {
238 4 gate_contact_organization_create_copy(&this->impl, NULL);
239 4 }
240 2 ContactOrganization::ContactOrganization(gate_contact_organization_t const& src)
241 {
242 2 gate_contact_organization_create_copy(&this->impl, &src);
243 2 }
244 4 ContactOrganization::ContactOrganization(ContactOrganization const& src)
245 {
246 4 gate_contact_organization_create_copy(&this->impl, &src.impl);
247 4 }
248 1 ContactOrganization& ContactOrganization::operator=(ContactOrganization const& src)
249 {
250 1 gate_contact_organization_destroy(&this->impl);
251 1 gate_contact_organization_create_copy(&this->impl, &src.impl);
252 1 return *this;
253 }
254 20 ContactOrganization::~ContactOrganization() noexcept
255 {
256 10 gate_contact_organization_destroy(&this->impl);
257 10 }
258 3 gate_contact_organization_t const* ContactOrganization::c_impl() const
259 {
260 3 return &this->impl;
261 }
262 1 String ContactOrganization::getOrgName() const
263 {
264 1 return String(this->impl.org_name);
265 }
266 1 String ContactOrganization::getDivision() const
267 {
268 1 return String(this->impl.division);
269 }
270 1 String ContactOrganization::getDepartment() const
271 {
272 1 return String(this->impl.department);
273 }
274 1 String ContactOrganization::getRole() const
275 {
276 1 return String(this->impl.role);
277 }
278 1 String ContactOrganization::getTitle() const
279 {
280 1 return String(this->impl.title);
281 }
282
283 15 ContactOrganization& ContactOrganization::writeString(gate_string_t& dest, String const& value)
284 {
285 15 String::assign(dest, value);
286 15 return *this;
287 }
288
289 3 ContactOrganization& ContactOrganization::setOrgName(String const& value)
290 {
291 3 return this->writeString(this->impl.org_name, value);
292 }
293 3 ContactOrganization& ContactOrganization::setDivision(String const& value)
294 {
295 3 return this->writeString(this->impl.division, value);
296 }
297 3 ContactOrganization& ContactOrganization::setDepartment(String const& value)
298 {
299 3 return this->writeString(this->impl.department, value);
300 }
301 3 ContactOrganization& ContactOrganization::setRole(String const& value)
302 {
303 3 return this->writeString(this->impl.role, value);
304 }
305 3 ContactOrganization& ContactOrganization::setTitle(String const& value)
306 {
307 3 return this->writeString(this->impl.title, value);
308 }
309
310
311
312 3 ContactCard::ContactCard()
313 {
314 3 gate_contact_card_create_copy(&this->impl, NULL);
315 3 }
316 1 ContactCard::ContactCard(gate_contact_card_t const& src)
317 {
318 1 gate_contact_card_create_copy(&this->impl, &src);
319 1 }
320 2 ContactCard::ContactCard(ContactCard const& src)
321 {
322 2 gate_contact_card_create_copy(&this->impl, &src.impl);
323 2 }
324 1 ContactCard& ContactCard::operator=(ContactCard const& src)
325 {
326 1 gate_contact_card_create_copy(&this->impl, &src.impl);
327 1 return *this;
328 }
329 12 ContactCard::~ContactCard() noexcept
330 {
331 6 gate_contact_card_destroy(&this->impl);
332 6 }
333 1 gate_contact_card_t const* ContactCard::c_impl() const
334 {
335 1 return &this->impl;
336 }
337
338 1 String ContactCard::getDisplayName() const
339 {
340 1 return String(this->impl.display_name);
341 }
342 1 String ContactCard::getFamilyName() const
343 {
344 1 return String(this->impl.family_name);
345 }
346 1 String ContactCard::getGivenName() const
347 {
348 1 return String(this->impl.given_name);
349 }
350 1 String ContactCard::getAdditionalName() const
351 {
352 1 return String(this->impl.additional_name);
353 }
354 1 String ContactCard::getHonoricPrefix() const
355 {
356 1 return String(this->impl.honoric_prefix);
357 }
358 1 String ContactCard::getHonoricSuffix() const
359 {
360 1 return String(this->impl.honoric_suffix);
361 }
362 1 Array<ContactAddress> ContactCard::getAddresses() const
363 {
364
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 ArrayList<ContactAddress> lst = util::convertArrayListTypes<ContactAddress, gate_contact_address_t>(this->impl.addresses);
365
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 return lst.toArray();
366 }
367 1 Array<ContactTelephone> ContactCard::getTelephones() const
368 {
369
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 ArrayList<ContactTelephone> lst = util::convertArrayListTypes<ContactTelephone, gate_contact_telephone_t>(this->impl.telephones);
370
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 return lst.toArray();
371 }
372 1 Array<ContactEmail> ContactCard::getEmailAddresses() const
373 {
374
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 ArrayList<ContactEmail> lst = util::convertArrayListTypes<ContactEmail, gate_contact_email_t>(this->impl.email_addresses);
375
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 return lst.toArray();
376 }
377 1 String ContactCard::getNickname() const
378 {
379 1 return String(this->impl.nickname);
380 }
381 1 char ContactCard::getGender() const
382 {
383 1 return this->impl.gender;
384 }
385 1 Date ContactCard::getBirthday() const
386 {
387 1 return Date(this->impl.birthday);
388 }
389 1 Array<ContactOrganization> ContactCard::getOrganizations() const
390 {
391
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 ArrayList<ContactOrganization> lst = util::convertArrayListTypes<ContactOrganization, gate_contact_organization_t>(this->impl.organizations);
392
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 return lst.toArray();
393 }
394 1 Time ContactCard::getCreationTime() const
395 {
396 1 return Time(this->impl.creation_time);
397 }
398 1 Time ContactCard::getUpdateTime() const
399 {
400 1 return Time(this->impl.update_time);
401 }
402
403 14 ContactCard& ContactCard::writeString(gate_string_t& dest, String const& value)
404 {
405 14 String::assign(dest, value);
406 14 return *this;
407 }
408
409 2 ContactCard& ContactCard::setDisplayName(String const& value)
410 {
411 2 return this->writeString(this->impl.display_name, value);
412 }
413 2 ContactCard& ContactCard::setFamilyName(String const& value)
414 {
415 2 return this->writeString(this->impl.family_name, value);
416 }
417 2 ContactCard& ContactCard::setGivenName(String const& value)
418 {
419 2 return this->writeString(this->impl.given_name, value);
420 }
421 2 ContactCard& ContactCard::setAdditionalName(String const& value)
422 {
423 2 return this->writeString(this->impl.additional_name, value);
424 }
425 2 ContactCard& ContactCard::setHonoricPrefix(String const& value)
426 {
427 2 return this->writeString(this->impl.honoric_prefix, value);
428 }
429 2 ContactCard& ContactCard::setHonoricSuffix(String const& value)
430 {
431 2 return this->writeString(this->impl.honoric_suffix, value);
432 }
433 2 ContactCard& ContactCard::setAddresses(Array<ContactAddress> const& value)
434 {
435 2 gate_arraylist_clear(this->impl.addresses);
436 2 util::convertArrayIntoCTypeArrayList<gate_contact_address_t, ContactAddress>(this->impl.addresses, value);
437 2 return *this;
438 }
439 2 ContactCard& ContactCard::setTelephones(Array<ContactTelephone> const& value)
440 {
441 2 gate_arraylist_clear(this->impl.telephones);
442 2 util::convertArrayIntoCTypeArrayList<gate_contact_telephone_t, ContactTelephone>(this->impl.telephones, value);
443 2 return *this;
444 }
445 2 ContactCard& ContactCard::setEmailAddresses(Array<ContactEmail> const& value)
446 {
447 2 gate_arraylist_clear(this->impl.email_addresses);
448 2 util::convertArrayIntoCTypeArrayList<gate_contact_email_t, ContactEmail>(this->impl.email_addresses, value);
449 2 return *this;
450 }
451 2 ContactCard& ContactCard::setNickname(String const& value)
452 {
453 2 return this->writeString(this->impl.nickname, value);
454 }
455 2 ContactCard& ContactCard::setGender(char value)
456 {
457 2 this->impl.gender = value;
458 2 return *this;
459 }
460 2 ContactCard& ContactCard::setBirthday(Date const& value)
461 {
462 2 this->impl.birthday = value;
463 2 return *this;
464 }
465 2 ContactCard& ContactCard::setOrganizations(Array<ContactOrganization> const& value)
466 {
467 2 gate_arraylist_clear(this->impl.organizations);
468 2 util::convertArrayIntoCTypeArrayList<gate_contact_organization_t, ContactOrganization>(this->impl.organizations, value);
469 2 return *this;
470 }
471 2 ContactCard& ContactCard::setCreationTime(Time const& value)
472 {
473 2 this->impl.creation_time = value.timestamp;
474 2 return *this;
475 }
476 2 ContactCard& ContactCard::setUpdateTime(Time const& value)
477 {
478 2 this->impl.update_time = value.timestamp;
479 2 return *this;
480 }
481
482
483 ✗ Array<ContactCard> Contacts::load(FormatEnum format, Stream& inputStream)
484 {
485 ✗ ArrayList<ContactCard> cards;
486 // TODO
487 ✗ return cards.toArray();
488 }
489
490 1 void Contacts::store(FormatEnum format, Array<ContactCard> const& cards, Stream& outputStream)
491 {
492 gate_enumerator_t e;
493
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 gate_array_enumerate(cards.c_impl(), &e);
494
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 result_t result = gate_contact_cards_store(format, &e, outputStream.c_impl());
495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_EXCEPTION(result);
496 1 }
497
498
499 } // namespace tech
500 } // namespace gate
501