Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Back  Login

GLib::BufferedInputStream Diff - Ruby-GNOME2 Project Website

  • Added parts are displayed like this.
  • Deleted parts are displayed like this.

= class GLib::BufferedInputStream

Buffered input stream implements GLib::FilterInputStream and provides for
buffered reads.

By default, GLib::BufferedInputStream’s buffer size is set at 4 kilobytes.

To create a buffered input stream, use GLib::BufferedInputStream.new.

To get the size of a buffer within a buffered input stream, use
GLib::BufferedInputStream#buffer_size. To change the size of a buffered
input stream’s buffer, use GLib::BufferedInputStream#buffer_size=. Note that
the buffer’s size cannot be reduced below the size of the data within the
buffer.

== Object Hierarchy

* Object
  * GLib::Instantiatable
    * GLib::Object
      * GLib::InputStream
        * GLib::FilterInputStream
          * GLib::BufferedInputStream

== Known Subclasses

     * GLib::DataInputStream

== Class Methods

--- GLib::BufferedInputStream.new(base_stream, size = 4096)

     Creates a new GLib::BufferedInputStream from ((|base_stream|)), with a
     buffer size set to ((|size|)).

     * base_stream: A GLib::InputStream
     * Returns: a new GLib::BufferedInputStream for the given ((|base_stream|))

== Instance Methods

--- available

     Gets the size of the available data within the stream.

     * Returns: The size of the available data within the stream

--- buffer_size

     Gets the size of the input buffer.

     * Returns: The size of the input buffer

--- buffer_size=(buffer_size)

     Same as GLib::BufferedInputStream#set_buffer_size.

     * Returns: buffer_size

--- fill(count = -1, cancellable = nil)

     Tries to read ((|count|)) bytes from the stream into the buffer.  Will
     block during this read.

     If ((|count|)) is zero, returns zero and does nothing. A value of ((|count|))
     larger than GLib::MAXSSIZE will raise GLib::IO::InvalidArgumentError.

     On success, the number of bytes read into the buffer is returned.  It is
     not an error if this is not the same as the requested size, as it can
     happen, for example, near the end of a file. Zero is returned on end of file (or if
     ((|count|)) is zero),  but never otherwise.

     If ((|count|)) is -1, then the attempted read size is equal to the number
     of bytes that are required to fill the buffer.

     If ((|cancellable|)) is not nil, then the operation can be cancelled by
     triggering the cancellable object from another thread. If the operation
     was cancelled, GLib::IO::CancelledError will be raised. If an operation
     was partially finished when the operation was cancelled the partial result
     will be returned, without an error.

     For the asynchronous, non-blocking, version of this function, see
     GLib::BufferedInputStream#fill_async.

     * count: The number of bytes that will be read from the stream
     * cancellable: Optional GLib::Cancellable object, nil to ignore
     * Returns: The number of bytes read into this stream’s buffer

--- fill_async(count, io_priority = GLib::PRIORITY_DEFAULT, cancellable = nil){ |result| … }

     Reads data into this stream’s buffer asynchronously, up to ((|count|))
     bytes. ((|Io_priority|)) can be used to prioritize reads. For the
     synchronous version of this function, see GLib::BufferedInputStream#fill.

     If ((|count|)) is -1, then the attempted read size is equal to the number
     of bytes that are required to fill the buffer.

     * count: The number of bytes that will be read from the stream
     * io_priority: The I/O priority of the request
     * cancellable: Optional GLib::Cancellable object
     * result: A GLib::AsyncResult
     * Returns: self

--- fill_finish(result)

     Finishes an asynchronous read.

     A GLib::IO::Error is raised if the buffer filling failed.

     * result: A GLib::AsyncResult
     * Returns: The number of bytes read into this stream’s buffer

--- peek(offset, count)

     Peeks ((|count|)) bytes of data from the buffer, beginning at ((|offset|)).

     * offset: An index to begin peeking at
     * count: The number of bytes to peek at
     * Returns: ((|count|)) bytes of data from the buffer, beginning at
       ((|offset|)), as a String

--- peek_buffer

     Returns the buffer with the currently available bytes.

     * Returns: A String containing the currently available bytes in the buffer

--- read_byte(cancellable = nil)

     Tries to read a single byte from the stream or the buffer. Will block
     during this read.

     On success, the byte read from the stream is returned. On end of stream,
     -1 is returned.

     If ((|cancellable|)) is not nil, then the operation can be cancelled by
     triggering the cancellable object from another thread. If the operation
     was cancelled, GLib::IO::CancelledError will be raised. If an operation
     was partially finished when the operation was cancelled the partial result
     will be returned, without an error.

     * cancellable: Optional GLib::Cancellable object, nil to ignore
     * Returns: The byte read from this stream, or -1 on end of stream

--- set_buffer_size(buffer_size)

     Sets the size of the input buffer.

     * buffer_size: The size of the input buffer
     * Returns: self

== Properties

--- buffer-size: Integer (Read/Write)

     The size of the input buffer

     Allowed values: ≥ 1

     Default value: 4096

== See Also

== ChangeLog