⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 streambuf.hh

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 HH
字号:
////#ifndef MAIMM_streambuf#define MAIMM_streambuf#ifndef MAIMM_buf#include "basic_mai.hh"#endif#ifndef __IOSTREAM__#include <iostream>#endif/** @file   streambuf.hh    @author Darrell Stam    @date   Wed Oct  9 04:06:43 2002    @brief  Stream buffer over an C FILE */namespace MAI {  //==================================================================  /** Basic MAI stream buffer.       @param T The kind of streambuf to derive from.  Should be a      sub-class of std::streambuf      @ingroup filemm  */  template <typename T>  class basic_streambuf : public T  {  public:    /// The streambuf type we're deriving from     typedef T                                    streambuf_type;    /// The character type     typedef typename streambuf_type::char_type   char_type;    /// The integer type     typedef typename streambuf_type::int_type    int_type;    /// The type of traits     typedef typename streambuf_type::traits_type traits_type;    /// The underlying MAI interface type     typedef basic_mai<char_type, traits_type>   mai_type;    /// The position type     typedef typename traits_type::pos_type       pos_type;    /// The offset type    typedef typename traits_type::off_type       off_type;  private:    /// The underlying C FILE abstraction layer.     mai_type _mai_handle;  protected:    /** @name std::basic_streambuf interface. 	Forwards call to C FILE abstraction layer. */     /*@{*/    /** write a character to output. 	@param c The character to write. 	@return EOF on failure or @p c on success. */    int_type overflow(int_type c=EOF) { return _mai_handle.overflow(c); }    /** Read the pending character from the stream and put it back. 	@return the next pending input. */    int_type underflow() { return _mai_handle.underflow(); }    /** Read the pending character from the stream. 	@return the next pending input. */    int_type uflow() { return _mai_handle.uflow(); }    /** Put back one character to the input stream. 	@param c the character to put back. 	@return EOF on failure, otherwise @p c */    int_type pbackfail(int_type c=EOF) { return _mai_handle.pbackfail(c); }    /** Read a block of characters from the file. 	@param buf Buffer to read into. 	@param n Size of the buffer to fill. 	@return # of characters read. */    std::streamsize xsgetn(char_type* buf, std::streamsize n);    /** Put back a block of characters to the file. 	@param buf Buffer to read from. 	@param n Size of the buffer to write out. 	@return # of characters writen. */    std::streamsize xsputn(char_type* buf, std::streamsize n);    /** Syncronise the stream. 	@return EOF on error. */    int sync() { return _mai_handle.sync(); }    /** Seek to an offset in the file in the stream. 	@param pos The position to seek to. 	@param dir The direction to seek in. 	@param mode The open mode. 	@return new offset in the file. */    pos_type seekoff(off_type pos, 		     std::ios_base::seekdir dir,		     std::ios_base::openmode mode=		     std::ios::in|std::ios::out);    /** Seek to a position in the stream. 	@param pos The position to seek to. 	@param mode The open mode. 	@return new offset in the file. */    pos_type seekpos(off_type pos, 		     std::ios_base::openmode mode=		     std::ios::in|std::ios::out);        /*@}*/  public:    /** Constructor. */    basic_streambuf() : streambuf_type() { setbuf(0, 0); };    /** Constrcutor with an explicit C FILE argument. 	This constructor is non-standard. 	@param fp A C FILE pointer. */    basic_streambuf(MAICompBufferPool_t handle) : streambuf_type(), _mai_handle(handle) {printf("creating basic_streambuf\n"); setbuf(0, 0); }    /** Destructor. */    virtual ~basic_streambuf() {}    /** @name std::basic_filebuf interface. 	Forwards call to C FILE abstraction layer. */     /*@{*/    /** Opens a file. 	@param name the file to open. 	@param mode the mode to open the file in. 	@return a pointer to self. */    streambuf_type* open(const char* name, std::ios_base::openmode mode);    /** Closes a file.	@return a pointer to self. */    streambuf_type* close();    /** Test if file is open. 	@return true if open, false otherwise. */    bool is_open() const { return _mai_handle.is_open(); }    /*@}*/    /** Conversion operator. 	@return self as a pointer to C @c FILE object. */    operator MAICompBufferPool_t () { return _mai_handle._handle; }  };  #ifdef __GLOBAL_STREAMBUF_NAMESPACE_  //__________________________________________________________________  template<typename T>  std::streamsize   basic_streambuf<T>::xsgetn(basic_streambuf<T>::char_type* buf, std::streamsize n)  {    return _mai_handle.xsgetn(buf, n);  }  //__________________________________________________________________  template <typename T>  std::streamsize   basic_streambuf<T>::xsputn(basic_streambuf<T>::char_type* buf,  std::streamsize n)  {    return _mai_handle.xsgetn(buf, n);  }  //__________________________________________________________________  template <typename T>  typename basic_streambuf<T>::pos_type   basic_streambuf<T>::seekoff(basic_streambuf<T>::off_type pos, 			       std::ios_base::seekdir dir,			       std::ios_base::openmode mode)   {    return _mai_handle.seekoff(pos, dir, mode);  }    //__________________________________________________________________  template <typename T>  typename basic_streambuf<T>::pos_type   basic_streambuf<T>::seekpos(basic_streambuf<T>::off_type pos, 			 std::ios_base::openmode mode)   {    return _mai_handle.seekpos(pos, mode);  }    //__________________________________________________________________  template <typename T>  typename basic_streambuf<T>::streambuf_type*  basic_streambuf<T>::open(const char* name, 			    std::ios_base::openmode mode)   {    return _mai_handle.open(name, mode) ? this : 0;  }    //__________________________________________________________________  template <typename T>  typename basic_streambuf<T>::streambuf_type*  basic_streambuf<T>::close()  {    return _mai_handle.close() ? this : 0;   }#undef __GLOBAL_STREAMBUF_NAMESPACE_#endif // __GLOBAL_STREAMBUF_NAMESPACE_    //==================================================================  /** MAI normal stream buffer.       @ingroup filemm  */  typedef basic_streambuf<std::streambuf> streambuf;}#endif//____________________________________________________________________//// EOF//

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -