OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimIoStream.h
Go to the documentation of this file.
1 //---
2 //
3 // License: MIT
4 //
5 // Author: Garrett Potts
6 //
7 // Description:
8 //
9 // Class declarations for:
10 //
11 // ossimIStream
12 // ossimOStream
13 // ossimIOStream
14 // ossimIOMemoryStream
15 // ossimIMemoryStream
16 // ossimOMemoryStream
17 // ossimIOFStream
18 // ossimIFStream
19 // ossimOFStream
20 //
21 //---
22 // $Id$
23 
24 #ifndef ossimIoStream_HEADER
25 #define ossimIoStream_HEADER 1
26 
27 #include <ossim/base/ossimIosFwd.h>
28 
29 // NOTE: All below includes will go away once deprecated code is replaced.
30 // drb 04 Nov. 2016
31 
32 
35 #include <ossim/base/ossimString.h>
36 
37 #include <istream>
38 #include <iostream>
39 #include <ostream>
40 #include <fstream>
41 #include <sstream>
42 
43 // needed by std::shared_ptr
44 #include <memory>
45 //---
46 // Depreciated:
47 //---
48 class OSSIM_DLL ossimIStream : public ossimStreamBase, public std::basic_istream<char>
49 {
50 public:
51  //ossimIStream();
52  ossimIStream(std::streambuf* sb);
53  virtual ~ossimIStream();
54 };
55 
56 
57 class OSSIM_DLL ossimOStream : public ossimStreamBase, public std::basic_ostream<char>
58 {
59 public:
60  //ossimOStream();
61  ossimOStream(std::streambuf* sb);
62  virtual ~ossimOStream();
63 };
64 
65 class OSSIM_DLL ossimIOStream : public ossimStreamBase, public std::basic_iostream<char>
66 {
67 public:
68  //ossimIOStream();
69  ossimIOStream(std::streambuf* sb);
70  virtual ~ossimIOStream();
71 };
72 
74 {
75 public:
77 
78  virtual ~ossimIOMemoryStream();
79 
80  // ??? (drb)
81  bool is_open()const;
82 
83  // ??? (drb)
84  virtual void open(const char* /* protocolString */,
85  int /* openMode */);
86 
87  ossimString str();
88 
89  // ??? (drb)
90  virtual void close();
91 
92  // ??? (drb) std::streamsize
93  ossim_uint64 size()const;
94 
95 protected:
97 };
98 
100 {
101 public:
102 
103  ossimIMemoryStream(const ossimString& inputBuf);
104 
105  virtual ~ossimIMemoryStream();
106 
107  bool is_open()const;
108 
109  ossim_uint64 size()const;
110 
111  virtual void open(const char* /* protocolString */,
112  int /* openMode */ );
113 
114  virtual void close();
115 
116  ossimString str();
117 
118 protected:
120 
121 };
122 
124 {
125 public:
127  virtual ~ossimOMemoryStream();
128 
129  bool is_open()const;
130 
131  ossim_uint64 size()const;
132 
133  virtual void open(const char* /* protocolString */,
134  int /* openMode */ );
135 
136  virtual void close();
137 
138  ossimString str();
139 
140 protected:
142 };
143 
144 class OSSIM_DLL ossimIOFStream : public ossimStreamBase, public std::basic_fstream<char>
145 {
146 public:
147  ossimIOFStream();
148 
149  ossimIOFStream(const char* name,
150  std::ios_base::openmode mode =
151  std::ios_base::in | std::ios_base::out);
152 
153  virtual ~ossimIOFStream();
154 };
155 
156 class OSSIM_DLL ossimIFStream : public ossimStreamBase, public std::basic_ifstream<char>
157 {
158 public:
159  ossimIFStream();
160 
161  ossimIFStream(const char* file,
162  std::ios_base::openmode mode = std::ios_base::in);
163 
164  virtual ~ossimIFStream();
165 
166 };
167 
168 class OSSIM_DLL ossimOFStream : public ossimStreamBase, public std::basic_ofstream<char>
169 {
170 public:
171  ossimOFStream();
172 
173  ossimOFStream(const char* name,
174  std::ios_base::openmode mode =
175  std::ios_base::out|std::ios_base::trunc);
176 
177  virtual ~ossimOFStream();
178 
179 };
180 
185 {
186 public:
191  ossimBufferedInputStream(std::shared_ptr<ossim::istream> in, ossim_uint32 bufferSize=1024 )
192  :ossim::istream(in->rdbuf()),
193  m_inputStream(in)
194  {
195  if(bufferSize > 0)
196  {
197  m_buffer.resize(bufferSize);
198  rdbuf()->pubsetbuf(&m_buffer.front(), m_buffer.size());
199  }
200  }
202  {
203  m_inputStream = 0;
204  }
205 protected:
210  std::vector<char> m_buffer;
211 
215  std::shared_ptr<ossim::istream> m_inputStream;
216 };
217 
218 
219 #ifdef _MSC_VER
220 
221 class ossimIFStream64 : public std::basic_ifstream<char>
222 {
223 public:
224  ossimIFStream64(const char* pFilename,
225  std::ios_base::openmode mode = ios_base::in,
226  int prot = ios_base::_Openprot);
227 
228  virtual ~ossimIFStream64();
229  void seekg64(off_type off, ios_base::seekdir way);
230 
231  void seekg64(streampos pos, ios_base::seekdir way);
232 
233  static void seekg64(std::istream& str, off_type off, ios_base::seekdir way);
234 
235  static void seekg64(std::istream& str, std::streampos pos, ios_base::seekdir way);
236 private:
237  FILE* theFile;
238 };
239 
240 class ossimOFStream64 : public std::basic_ofstream<char>
241 {
242 public:
243  ossimOFStream64(const char* pFilename,
244  std::ios_base::openmode mode = ios_base::out,
245  int prot = ios_base::_Openprot);
246  virtual ~ossimOFStream64();
247 
249 };
250 
251 #else
252 
253 class ossimIFStream64 : public std::basic_ifstream<char>
254 {
255 public:
256  ossimIFStream64(const char* pFilename, std::ios_base::openmode mode = ios_base::in, long prot = 0666);
257 
258  virtual ~ossimIFStream64();
259 
260  void seekg64(off_type off, ios_base::seekdir way);
261 
262  static void seekg64(std::istream& str, off_type off, ios_base::seekdir way);
263 };
264 
265 class ossimOFStream64 : public std::basic_ofstream<char>
266 {
267 public:
268  ossimOFStream64(const char* pFilename, std::ios_base::openmode mode = ios_base::out, long prot = 0666);
269 
270  virtual ~ossimOFStream64();
271 
273 };
274 
275 #endif // _MSC_VER
276 
285 
286 
287 #endif
ossimIFStream64(const char *pFilename, std::ios_base::openmode mode=ios_base::in, long prot=0666)
virtual ~ossimOFStream64()
This code was derived from https://gist.github.com/mshockwave.
Definition: Barrier.h:8
OSSIM_DLL void operator<<(ossimOStream &out, ossimIStream &in)
virtual ~ossimIFStream64()
ossimBufferedInputStream(std::shared_ptr< ossim::istream > in, ossim_uint32 bufferSize=1024)
will use the read buffer of the passed in input stream and will set the buffer based on the buffer si...
std::stringbuf theBuf
Definition: ossimIoStream.h:96
yy_size_t size
std::stringbuf theBuf
unsigned long long ossim_uint64
unsigned int ossim_uint32
std::stringbuf theBuf
ossim_uint64 tellp64()
virtual ~ossimBufferedInputStream()
std::basic_stringbuf< char > stringbuf
Class for char memory buffers.
Definition: ossimIosFwd.h:29
void seekg64(off_type off, ios_base::seekdir way)
Alows one to create a buffered input stream.
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
std::vector< char > m_buffer
We have a buffer that we allocate so it does not loose scope through the life of this stream...
#define OSSIM_DLL
ossimOFStream64(const char *pFilename, std::ios_base::openmode mode=ios_base::out, long prot=0666)
std::shared_ptr< ossim::istream > m_inputStream
We will save the input stream we set the buffer to.
OSSIM_DLL void operator>>(ossimIStream &in, ossimOStream &out)