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 
27 #include "dsodefs.h" // DSOEXPORT
28 #include "GnashException.h" // for IOException inheritance
29 
30 namespace gnash {
31 
34 {
35 public:
36  IOException(const std::string& s) : GnashException(s) {}
37  IOException() : GnashException("IO error") {}
38 };
39 
42 {
43 public:
44 
45  virtual ~IOChannel() {}
46 
49  //
52  boost::uint32_t read_le32();
53 
55  //
58  boost::uint16_t read_le16();
59 
61  //
64  boost::uint8_t read_byte();
65 
67  //
73  virtual std::streamsize read(void* dst, std::streamsize num)=0;
74 
76  //
86  virtual std::streamsize readNonBlocking(void* dst, std::streamsize num)
87  {
88  return read(dst, num);
89  }
90 
92  //
95  virtual std::streamsize write(const void* src, std::streamsize num);
96 
100  //
110  int read_string(char* dst, int max_length);
111 
113  //
119  float read_float32();
120 
122  //
125  virtual std::streampos tell() const = 0;
126 
128  //
134  virtual bool seek(std::streampos p) = 0;
135 
137  //
140  virtual void go_to_end() = 0;
141 
143  //
146  virtual bool eof() const = 0;
147 
149  //
152  virtual bool bad() const = 0;
153 
155  //
163  virtual size_t size() const { return static_cast<size_t>(-1); }
164 
165 };
166 
167 } // namespace gnash
168 
169 #endif // GNASH_IOCHANNEL_H
170 
171 
172 // Local Variables:
173 // mode: C++
174 // indent-tabs-mode: t
175 // End:
A virtual IO channel.
Definition: IOChannel.h:41
SWFStream & s
Definition: DefineBitsTag.cpp:73
void write(SimpleBuffer &buf, const std::string &str)
Write a string to an AMF buffer.
Definition: AMF.cpp:161
IOException()
Definition: IOChannel.h:37
virtual ~IOChannel()
Definition: IOChannel.h:45
IOException(const std::string &s)
Definition: IOChannel.h:36
#define DSOEXPORT
Definition: dsodefs.h:55
virtual size_t size() const
Get the size of the stream (unreliably).
Definition: IOChannel.h:163
Exception signalling an IO error.
Definition: IOChannel.h:33
virtual std::streamsize readNonBlocking(void *dst, std::streamsize num)
Read at most the given number of bytes w/out blocking.
Definition: IOChannel.h:86
Definition: GnashKey.h:162
Top-level gnash exception.
Definition: GnashException.h:30