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 <ios> // for std::streamsize
26 #include <cstdint> // for boost int types
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  std::uint32_t read_le32();
54 
56  //
59  std::uint16_t read_le16();
60 
62  //
65  std::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  //
117  virtual std::streampos tell() const = 0;
118 
120  //
126  virtual bool seek(std::streampos p) = 0;
127 
129  //
132  virtual void go_to_end() = 0;
133 
135  //
138  virtual bool eof() const = 0;
139 
141  //
144  virtual bool bad() const = 0;
145 
147  //
155  virtual size_t size() const { return static_cast<size_t>(-1); }
156 
157 };
158 
159 } // namespace gnash
160 
161 #endif // GNASH_IOCHANNEL_H
162 
163 
164 // Local Variables:
165 // mode: C++
166 // indent-tabs-mode: t
167 // End:
A virtual IO channel.
Definition: IOChannel.h:42
void write(SimpleBuffer &buf, const std::string &str)
Write a string to an AMF buffer.
Definition: AMF.cpp:161
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
IOException()
Definition: IOChannel.h:38
virtual ~IOChannel()
Definition: IOChannel.h:46
IOException(const std::string &s)
Definition: IOChannel.h:37
virtual size_t size() const
Get the size of the stream (unreliably).
Definition: IOChannel.h:155
#define DSOEXPORT
Definition: dsodefs.h:55
Exception signalling an IO error.
Definition: IOChannel.h:34
virtual std::streamsize readNonBlocking(void *dst, std::streamsize num)
Read at most the given number of bytes w/out blocking.
Definition: IOChannel.h:87
Definition: GnashKey.h:162
Definition: GnashKey.h:165
Top-level gnash exception.
Definition: GnashException.h:30