PhoenixDebug  1.0.0
Tool to ease debugging
Loading...
Searching...
No Matches
PDebugAssistant Class Reference

Class able to treat Map of ofstream. More...

#include <PDebugAssistant.h>

Public Member Functions

void clearBin ()
 Clear the file stream Map by closing all the binary files.
 
void clearTxt ()
 Clear the file stream Map by closing all the files.
 
PStream & getBinFile (const PPath &fileName=PPath("default.bin"))
 Returns a file stream for the given file name.
 
std::ofstream & getTxtFile (const PPath &fileName=PPath("default.txt"))
 Returns a file stream for the given file name.
 
 PDebugAssistant ()
 Constructor of PDebugAssistant.
 
virtual ~PDebugAssistant ()
 Destructor of PDebugAssistant.
 

Private Attributes

PMapBinstream p_mapBinStream
 Map of binary stream.
 
PMapOfstream p_mapFileStreamTxt
 Map of text file streams.
 

Detailed Description

Class able to treat Map of ofstream.

Definition at line 24 of file PDebugAssistant.h.

Constructor & Destructor Documentation

◆ PDebugAssistant()

PDebugAssistant::PDebugAssistant ( )

Constructor of PDebugAssistant.

Definition at line 11 of file PDebugAssistant.cpp.

11 {
12
13}

◆ ~PDebugAssistant()

PDebugAssistant::~PDebugAssistant ( )
virtual

Destructor of PDebugAssistant.

Definition at line 16 of file PDebugAssistant.cpp.

16 {
17 clearTxt();
18}
void clearTxt()
Clear the file stream Map by closing all the files.

References clearTxt().

+ Here is the call graph for this function:

Member Function Documentation

◆ clearBin()

void PDebugAssistant::clearBin ( )

Clear the file stream Map by closing all the binary files.

Definition at line 31 of file PDebugAssistant.cpp.

31 {
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}
PMapBinstream p_mapBinStream
Map of binary stream.

References p_mapBinStream.

◆ clearTxt()

void PDebugAssistant::clearTxt ( )

Clear the file stream Map by closing all the files.

Definition at line 21 of file PDebugAssistant.cpp.

21 {
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}
PMapOfstream p_mapFileStreamTxt
Map of text file streams.

References p_mapFileStreamTxt.

Referenced by ~PDebugAssistant().

+ Here is the caller graph for this function:

◆ getBinFile()

PStream & PDebugAssistant::getBinFile ( const PPath & fileName = PPath("default.bin"))

Returns a file stream for the given file name.

Parameters
fileName: file name we want to write in
Returns
corresponding file stream

Definition at line 63 of file PDebugAssistant.cpp.

63 {
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}
PStream & getBinFile(const PPath &fileName=PPath("default.bin"))
Returns a file stream for the given file name.

References getBinFile(), and p_mapBinStream.

Referenced by getBinFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTxtFile()

std::ofstream & PDebugAssistant::getTxtFile ( const PPath & fileName = PPath("default.txt"))

Returns a file stream for the given file name.

Parameters
fileName: file name we want to write in
Returns
corresponding file stream

Definition at line 44 of file PDebugAssistant.cpp.

44 {
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}
std::ofstream & getTxtFile(const PPath &fileName=PPath("default.txt"))
Returns a file stream for the given file name.

References getTxtFile(), and p_mapFileStreamTxt.

Referenced by getTxtFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ p_mapBinStream

PMapBinstream PDebugAssistant::p_mapBinStream
private

Map of binary stream.

Definition at line 40 of file PDebugAssistant.h.

Referenced by clearBin(), and getBinFile().

◆ p_mapFileStreamTxt

PMapOfstream PDebugAssistant::p_mapFileStreamTxt
private

Map of text file streams.

Definition at line 38 of file PDebugAssistant.h.

Referenced by clearTxt(), and getTxtFile().


The documentation for this class was generated from the following files: