GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/StringUtils/src/PStream.cpp Lines: 19 19 100.0 %
Date: 2024-12-09 15:30:52 Branches: 2 2 100.0 %

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 "PStream.h"
9
10
///Default constructor of PStream
11
6
PStream::PStream(){
12
6
	initialisationPStream();
13
6
}
14
15
///Destructor of PStream
16
24
PStream::~PStream(){
17
12
	close();
18
}
19
20
///Open the current stream
21
/**	@param fileName : name of the file to be used
22
 * 	@param mode : open mode, r : read only, write : write only, etc
23
 * 	@return true on success, false otherwise
24
*/
25
6
bool PStream::open(const std::string & fileName, const std::string & mode){
26
6
	close();
27
6
	p_fp = fopen(fileName.c_str(), mode.c_str());
28
6
	return isOpen();
29
}
30
31
///Close the stream
32
15
void PStream::close(){
33
15
	if(isOpen()){
34
6
		fclose(p_fp);
35
6
		p_fp = NULL;
36
	}
37
15
}
38
39
///Say if the stream is opened
40
/**	@return true if it is opened, false otherwise
41
*/
42
21
bool PStream::isOpen() const{
43
21
	return p_fp != NULL;
44
}
45
46
///Initialisation function of the class PStream
47
6
void PStream::initialisationPStream(){
48
6
	p_fp = NULL;
49
6
}
50
51
52
53
54