PhoenixFileParser  1.0.0
Set of tools to ease file parsing
Loading...
Searching...
No Matches
openFileStream.cpp File Reference
#include <iostream>
#include "convertToString.h"
#include "openFileStream.h"
+ Include dependency graph for openFileStream.cpp:

Go to the source code of this file.

Functions

void closeFileStream (PVecIFStream &fs)
 Close a vector of ifstream.
 
void closeFileStream (PVecOFStream &fs)
 Close a vector of ofstream.
 
bool openFileStream (PVecIFStream &fs, const PPath &fileName, size_t nbFile)
 Open a vector of ifstream.
 
bool openFileStream (PVecOFStream &fs, const PPath &fileName, size_t nbFile)
 Open a vector of ofstream.
 
bool openFileStream (std::ifstream &fs, const PPath &fileName)
 Open a ofstream and says if there is a problem.
 
bool openFileStream (std::ofstream &fs, const PPath &fileName)
 Open a ofstream and says if there is a problem.
 

Function Documentation

◆ closeFileStream() [1/2]

void closeFileStream ( PVecIFStream & fs)

Close a vector of ifstream.

Parameters
[out]fs: vector of ifstream to be closed

Definition at line 93 of file openFileStream.cpp.

93 {
94 for(PVecIFStream::iterator it(fs.begin()); it != fs.end(); ++it){
95 it->close();
96 }
97}

◆ closeFileStream() [2/2]

void closeFileStream ( PVecOFStream & fs)

Close a vector of ofstream.

Parameters
[out]fs: vector of ofstream to be closed

Definition at line 84 of file openFileStream.cpp.

84 {
85 for(PVecOFStream::iterator it(fs.begin()); it != fs.end(); ++it){
86 it->close();
87 }
88}

◆ openFileStream() [1/4]

bool openFileStream ( PVecIFStream & fs,
const PPath & fileName,
size_t nbFile )

Open a vector of ifstream.

Parameters
[out]fs: vector of ifstream to be opened
fileName: basic name of the file to be used (the file name will have a file index)
nbFile: number of file to open
Returns
true on success, false otherwise

Definition at line 66 of file openFileStream.cpp.

66 {
67 if(nbFile == 0lu){return true;} //There is no problem in oppening 0 file
68 PPath baseFileName(fileName.eraseExtension()), extention(fileName.getExtension());
69 if(extention != ""){extention = PPath("." + extention);}
70 fs.resize(nbFile);
71 bool b(true);
72 size_t i(0lu);
73 for(PVecIFStream::iterator it(fs.begin()); it != fs.end(); ++it){
74 PPath tmpFileName(baseFileName + PPath("_") + valueToString(i) + extention);
75 b &= openFileStream(*it, tmpFileName);
76 ++i;
77 }
78 return b;
79}
bool openFileStream(std::ofstream &fs, const PPath &fileName)
Open a ofstream and says if there is a problem.

References openFileStream().

+ Here is the call graph for this function:

◆ openFileStream() [2/4]

bool openFileStream ( PVecOFStream & fs,
const PPath & fileName,
size_t nbFile )

Open a vector of ofstream.

Parameters
[out]fs: vector of ofstream to be opened
fileName: basic name of the file to be used (the file name will have a file index)
nbFile: number of file to open
Returns
true on success, false otherwise

Definition at line 45 of file openFileStream.cpp.

45 {
46 if(nbFile == 0lu){return true;} //There is no problem in oppening 0 file
47 PPath baseFileName(fileName.eraseExtension()), extention(fileName.getExtension());
48 if(extention != ""){extention = PString("." + extention);}
49 fs.resize(nbFile);
50 bool b(true);
51 size_t i(0lu);
52 for(PVecOFStream::iterator it(fs.begin()); it != fs.end(); ++it){
53 PPath tmpFileName(baseFileName + PPath("_") + valueToString(i) + extention);
54 b &= openFileStream(*it, tmpFileName);
55 ++i;
56 }
57 return b;
58}

References openFileStream().

+ Here is the call graph for this function:

◆ openFileStream() [3/4]

bool openFileStream ( std::ifstream & fs,
const PPath & fileName )

Open a ofstream and says if there is a problem.

Parameters
fs: ifstream to open
fileName: name of the file in witch to write
Returns
true on success, false otherwise

Definition at line 31 of file openFileStream.cpp.

31 {
32 fs.open(fileName.c_str());
33 if(!fs.is_open()){
34 std::cerr << "openFileStream : can't open file '" << fileName << "'" << std::endl;
35 return false;
36 }else return true;
37}

◆ openFileStream() [4/4]

bool openFileStream ( std::ofstream & fs,
const PPath & fileName )

Open a ofstream and says if there is a problem.

Parameters
fs: ofstream to open
fileName: name of the file in witch to write
Returns
true on success, false otherwise

Definition at line 18 of file openFileStream.cpp.

18 {
19 fs.open(fileName.c_str());
20 if(!fs.is_open()){
21 std::cerr << "openFileStream : can't open file '" << fileName << "'" << std::endl;
22 return false;
23 }else return true;
24}

Referenced by openFileStream(), and openFileStream().

+ Here is the caller graph for this function: