PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
PStream.h
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 #ifndef __PSTREAM_H__
8 #define __PSTREAM_H__
9 
10 #include <stdio.h>
11 #include "PPath.h"
12 
14 class PStream{
15  public:
16  PStream();
17  virtual ~PStream();
18 
19  bool open(const PPath & fileName, const PString & mode = "r");
20  void close();
21  bool isOpen() const;
22 
23  template<typename T>
24  PStream & operator << (const T & value);
25 
26  template<typename T>
27  PStream & operator >> (T & value);
28 
29  template<typename T>
30  bool write(const T & value);
31 
32  template<typename T>
33  bool write(const T * tabValue, size_t nbValue);
34 
35  template<typename T>
36  bool write(const T * tabValue, size_t nbRow, size_t nbCol, size_t padding = 0lu);
37 
38  template<typename T>
39  bool read(T & value);
40 
41  template<typename T>
42  bool read(T * tabValue, size_t nbValue);
43 
44  template<typename T>
45  bool read(T * tabValue, size_t nbRow, size_t nbCol, size_t padding = 0lu);
46 
47  private:
48  void initialisationPStream();
49 
51  FILE* p_fp;
52 };
53 
54 #include "PStream_impl.h"
55 
56 #endif
57 
Path of a directory or a file.
Definition: PPath.h:17
Deal with binary stream.
Definition: PStream.h:14
void initialisationPStream()
Initialisation function of the class PStream.
Definition: PStream.cpp:47
PStream()
Default constructor of PStream.
Definition: PStream.cpp:11
bool write(const T &value)
Write a value into the stream.
Definition: PStream_impl.h:37
FILE * p_fp
Pointer to the main stream.
Definition: PStream.h:51
PStream & operator<<(const T &value)
Flux operator for stream.
Definition: PStream_impl.h:17
virtual ~PStream()
Destructor of PStream.
Definition: PStream.cpp:16
bool isOpen() const
Say if the stream is opened.
Definition: PStream.cpp:42
bool open(const PPath &fileName, const PString &mode="r")
Open the current stream.
Definition: PStream.cpp:25
PStream & operator>>(T &value)
Flux operator for stream.
Definition: PStream_impl.h:27
bool read(T &value)
Read a value from the stream.
Definition: PStream_impl.h:73
void close()
Close the stream.
Definition: PStream.cpp:32
Extends the std::string.
Definition: PString.h:16