Gnash  0.8.11dev
IOChannel.h
Go to the documentation of this file.
1 // IOChannel.h - a virtual IO channel, for Gnash
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 
21 #ifndef GNASH_IOCHANNEL_H
22 #define GNASH_IOCHANNEL_H
23 
24 #include <string>
25 #include <boost/cstdint.hpp> // for boost int types
26 #include <iosfwd>
27 
28 #include "dsodefs.h" // DSOEXPORT
29 #include "GnashException.h" // for IOException inheritance
30 
31 namespace gnash {
32 
35 {
36 public:
37  IOException(const std::string& s) : GnashException(s) {}
38  IOException() : GnashException("IO error") {}
39 };
40 
43 {
44 public:
45 
46  virtual ~IOChannel() {}
47 
50  //
53  boost::uint32_t read_le32();
54 
56  //
59  boost::uint16_t read_le16();
60 
62  //
65  boost::uint8_t read_byte();
66 
68  //
74  virtual std::streamsize read(void* dst, std::streamsize num)=0;
75 
77  //
87  virtual std::streamsize readNonBlocking(void* dst, std::streamsize num)
88  {
89  return read(dst, num);
90  }
91 
93  //
96  virtual std::streamsize write(const void* src, std::streamsize num);
97 
101  //
111  int read_string(char* dst, int max_length);
112 
114  //
120  float read_float32();
121 
123  //
126  virtual std::streampos tell() const = 0;
127 
129  //
135  virtual bool seek(std::streampos p) = 0;
136 
138  //
141  virtual void go_to_end() = 0;
142 
144  //
147  virtual bool eof() const = 0;
148 
150  //
153  virtual bool bad() const = 0;
154 
156  //
164  virtual size_t size() const { return static_cast<size_t>(-1); }
165 
166 };
167 
168 } // namespace gnash
169 
170 #endif // GNASH_IOCHANNEL_H
171 
172 
173 // Local Variables:
174 // mode: C++
175 // indent-tabs-mode: t
176 // End: