1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
2 |
|
---|
3 | #ifndef RAWSTREAM_H_SEEN
|
---|
4 | #define RAWSTREAM_H_SEEN
|
---|
5 |
|
---|
6 | // Classe de flot brut - pour utilisation par les streams PPersist
|
---|
7 | // R. Ansari LAL IN2P3/CNRS 11/2003
|
---|
8 |
|
---|
9 | #include "machdefs.h"
|
---|
10 | #include <stdio.h>
|
---|
11 | #include <iostream>
|
---|
12 | #include <string>
|
---|
13 |
|
---|
14 |
|
---|
15 | namespace SOPHYA {
|
---|
16 | class RawInOutStream {
|
---|
17 | public:
|
---|
18 | RawInOutStream();
|
---|
19 | virtual ~RawInOutStream();
|
---|
20 |
|
---|
21 | virtual bool isSeekable() const ;
|
---|
22 | // Interface pour lecture
|
---|
23 | virtual int_8 tellg();
|
---|
24 | virtual RawInOutStream& seekg(int_8, int sd = ios::beg);
|
---|
25 | virtual RawInOutStream& read(char* s, uint_8 n);
|
---|
26 | // Interface pour ecriture
|
---|
27 | virtual int_8 tellp();
|
---|
28 | virtual RawInOutStream& seekp(int_8, int sd = ios::beg);
|
---|
29 | virtual RawInOutStream& write(const char* s, uint_8 n);
|
---|
30 | inline std::string getFileName() const { return _filename; }
|
---|
31 | protected:
|
---|
32 | std::string _filename;
|
---|
33 |
|
---|
34 | };
|
---|
35 |
|
---|
36 | // Input flow on a disk file
|
---|
37 | class RawInFileStream : public RawInOutStream {
|
---|
38 | public:
|
---|
39 | RawInFileStream(const char * path);
|
---|
40 | RawInFileStream(string const & path);
|
---|
41 | virtual ~RawInFileStream();
|
---|
42 |
|
---|
43 | virtual bool isSeekable() const ;
|
---|
44 | // Interface pour lecture
|
---|
45 | virtual int_8 tellg();
|
---|
46 | virtual RawInOutStream& seekg(int_8, int sd = ios::beg);
|
---|
47 | virtual RawInOutStream& read(char* s, uint_8 n);
|
---|
48 |
|
---|
49 | protected:
|
---|
50 | FILE * fip;
|
---|
51 | };
|
---|
52 |
|
---|
53 | // Output flow on a disk file
|
---|
54 | class RawOutFileStream : public RawInOutStream {
|
---|
55 | public:
|
---|
56 | RawOutFileStream(const char * path);
|
---|
57 | RawOutFileStream(string const & path);
|
---|
58 | virtual ~RawOutFileStream();
|
---|
59 |
|
---|
60 | virtual bool isSeekable() const ;
|
---|
61 | // Interface pour ecriture
|
---|
62 | virtual int_8 tellp();
|
---|
63 | virtual RawInOutStream& seekp(int_8 pos, int sd = ios::beg);
|
---|
64 | virtual RawInOutStream& write(const char* s, uint_8 n);
|
---|
65 |
|
---|
66 | protected:
|
---|
67 | FILE * fip;
|
---|
68 | };
|
---|
69 |
|
---|
70 |
|
---|
71 | } // namespace SOPHYA
|
---|
72 |
|
---|
73 | #endif
|
---|