NeoPZ
TPZBFileStream.h
Go to the documentation of this file.
1 #ifndef TPZBFILESTREAM_H
2 #define TPZBFILESTREAM_H
3 #include <complex> // for complex
4 #include <fstream> // for string, ifstream, ofstream
5 #include "TPZGeneralFStream.h" // for TPZGeneralFStream
6 #include <stdint.h> // for uint64_t and int64_t
7 
8 #ifdef _AUTODIFF
9 template <class T> class Fad;
10 template <int Num, class T> class TFad;
11 #endif
12 
14  private:
15  std::ifstream fIn;
16  std::ofstream fOut;
17 
18  public:
21 
22  void OpenRead(const std::string &fileName);
23  void OpenWrite(const std::string &fileName);
24 
25  virtual bool AmIOpenForRead();
26 
27  virtual bool AmIOpenForWrite();
28 
29  void CloseRead();
30  void CloseWrite();
31 
32  using TPZStream::Read;
34  virtual void Read(int *p, int howMany) { ReadData<int>(p, howMany); }
36  virtual void Read(unsigned int *p, int howMany) { ReadData<unsigned int>(p, howMany); }
38  virtual void Read(uint64_t *p, int howMany) { ReadData<uint64_t>(p, howMany); }
40  virtual void Read(int64_t *p, int howMany) { ReadData<int64_t>(p, howMany); }
42  virtual void Read(float *p, int howMany) { ReadData<float>(p, howMany); }
44  virtual void Read(double *p, int howMany) { ReadData<double>(p, howMany); }
46  virtual void Read(unsigned char *p, int howMany) { ReadData<unsigned char>(p, howMany); }
48  virtual void Read(char *p, int howMany) { ReadData<char>(p, howMany); }
50  virtual void Read(std::complex<float> *p, int howMany) { ReadData<std::complex<float>>(p, howMany); }
52  virtual void Read(std::complex<double> *p, int howMany) { ReadData<std::complex<double>>(p, howMany); }
53 #ifdef _AUTODIFF
54  virtual void Read(TFad<1,REAL> *p, int howMany) { ReadData<TFad<1,REAL>>(p, howMany); }
55  virtual void Read(TFad<6,REAL> *p, int howMany) { ReadData<TFad<6,REAL>>(p, howMany); }
56  virtual void Read(TFad<8,REAL> *p, int howMany) { ReadData<TFad<8,REAL>>(p, howMany); }
57  virtual void Read(TFad<9,REAL> *p, int howMany) { ReadData<TFad<9,REAL>>(p, howMany); }
59  virtual void Read(TFad<10,REAL> *p, int howMany) { ReadData<TFad<10,REAL>>(p, howMany); }
61  virtual void Read(TFad<14,REAL> *p, int howMany) { ReadData<TFad<14,REAL>>(p, howMany); }
63  virtual void Read(Fad<float> *p, int howMany) { ReadData<Fad<float>>(p, howMany); }
65  virtual void Read(Fad<double> *p, int howMany) { ReadData<Fad<double>>(p, howMany); }
66 #endif
67 
68  using TPZStream::Write;
70  virtual void Write(const int *p, int howMany) { WriteData<int>(p,howMany); }
72  virtual void Write(const unsigned int *p, int howMany) { WriteData<const unsigned int>(p,howMany); }
74  virtual void Write(const uint64_t *p, int howMany) { WriteData<const uint64_t>(p,howMany); }
76  virtual void Write(const int64_t *p, int howMany) { WriteData<const int64_t>(p,howMany); }
78  virtual void Write(const float *p, int howMany) { WriteData<float>(p,howMany); }
80  virtual void Write(const double *p, int howMany) { WriteData<double>(p,howMany); }
82  virtual void Write(const unsigned char *p, int howMany) { WriteData<unsigned char>(p,howMany); }
84  virtual void Write(const char *p, int howMany) { WriteData<char>(p,howMany); }
86  virtual void Write(const std::complex <float> *p, int howMany) { WriteData< std::complex <float> >(p,howMany); }
88  virtual void Write(const std::complex <double> *p, int howMany) { WriteData< std::complex <double> >(p,howMany); }
89 
90 #ifdef _AUTODIFF
91 
92  virtual void Write(const TFad <1,REAL> *p, int howMany) { WriteData< TFad <1,REAL> >(p,howMany); }
94  virtual void Write(const TFad <6,REAL> *p, int howMany) { WriteData< TFad <6,REAL> >(p,howMany); }
96  virtual void Write(const TFad <8,REAL> *p, int howMany) { WriteData< TFad <8,REAL> >(p,howMany); }
98  virtual void Write(const TFad <9,REAL> *p, int howMany) { WriteData< TFad <9,REAL> >(p,howMany); }
100  virtual void Write(const TFad <10,REAL> *p, int howMany) { WriteData< TFad <10,REAL> >(p,howMany); }
102  virtual void Write(const TFad <14,REAL> *p, int howMany) { WriteData< TFad <14,REAL> >(p,howMany); }
104  virtual void Write(const Fad <float> *p, int howMany) { WriteData< Fad <float> >(p,howMany); }
106  virtual void Write(const Fad <double> *p, int howMany) { WriteData< Fad <double> >(p,howMany); }
107 #endif
108  private:
109  template <class T> void ReadData(T *p, int howMany);
110  template <class T> void WriteData(const T *p, int howMany);
111 };
112 #endif // TPZBFILESTREAM_H
virtual void Read(float *p, int howMany)
Reads howMany floating points from pointer location p.
void WriteData(const T *p, int howMany)
Reads howMany objects of the class T from pointer location p.
virtual void Write(const float *p, int howMany)
Writes howMany floating points at pointer location p.
virtual bool AmIOpenForRead()
virtual void Read(double *p, int howMany)
Reads howMany floating points from pointer location p.
std::ofstream fOut
virtual void Read(unsigned char *p, int howMany)
Reads howMany unsigned chars from pointer location p.
Definition: fad.h:54
virtual void Read(int *p, int howMany)
Reads howMany integers from pointer location p.
virtual void Write(const std::complex< float > *p, int howMany)
Writes howMany complex-float at pointer location p.
virtual void Read(uint64_t *p, int howMany)
Reads howMany uint64_t from pointer location p.
virtual void Write(const double *p, int howMany)
Writes howMany floating points at pointer location p.
virtual void Write(const unsigned int *p, int howMany)
Writes howMany integers at pointer location p.
virtual void Read(std::complex< double > *p, int howMany)
Reads howMany complex-double from pointer location p.
virtual void Write(const bool val)
Definition: TPZStream.cpp:8
virtual void Read(std::complex< float > *p, int howMany)
Reads howMany complex-float from pointer location p.
Definition: tfad.h:64
virtual void Write(const uint64_t *p, int howMany)
Writes howMany uint64_t at pointer location p.
virtual void Write(const int *p, int howMany)
Writes howMany integers at pointer location p.
void OpenRead(const std::string &fileName)
virtual void Read(unsigned int *p, int howMany)
Reads howMany integers from pointer location p.
virtual void Read(int64_t *p, int howMany)
Reads howMany int64_t from pointer location p.
std::ifstream fIn
virtual void Write(const std::complex< double > *p, int howMany)
Writes howMany complex-double at pointer location p.
virtual void Read(char *p, int howMany)
Reads howMany chars from pointer location p.
void OpenWrite(const std::string &fileName)
virtual bool AmIOpenForWrite()
virtual void Write(const int64_t *p, int howMany)
Writes howMany int64_t at pointer location p.
void ReadData(T *p, int howMany)
Reads howMany objects of the class T from pointer location p.
virtual void Write(const unsigned char *p, int howMany)
Writes howMany unsigned chars at pointer location p.
virtual void Write(const char *p, int howMany)
Writes howMany chars at pointer location p.
virtual void Read(bool &val)
Definition: TPZStream.cpp:91