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 "PStream.h"
11 
13 void testPStream(){
14  PStream strOut;
15  phoenix_assert(strOut.open(PPath("testInt.bin"), "w"));
16  strOut << 42;
17  strOut.close();
18 
19  PStream strIn;
20  phoenix_assert(strIn.open(PPath("testInt.bin"), "r"));
21  int val(0);
22  strIn >> val;
23 
24  std::cout << "testPStream : val = " << val << std::endl;
25  phoenix_assert(val == 42);
26 }
27 
30  int tabInt [] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
31  int tabIntRead [] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
32 
33  PStream strOut;
34  phoenix_assert(strOut.open(PPath("testTabInt.bin"), "w"));
35  strOut.write(tabInt, 10lu);
36  strOut.close();
37 
38  PStream strIn;
39  phoenix_assert(strIn.open(PPath("testTabInt.bin"), "r"));
40  strIn.read(tabIntRead, 10lu);
41 
42  std::cout << "testPStreamTable : tabIntRead[9] = " << tabIntRead[9] << std::endl;
43  for(size_t i(0); i < 10lu; ++i){
44  phoenix_assert(tabInt[i] == tabIntRead[i]);
45  }
46 }
47 
50  int tabInt [] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
51  int tabIntRead [] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
52 
53  PStream strOut;
54  phoenix_assert(strOut.open(PPath("testMatInt.bin"), "w"));
55  strOut.write(tabInt, 2lu, 5lu, 0lu);
56  strOut.close();
57 
58  PStream strIn;
59  phoenix_assert(strIn.open(PPath("testMatInt.bin"), "r"));
60  strIn.read(tabIntRead, 2lu, 5lu, 0lu);
61 
62  std::cout << "testPStreamMatrix : tabIntRead[9] = " << tabIntRead[9] << std::endl;
63  for(size_t i(0); i < 10lu; ++i){
64  phoenix_assert(tabInt[i] == tabIntRead[i]);
65  }
66 }
67 
68 int main(int argc, char** argv){
69  testPStream();
72  return 0;
73 }
74 
75 
Path of a directory or a file.
Definition: PPath.h:17
Deal with binary stream.
Definition: PStream.h:14
bool write(const T &value)
Write a value into the stream.
Definition: PStream_impl.h:37
bool open(const PPath &fileName, const PString &mode="r")
Open the current stream.
Definition: PStream.cpp:25
bool read(T &value)
Read a value from the stream.
Definition: PStream_impl.h:73
void close()
Close the stream.
Definition: PStream.cpp:32
#define phoenix_assert(isOk)
int main(int argc, char **argv)
Definition: main.cpp:290
void testPStream()
Test the PStream.
Definition: main.cpp:13
void testPStreamMatrix()
Test the PStream.
Definition: main.cpp:49
void testPStreamTable()
Test the PStream.
Definition: main.cpp:29