PhoenixInkscape  2.0.0
Generate multiple png files with svg inkscape files
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. More...
 
void closeFileStream (PVecOFStream &fs)
 Close a vector of ofstream. More...
 
bool openFileStream (PVecIFStream &fs, const PPath &fileName, size_t nbFile)
 Open a vector of ifstream. More...
 
bool openFileStream (PVecOFStream &fs, const PPath &fileName, size_t nbFile)
 Open a vector of ofstream. More...
 
bool openFileStream (std::ifstream &fs, const PPath &fileName)
 Open a ofstream and says if there is a problem. More...
 
bool openFileStream (std::ofstream &fs, const PPath &fileName)
 Open a ofstream and says if there is a problem. More...
 

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 }

Referenced by checkOpenVecFileStream().

+ Here is the caller graph for this function:

◆ 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 }
Path of a directory or a file.
Definition: PPath.h:17
PPath & eraseExtension()
Erase the extension of the PPath.
Definition: PPath.cpp:292
PString getExtension() const
Get file extension.
Definition: PPath.cpp:252
std::string valueToString(const T &val)
Convert a type into a string.
bool openFileStream(std::ofstream &fs, const PPath &fileName)
Open a ofstream and says if there is a problem.

References PPath::eraseExtension(), PPath::getExtension(), openFileStream(), and valueToString().

+ 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 }
Extends the std::string.
Definition: PString.h:16

References PPath::eraseExtension(), PPath::getExtension(), openFileStream(), and valueToString().

+ 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 checkOpenFileStream(), checkOpenVecFileStream(), and openFileStream().

+ Here is the caller graph for this function: