GCC Code Coverage Report


Directory: src/gate/
File: src/gate/cxx_guids.cpp
Date: 2026-06-21 00:38:37
Exec Total Coverage
Lines: 53 58 91.4%
Functions: 14 15 93.3%
Branches: 7 28 25.0%

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 #include "gate/guids.hpp"
29 #include "gate/exceptions.hpp"
30 #include "gate/streams.hpp"
31
32 namespace gate
33 {
34
35
36 9 Guid::Guid()
37 9 : gate_guid_t(gate_guid_t())
38 {
39 9 }
40 1 Guid::Guid(uint32_t timeLow, uint16_t timeMid, uint16_t timeHiVersion, uint8_t clockSeqHiRes, uint8_t clockSeqLow,
41 1 uint8_t node1, uint8_t node2, uint8_t node3, uint8_t node4, uint8_t node5, uint8_t node6)
42 {
43 1 this->item1 = timeLow;
44 1 this->item2 = timeMid;
45 1 this->item3 = timeHiVersion;
46 1 this->item4[0]= clockSeqHiRes;
47 1 this->item4[1] = clockSeqLow;
48 1 this->item4[2] = node1;
49 1 this->item4[3] = node2;
50 1 this->item4[4] = node3;
51 1 this->item4[5] = node4;
52 1 this->item4[6] = node5;
53 1 this->item4[7] = node6;
54 1 }
55
56 1 Guid::Guid(gate_guid_t const& guid)
57 1 : gate_guid_t(guid)
58 {
59 1 }
60 2 Guid::Guid(Guid const& guid)
61 2 : gate_guid_t(guid)
62 {
63 2 }
64 1 Guid& Guid::operator=(Guid const& guid)
65 {
66 1 gate_guid_t& self = *this;
67 1 self = guid;
68 1 return *this;
69 }
70 13 Guid::~Guid()
71 {
72 13 }
73
74 1 bool Guid::operator==(Guid const& that) const
75 {
76 1 return gate_guid_equals(this, &that);
77 }
78 6 bool Guid::operator!=(Guid const& that) const
79 {
80 6 return !gate_guid_equals(this, &that);
81 }
82
83 2 bool Guid::operator==(gate_guid_t const& that) const
84 {
85 2 return gate_guid_equals(this, &that);
86 }
87 1 bool Guid::operator!=(gate_guid_t const& that) const
88 {
89 1 return !gate_guid_equals(this, &that);
90 }
91
92 5 Guid Guid::generate()
93 {
94 5 Guid tmp;
95
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 result_t res = gate_guid_generate(&tmp);
96
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
5 GATEXX_CHECK_ERROR(res);
97 5 return tmp;
98 }
99 1 Guid Guid::parse(String const& text)
100 {
101 1 Guid tmp;
102
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 result_t res = gate_guid_parse_string(text.c_str(), text.size(), &tmp);
103
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_EXCEPTION(res);
104 1 return tmp;
105 }
106
107 2 String Guid::toString() const
108 {
109 char buffer[64];
110
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 result_t res = gate_guid_to_string(this, buffer);
111
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 GATEXX_CHECK_ERROR(res);
112
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
4 return String(&buffer[0]);
113 }
114
115 2 gate_guid_t const* Guid::c_impl() const
116 {
117 2 return static_cast<gate_guid_t const*>(this);
118 }
119
120
121 Stream& operator<<(Stream& strm, Guid const& guid)
122 {
123 char buffer[64];
124 result_t res = gate_guid_to_string(&guid, buffer);
125 GATEXX_CHECK_ERROR(res);
126 strm << buffer;
127 return strm;
128 }
129
130
131
132 } // end of namespace gate
133