Directory: | ./ |
---|---|
File: | tmp_project/PhoenixFileParser/src/PLocation.cpp |
Date: | 2025-03-14 11:45:13 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 40 | 40 | 100.0% |
Branches: | 6 | 10 | 60.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /*************************************** | ||
2 | Auteur : Pierre Aubert | ||
3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
4 | Licence : CeCILL-C | ||
5 | ****************************************/ | ||
6 | |||
7 | #include "PLocation.h" | ||
8 | |||
9 | |||
10 | //////////////////////////////////////////////////// | ||
11 | // // | ||
12 | // Fonctions publiques de la classe PLocation // | ||
13 | // // | ||
14 | //////////////////////////////////////////////////// | ||
15 | |||
16 | |||
17 | ///Constructeur par défaut de PLocation | ||
18 | /** @param fileName : fichier vers lequel le PLocation pointe | ||
19 | * @param line : ligne du fichier vers lequel le PLocation pointe | ||
20 | * @param column : colonne du fichier vers lequel le PLocation pointe | ||
21 | */ | ||
22 | 13 | PLocation::PLocation(const PPath & fileName, size_t line, size_t column){ | |
23 |
1/1✓ Branch 1 taken 13 times.
|
13 | initialisationPLocation(fileName, line, column); |
24 | 13 | } | |
25 | |||
26 | ///Constructeur de copier de PLocation | ||
27 | /** @param other : PLocation à copier | ||
28 | */ | ||
29 | 1 | PLocation::PLocation(const PLocation & other){ | |
30 |
1/1✓ Branch 1 taken 1 times.
|
1 | copyPLocation(other); |
31 | 1 | } | |
32 | |||
33 | ///Destructeur de PLocation | ||
34 | 28 | PLocation::~PLocation(){ | |
35 | |||
36 | } | ||
37 | |||
38 | ///fonction qui permet d'initialiser la ligne du PLocation | ||
39 | /** @param fileName : fichier du PLocation | ||
40 | */ | ||
41 | 1 | void PLocation::setFileName(const PPath & fileName){ | |
42 | 1 | p_fileName = fileName; | |
43 | 1 | } | |
44 | |||
45 | ///fonction qui permet d'initialiser la ligne du PLocation | ||
46 | /** @param line : ligne du PLocation | ||
47 | */ | ||
48 | 1 | void PLocation::setLine(size_t line){ | |
49 | 1 | p_line = line; | |
50 | 1 | } | |
51 | |||
52 | ///fonction qui permet d'initialiser la colonne du PLocation | ||
53 | /** @param column : colonne du PLocation | ||
54 | */ | ||
55 | 1 | void PLocation::setColumn(size_t column){p_column = column;} | |
56 | |||
57 | ///renvoie le fichier du PLocation | ||
58 | /** @return fichier du PLocation | ||
59 | */ | ||
60 | 3 | PPath PLocation::getFileName() const{ | |
61 | 3 | return p_fileName; | |
62 | } | ||
63 | |||
64 | ///renvoie la ligne du PLocation | ||
65 | /** @return ligne du PLocation | ||
66 | */ | ||
67 | 3 | size_t PLocation::getLine() const{ | |
68 | 3 | return p_line; | |
69 | } | ||
70 | |||
71 | ///renvoie la colonne du PLocation | ||
72 | /** @return colonne du PLocation | ||
73 | */ | ||
74 | 3 | size_t PLocation::getColumn() const{ | |
75 | 3 | return p_column; | |
76 | } | ||
77 | |||
78 | //////////////////////////////////////////////// | ||
79 | // // | ||
80 | // Les opérateurs de la classe PLocation // | ||
81 | // // | ||
82 | //////////////////////////////////////////////// | ||
83 | |||
84 | |||
85 | ///Définition de l'opérateur = de PLocation | ||
86 | /** @param other : PLocation à copier | ||
87 | * @return PLocation copiée | ||
88 | */ | ||
89 | 1 | PLocation & PLocation::operator = (const PLocation & other){ | |
90 | 1 | copyPLocation(other); | |
91 | 1 | return *this; | |
92 | } | ||
93 | |||
94 | ///////////////////////////////////////////////////// | ||
95 | // // | ||
96 | // Les opérateurs amis de la classe PLocation // | ||
97 | // // | ||
98 | ///////////////////////////////////////////////////// | ||
99 | |||
100 | |||
101 | ///Définition de l'opérateur ami == de la classe PLocation | ||
102 | /** @param other1 : PLocation | ||
103 | * @param other2 : PLocation | ||
104 | * @return true si other1 et other2 sont égaux, false sinonPLocation | ||
105 | */ | ||
106 | 3 | bool operator == (const PLocation & other1, const PLocation & other2){ | |
107 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
3 | return (other1.p_fileName == other2.p_fileName && other1.p_line == other2.p_line); |
108 | } | ||
109 | |||
110 | ///Définition de l'opérateur ami != de la classe PLocation | ||
111 | /** @param other1 : PLocation | ||
112 | * @param other2 : PLocation | ||
113 | * @return false si other1 et other2 sont égaux, true sinon | ||
114 | */ | ||
115 | 3 | bool operator != (const PLocation & other1, const PLocation & other2){ | |
116 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
|
3 | return (other1.p_fileName != other2.p_fileName || other1.p_line != other2.p_line); |
117 | } | ||
118 | |||
119 | ///Définition de l'opérateur ami << de la classe PLocation | ||
120 | /** @param out : sortie standart de la console (cout) | ||
121 | * @param other : PLocation à affiche dans la console | ||
122 | * @return sortie standart de la console (cout) | ||
123 | */ | ||
124 | 9 | std::ostream & operator << (std::ostream & out, const PLocation & other){ | |
125 | 9 | out << "'" << other.p_fileName << "':" << other.p_line << ":" << other.p_column; | |
126 | 9 | return out; | |
127 | } | ||
128 | |||
129 | ////////////////////////////////////////////////// | ||
130 | // // | ||
131 | // Fonctions private de la classe PLocation // | ||
132 | // // | ||
133 | ////////////////////////////////////////////////// | ||
134 | |||
135 | |||
136 | ///Fonction d'initialisation de la classe PLocation | ||
137 | /** @param fileName : fichier vers lequel le PLocation pointe | ||
138 | * @param line : ligne du fichier vers lequel le PLocation pointe | ||
139 | * @param column : colonne du fichier vers lequel le PLocation pointe | ||
140 | */ | ||
141 | 13 | void PLocation::initialisationPLocation(const PPath & fileName, size_t line, size_t column){ | |
142 | 13 | p_fileName = fileName; | |
143 | 13 | p_line = line; | |
144 | 13 | p_column = column; | |
145 | 13 | } | |
146 | |||
147 | ///Fonction de copie de la classe PLocation | ||
148 | /** @param other : PLocation à copier | ||
149 | */ | ||
150 | 2 | void PLocation::copyPLocation(const PLocation & other){ | |
151 | 2 | p_fileName = other.p_fileName; | |
152 | 2 | p_line = other.p_line; | |
153 | 2 | p_column = other.p_column; | |
154 | 2 | } | |
155 | |||
156 |