Gnash  0.8.10
IOChannel.h
Go to the documentation of this file.
00001 // IOChannel.h - a virtual IO channel, for Gnash
00002 // 
00003 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00004 //   Free Software Foundation, Inc
00005 // 
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 3 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020 
00021 #ifndef GNASH_IOCHANNEL_H
00022 #define GNASH_IOCHANNEL_H
00023 
00024 #include <string>
00025 #include <boost/cstdint.hpp> // for boost int types
00026 #include <iosfwd>
00027 
00028 #include "dsodefs.h" // DSOEXPORT
00029 #include "GnashException.h" // for IOException inheritance
00030 
00031 namespace gnash {
00032 
00034 class DSOEXPORT IOException : public GnashException
00035 {
00036 public:
00037     IOException(const std::string& s) : GnashException(s) {}
00038     IOException() : GnashException("IO error") {}
00039 };
00040 
00042 class DSOEXPORT IOChannel
00043 {
00044 public:
00045 
00046     virtual ~IOChannel() {}
00047 
00050     //
00053     boost::uint32_t read_le32();
00054 
00056     //
00059     boost::uint16_t read_le16();
00060 
00062     //
00065     boost::uint8_t read_byte();
00066     
00068     //
00074     virtual std::streamsize read(void* dst, std::streamsize num)=0;
00075 
00077     //
00087     virtual std::streamsize readNonBlocking(void* dst, std::streamsize num)
00088     {
00089         return read(dst, num);
00090     }
00091 
00093     //
00096     virtual std::streamsize write(const void* src, std::streamsize num);
00097 
00101     //
00111     int    read_string(char* dst, int max_length);
00112     
00114     //
00120     float read_float32();
00121 
00123     //
00126     virtual std::streampos tell() const = 0;
00127 
00129     //
00135     virtual bool seek(std::streampos p) = 0;
00136 
00138     //
00141     virtual void go_to_end() = 0;
00142 
00144     //
00147     virtual bool eof() const = 0;
00148     
00150     //
00153     virtual bool bad() const = 0;
00154     
00156     //
00164     virtual size_t size() const { return static_cast<size_t>(-1); }
00165    
00166 };
00167 
00168 } // namespace gnash
00169 
00170 #endif // GNASH_IOCHANNEL_H
00171 
00172 
00173 // Local Variables:
00174 // mode: C++
00175 // indent-tabs-mode: t
00176 // End: