PhoenixInkscape
2.0.0
Generate multiple png files with svg inkscape files
main.cpp
Go to the documentation of this file.
1
2
/***************************************
3
Auteur : Pierre Aubert
4
Mail : pierre.aubert@lapp.in2p3.fr
5
Licence : CeCILL-C
6
****************************************/
7
8
#include <iostream>
9
#include "
phoenix_assert.h
"
10
#include "
phoenix_check.h
"
11
#include "
openFileStream.h
"
12
14
void
checkOpenFileStream
(){
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"
)));
31
phoenix_assert
(!
openFileStream
(fs,
PPath
(
""
)));
32
phoenix_assert
(!
openFileStream
(ifs,
PPath
(
""
)));
33
}
34
36
40
bool
checkOpenVecFileStream
(
const
PPath
& fileName,
size_t
nbFile){
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
}
58
59
60
int
main
(
int
argc,
char
** argv){
61
checkOpenFileStream
();
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
}
68
69
PPath
Path of a directory or a file.
Definition:
PPath.h:17
PString
Extends the std::string.
Definition:
PString.h:16
openFileStream
bool openFileStream(std::ofstream &fs, const PPath &fileName)
Open a ofstream and says if there is a problem.
Definition:
openFileStream.cpp:18
closeFileStream
void closeFileStream(PVecOFStream &fs)
Close a vector of ofstream.
Definition:
openFileStream.cpp:84
openFileStream.h
PVecIFStream
std::vector< std::ifstream > PVecIFStream
Definition:
openFileStream.h:16
PVecOFStream
std::vector< std::ofstream > PVecOFStream
Definition:
openFileStream.h:15
phoenix_assert.h
phoenix_assert
#define phoenix_assert(isOk)
Definition:
phoenix_assert.h:19
phoenix_check
bool phoenix_check(const std::string &testName, const std::string &val, const std::string &reference)
Check two string.
Definition:
phoenix_check.cpp:16
phoenix_check.h
main
int main(int argc, char **argv)
Definition:
main.cpp:290
checkOpenFileStream
void checkOpenFileStream()
Check the openFileStream.
Definition:
main.cpp:14
checkOpenVecFileStream
bool checkOpenVecFileStream(const PPath &fileName, size_t nbFile)
Check the openFileStream.
Definition:
main.cpp:40
tmp_project
PhoenixFileParser
TESTS
TEST_OPEN_FILE_STREAM
main.cpp
Generated on Fri Mar 14 2025 12:05:52 for PhoenixInkscape by
1.9.1