PhoenixDebug
2.0.0
Print/save tools to help debugging C++ programs
Toggle main menu visibility
Loading...
Searching...
No Matches
PDebugAssistant.cpp
Go to the documentation of this file.
1
/***************************************
2
Auteur : Pierre Aubert
3
Mail : pierre.aubert@lapp.in2p3.fr
4
Licence : LGPL-3.0-only
5
****************************************/
6
7
#include "
PDebugAssistant.h
"
8
9
#ifndef DISABLE_DEBUG_ASSISTANT
11
PDebugAssistant::PDebugAssistant
(){
12
13
}
14
16
PDebugAssistant::~PDebugAssistant
(){
17
clearTxt
();
18
}
19
21
void
PDebugAssistant::clearTxt
(){
22
if
(
p_mapFileStreamTxt
.size() == 0lu)
return
;
23
for
(PMapOfstream::iterator it(
p_mapFileStreamTxt
.begin()); it !=
p_mapFileStreamTxt
.end(); ++it){
24
it->second->close();
25
delete
it->second;
26
}
27
p_mapFileStreamTxt
.clear();
28
}
29
31
void
PDebugAssistant::clearBin
(){
32
if
(
p_mapBinStream
.size() == 0lu)
return
;
33
for
(PMapBinstream::iterator it(
p_mapBinStream
.begin()); it !=
p_mapBinStream
.end(); ++it){
34
it->second->close();
35
delete
it->second;
36
}
37
p_mapBinStream
.clear();
38
}
39
41
44
std::ofstream &
PDebugAssistant::getTxtFile
(
const
PPath & fileName){
45
if
(fileName ==
""
){
return
getTxtFile
(PPath(
"default.txt"
));}
46
47
PMapOfstream::iterator it(
p_mapFileStreamTxt
.find(fileName));
48
49
if
(it !=
p_mapFileStreamTxt
.end()){
50
return
*(it->second);
51
}
else
{
52
std::ofstream * ptFs =
new
std::ofstream;
53
ptFs->open(fileName);
54
p_mapFileStreamTxt
[fileName] = ptFs;
55
return
*ptFs;
56
}
57
}
58
60
63
PStream &
PDebugAssistant::getBinFile
(
const
PPath & fileName){
64
if
(fileName ==
""
){
return
getBinFile
(PPath(
"default.bin"
));}
65
66
PMapBinstream::iterator it(
p_mapBinStream
.find(fileName));
67
68
if
(it !=
p_mapBinStream
.end()){
69
return
*(it->second);
70
}
else
{
71
PStream * ptFs =
new
PStream;
72
ptFs->open(fileName,
"w"
);
73
p_mapBinStream
[fileName] = ptFs;
74
return
*ptFs;
75
}
76
}
77
78
#endif
79
PDebugAssistant.h
PDebugAssistant::p_mapBinStream
PMapBinstream p_mapBinStream
Map of binary stream.
Definition
PDebugAssistant.h:40
PDebugAssistant::getTxtFile
std::ofstream & getTxtFile(const PPath &fileName=PPath("default.txt"))
Returns a file stream for the given file name.
Definition
PDebugAssistant.cpp:44
PDebugAssistant::clearBin
void clearBin()
Clear the file stream Map by closing all the binary files.
Definition
PDebugAssistant.cpp:31
PDebugAssistant::PDebugAssistant
PDebugAssistant()
Constructor of PDebugAssistant.
Definition
PDebugAssistant.cpp:11
PDebugAssistant::getBinFile
PStream & getBinFile(const PPath &fileName=PPath("default.bin"))
Returns a file stream for the given file name.
Definition
PDebugAssistant.cpp:63
PDebugAssistant::clearTxt
void clearTxt()
Clear the file stream Map by closing all the files.
Definition
PDebugAssistant.cpp:21
PDebugAssistant::~PDebugAssistant
virtual ~PDebugAssistant()
Destructor of PDebugAssistant.
Definition
PDebugAssistant.cpp:16
PDebugAssistant::p_mapFileStreamTxt
PMapOfstream p_mapFileStreamTxt
Map of text file streams.
Definition
PDebugAssistant.h:38
src
PDebugAssistant.cpp
Generated by
1.17.0