Free Electron
Stream.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __data_Stream_h__
8 #define __data_Stream_h__
9 namespace fe
10 {
11 namespace data
12 {
13 
14 class FE_DL_EXPORT StreamI:
15  public Component,
16  public CastableAs<StreamI>
17 {
18  public:
19 virtual void bind(sp<Scope> spScope) = 0;
20 virtual void output(std::ostream &ostm, sp<RecordGroup> spRG) = 0;
21 virtual sp<RecordGroup> input(std::istream &istrm) = 0;
22 };
23 
24 class FE_DL_EXPORT FileStreamI:
25  public Component,
26  public CastableAs<FileStreamI>
27 {
28  public:
29 virtual void bind(sp<Scope> spScope) = 0;
30 virtual void output(const String &a_file, sp<RecordGroup> spRG) = 0;
31 virtual sp<RecordGroup> input(const String &a_file) = 0;
32 };
33 
34 class FE_DL_EXPORT AsciiFileStream:
35  virtual public FileStreamI,
36  public CastableAs<AsciiFileStream>
37 {
38  public:
39  AsciiFileStream(void);
40 virtual ~AsciiFileStream(void);
41 virtual void bind(sp<Scope> spScope);
42 virtual void output(const String &a_file, sp<RecordGroup> spRG);
43 virtual sp<RecordGroup> input(const String &a_file);
44 const String& name(void) const { return m_name; }
45  private:
46  sp<Scope> m_spScope;
47  sp<StreamI> m_spStream;
48  String m_name;
49 };
50 
51 class FE_DL_EXPORT BinaryFileStream:
52  virtual public FileStreamI,
53  public CastableAs<BinaryFileStream>
54 {
55  public:
56  BinaryFileStream(void);
57 virtual ~BinaryFileStream(void);
58 virtual void bind(sp<Scope> spScope);
59 virtual void output(const String &a_file, sp<RecordGroup> spRG);
60 virtual sp<RecordGroup> input(const String &a_file);
61 const String& name(void) const { return m_name; }
62  private:
63  sp<Scope> m_spScope;
64  sp<StreamI> m_spStream;
65  String m_name;
66 };
67 
68 #define FE_SERIAL_VERSION 5
69 
70 enum
71 {
72  e_end = 0,
73  e_reset = 1,
74  e_info = 2,
75  e_attribute = 3,
76  e_layout = 4,
77  e_group = 5,
78  e_state = 6
79 };
80 
81 /** Ascii IO
82  */
83 class FE_DL_EXPORT AsciiStream:
84  virtual public StreamI,
85  public CastableAs<AsciiStream>
86 {
87  public:
88  AsciiStream(void);
89  AsciiStream(sp<Scope> spScope);
90 virtual ~AsciiStream(void);
91 virtual void bind(sp<Scope> spScope);
92 virtual void output(std::ostream &ostrm, sp<RecordGroup> spRG);
93 virtual sp<RecordGroup> input(std::istream &istrm);
94 const String& name(void) const { return m_name; }
95  private:
96  sp<Scope> m_spScope;
97  sp<Writer> m_spWriter;
98  sp<Reader> m_spReader;
99  String m_name;
100 };
101 
102 /** Binary IO
103  */
104 class FE_DL_EXPORT BinaryStream:
105  virtual public StreamI,
106  public CastableAs<BinaryStream>
107 {
108  public:
109  BinaryStream(void);
110  BinaryStream(sp<Scope> spScope);
111 virtual ~BinaryStream(void);
112 virtual void bind(sp<Scope> spScope);
113 virtual void output(std::ostream &ostrm, sp<RecordGroup> spRG);
114 virtual sp<RecordGroup> input(std::istream &istrm);
115 const String& name(void) const { return m_name; }
116  private:
117  sp<Scope> m_spScope;
118  sp<Writer> m_spWriter;
119  sp<Reader> m_spReader;
120  String m_name;
121 };
122 
123 
124 } /* namespace */
125 } /* namespace */
126 
127 #endif /* __data_Stream_h__ */
128 
Ascii IO.
Definition: Stream.h:83
Binary IO.
Definition: Stream.h:104
kernel
Definition: namespace.dox:3
Automatically reference-counted string container.
Definition: String.h:128
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192