GCC Code Coverage Report


Directory: ./
File: src/PString.cpp
Date: 2024-11-14 16:05:39
Exec Total Coverage
Lines: 48 52 92.3%
Branches: 9 11 81.8%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7
8 #include "PString.h"
9
10 ///Default constructeur of PString
11 12 PString::PString()
12
1/1
✓ Branch 2 taken 12 times.
12 :std::string("")
13 {
14
1/1
✓ Branch 1 taken 12 times.
12 initialisationPString();
15 12 }
16
17 ///Default constructeur of PString
18 /** @param str : string to initialise the PString
19 */
20 7 PString::PString(const std::string & str)
21 7 :std::string(str)
22 {
23
1/1
✓ Branch 1 taken 7 times.
7 initialisationPString();
24 7 }
25
26 ///Copy constructor of PString
27 /** @param other : class to copy
28 */
29 5 PString::PString(const PString & other)
30 5 :std::string()
31 {
32
1/1
✓ Branch 1 taken 5 times.
5 copyPString(other);
33 5 }
34
35 ///Destructeur of PString
36 48 PString::~PString(){
37
38 }
39
40 ///Definition of equal operator of PString
41 /** @param other : class to copy
42 * @return copied class
43 */
44 6 PString & PString::operator = (const PString & other){
45 6 copyPString(other);
46 6 return *this;
47 }
48
49 ///Add a PString to an other
50 /** @param other : PString to be added to the current one
51 * @return PString
52 */
53 2 PString & PString::operator += (const PString & other){
54 2 concatenatePString(other);
55 2 return *this;
56 }
57
58 ///Add a std::string to an other
59 /** @param other : std::string to be added to the current one
60 * @return PString
61 */
62 1 PString & PString::operator += (const std::string & other){
63 1 concatenatePString(other);
64 1 return *this;
65 }
66
67 ///Concatenate 2 PString together
68 /** @param other1 : left PString
69 * @param other2 : right PString
70 * @return concatenated PString
71 */
72 2 PString operator + (const PString & other1, const PString & other2){
73 2 PString res(other1);
74
1/1
✓ Branch 1 taken 2 times.
2 res += other2;
75 2 return res;
76 }
77
78 ///Concatenate 2 PString together
79 /** @param other1 : left PString
80 * @param other2 : right PString
81 * @return concatenated PString
82 */
83 PString operator << (const PString & other1, const PString & other2){
84 PString res(other1);
85 res += other2;
86 return res;
87 }
88
89 ///Copy function of PString
90 /** @param other : class to copy
91 */
92 11 void PString::copyPString(const PString & other){
93 11 resize(other.size());
94 11 memcpy((char*)data(), other.data(), other.size());
95 11 }
96
97 ///Copy function of PString
98 /** @param other : class to copy
99 */
100 2 void PString::copyPString(const std::string & other){
101 2 resize(other.size());
102 2 memcpy((char*)data(), other.data(), other.size());
103 2 }
104
105 ///Concatenate a PString into the current PString
106 /** @param other : PString to be added
107 */
108 2 void PString::concatenatePString(const PString & other){
109
1/1
✓ Branch 1 taken 2 times.
2 std::string tmp(*this);
110
1/1
✓ Branch 3 taken 2 times.
2 resize(tmp.size() + other.size());
111 2 memcpy((char*)data(), tmp.data(), tmp.size());
112 2 memcpy((char*)data() + tmp.size(), other.data(), other.size());
113 2 }
114
115 ///Concatenate a std::string into the current PString
116 /** @param other : std::string to be added
117 */
118 16 void PString::concatenatePString(const std::string & other){
119
1/1
✓ Branch 1 taken 16 times.
16 std::string tmp(*this);
120
1/1
✓ Branch 3 taken 16 times.
16 resize(tmp.size() + other.size());
121 16 memcpy((char*)data(), tmp.data(), tmp.size());
122 16 memcpy((char*)data() + tmp.size(), other.data(), other.size());
123 16 }
124
125 ///Initialisation function of the class PString
126 19 void PString::initialisationPString(){
127
128 19 }
129
130
131
132
133
134