PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
main.cpp File Reference
#include <iostream>
#include "phoenix_assert.h"
#include "phoenix_check.h"
#include "openFileStream.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

void checkOpenFileStream ()
 Check the openFileStream. More...
 
bool checkOpenVecFileStream (const PPath &fileName, size_t nbFile)
 Check the openFileStream. More...
 
int main (int argc, char **argv)
 

Function Documentation

◆ checkOpenFileStream()

void checkOpenFileStream ( )

Check the openFileStream.

Definition at line 14 of file main.cpp.

14  {
15  std::ofstream fs;
16  phoenix_assert(openFileStream(fs, PPath("fileNameOut.txt")));
17  fs << "some content" << std::endl;
18  fs.close();
19 
20  std::ifstream ifs;
21  phoenix_assert(openFileStream(ifs, PPath("fileNameOut.txt")));
22  PString fileContent("");
23  ifs >> fileContent;
24  ifs.close();
25 
26  phoenix_assert(fileContent == "some"); //The input stream cut on blank characters
27 // std::cout << "checkOpenFileStream : fileContent = '" << fileContent << "'" << std::endl;
28 
29  phoenix_assert(!openFileStream(fs, PPath("outputDirWhichNotExist/test.txt")));
30  phoenix_assert(!openFileStream(ifs, PPath("unexistingFileNameOut.txt")));
33 }
Path of a directory or a file.
Definition: PPath.h:17
Extends the std::string.
Definition: PString.h:16
bool openFileStream(std::ofstream &fs, const PPath &fileName)
Open a ofstream and says if there is a problem.
#define phoenix_assert(isOk)

References openFileStream(), and phoenix_assert.

Referenced by main().

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

◆ checkOpenVecFileStream()

bool checkOpenVecFileStream ( const PPath fileName,
size_t  nbFile 
)

Check the openFileStream.

Parameters
fileName: name of the file to be used as a model
nbFile: number of files to be opened
Returns
true on success, false otherwise

Definition at line 40 of file main.cpp.

40  {
41  bool b(true);
42  PVecOFStream vecOut;
43  b &= openFileStream(vecOut, fileName, nbFile);
44  for(size_t i(0lu); i < nbFile; ++i){
45  vecOut[i] << i << std::endl;
46  }
47  closeFileStream(vecOut);
48  PVecIFStream vecIn;
49  b &= openFileStream(vecIn, fileName, nbFile);
50  for(size_t i(0lu); i < nbFile; ++i){
51  size_t val(0lu);
52  vecIn[i] >> val;
53  b &= phoenix_check("checkOpenVecFileStream : read element", val, i);
54  }
55  closeFileStream(vecIn);
56  return b;
57 }
void closeFileStream(PVecOFStream &fs)
Close a vector of ofstream.
std::vector< std::ifstream > PVecIFStream
std::vector< std::ofstream > PVecOFStream
bool phoenix_check(const std::string &testName, const std::string &val, const std::string &reference)
Check two string.

References closeFileStream(), openFileStream(), and phoenix_check().

Referenced by main().

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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 60 of file main.cpp.

60  {
62  for(size_t i(0lu); i < 10lu; ++i){
63  phoenix_assert(checkOpenVecFileStream(PPath("some_file_name.txt"), i));
64  phoenix_assert(checkOpenVecFileStream(PPath("some_file_without_extention"), i));
65  }
66  return 0;
67 }
void checkOpenFileStream()
Check the openFileStream.
Definition: main.cpp:14
bool checkOpenVecFileStream(const PPath &fileName, size_t nbFile)
Check the openFileStream.
Definition: main.cpp:40

References checkOpenFileStream(), checkOpenVecFileStream(), and phoenix_assert.

+ Here is the call graph for this function: