GCC Code Coverage Report


Directory: src/gate/
File: src/gate/system/cxx_configurations.cpp
Date: 2025-09-14 13:10:38
Exec Total Coverage
Lines: 32 41 78.0%
Functions: 7 9 77.8%
Branches: 18 32 56.2%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2025, 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/system/configurations.hpp"
30 #include "gate/exceptions.hpp"
31
32 namespace gate
33 {
34 namespace sys
35 {
36
37 1 AppConfig::AppConfig(String const& appName, String const& sourceName, ScopeEnum scope)
38
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 : app(appName.clone()), source(sourceName.clone()), scope(static_cast<enumint_t>(scope))
39 {
40 1 }
41 AppConfig::AppConfig(AppConfig const& src)
42 : app(src.app), source(src.source), scope(src.scope)
43 {
44 }
45 AppConfig& AppConfig::operator=(AppConfig const& src)
46 {
47 if (this != &src)
48 {
49 this->app = src.app;
50 this->source = src.source;
51 this->scope = src.scope;
52 }
53 return *this;
54 }
55 1 AppConfig::~AppConfig() noexcept
56 {
57 1 }
58
59 2 String AppConfig::read(String const& key, String const& subcategory)
60 {
61 2 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
62
3/4
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
5 result_t res = gate_appconfig_read_text(this->app.c_impl(), this->source.c_impl(),
63 3 subcategory.empty() ? NULL : subcategory.c_impl(), this->scope, key.c_impl(), &tmp);
64
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 GATEXX_CHECK_EXCEPTION(res);
65 4 return String::createFrom(tmp);
66 }
67 2 int32_t AppConfig::readNum(String const& key, String const& subcategory)
68 {
69 2 gate_int32_t num = 0;
70
3/4
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
5 result_t res = gate_appconfig_read_num(this->app.c_impl(), this->source.c_impl(),
71 3 subcategory.empty() ? NULL : subcategory.c_impl(), this->scope, key.c_impl(), &num);
72
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 GATEXX_CHECK_EXCEPTION(res);
73 2 return num;
74 }
75
76 2 void AppConfig::write(String const& key, String const& value, String const& subcategory)
77 {
78
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
5 result_t res = gate_appconfig_write_text(this->app.c_impl(), this->source.c_impl(),
79 3 subcategory.empty() ? NULL : subcategory.c_impl(), this->scope, key.c_impl(), value.c_impl());
80
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 GATEXX_CHECK_EXCEPTION(res);
81 2 }
82 2 void AppConfig::writeNum(String const& key, int32_t value, String const& subcategory)
83 {
84
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
5 result_t res = gate_appconfig_write_num(this->app.c_impl(), this->source.c_impl(),
85 3 subcategory.empty() ? NULL : subcategory.c_impl(), this->scope, key.c_impl(), value);
86
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 GATEXX_CHECK_EXCEPTION(res);
87 2 }
88
89 4 void AppConfig::remove(String const& key, String const& subcategory)
90 {
91
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
10 result_t res = gate_appconfig_remove(this->app.c_impl(), this->source.c_impl(),
92 6 subcategory.empty() ? NULL : subcategory.c_impl(), this->scope, key.c_impl());
93
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 GATEXX_CHECK_EXCEPTION(res);
94 4 }
95
96
97 } // end of namespace sys
98 } // end of namespace gate
99