module Fox
  #
  # Persistent store definition
  #
  # === Stream status codes
  #
  # +FXStreamOK+::		OK
  # +FXStreamEnd+::		Try read past end of stream
  # +FXStreamFull+::		Filled up stream buffer or disk full
  # +FXStreamNoWrite+::		Unable to open for write
  # +FXStreamNoRead+::		Unable to open for read
  # +FXStreamFormat+::		Stream format error
  # +FXStreamUnknown+::		Trying to read unknown class
  # +FXStreamAlloc+::		Alloc failed
  # +FXStreamFailure+::		General failure
  #
  # === Stream data flow direction
  #
  # +FXStreamDead+::	Unopened stream
  # +FXStreamSave+::	Saving stuff to stream
  # +FXStreamLoad+::	Loading stuff from stream
  #
  class FXStream

    # Stream status [Integer]
    attr_reader :status

    # Stream direction, one of +FXStreamSave+, +FXStreamLoad+ or +FXStreamDead+.
    attr_reader :direction
  
    # Parent object [FXObject]
    attr_reader :container
  
    # Stream position (an offset from the beginning of the stream) [Integer]
    attr_accessor :position
  
    #
    # Return an initialized FXStream instance.
    #
    # ==== Parameters:
    #
    # +cont+::	the container object, or +nil+ if there is none [FXObject].
    #
    def initialize(cont=nil) # :yields: theStream
    end
  
    #
    # Open this stream for reading or writing.
    # Returns true on success, false otherwise.
    #
    # ==== Parameters:
    #
    # +save_or_load+::	access mode, either +FXStreamSave+ or +FXStreamLoad+ [Integer]
    #
    def open(save_or_load); end
  
    # Close stream; returns +true+ if OK.
    def close(); end
  
    #
    # Set status code, where _err_ is one of the stream status
    # codes listed above.
    #
    def error=(err); end

    # Set the byte-swapped flag to +true+ or +false+.
    def bytesSwapped=(swapBytes); end
    
    # Returns +true+ if bytes are swapped for this stream
    def bytesSwapped?; end
  
    # Returns +true+ if little-endian architecture
    def FXStream.littleEndian?; end
  end

  # File Store Definition
  class FXFileStream < FXStream
    #
    # Return an initialized FXFileStream instance.
    #
    # ==== Parameters:
    #
    # +cont+::	the container object, or +nil+ if there is none [FXObject].
    #
    def initialize(cont=nil) # :yields: theFileStream
    end
  
    #
    # Open file stream for reading or writing.
    # Returns +true+ on success, +false+ otherwise.
    #
    # ==== Parameters:
    #
    # +filename+::	name of the file to open [String]
    # +save_or_load+::	access mode, either +FXStreamSave+ or +FXStreamLoad+ [Integer]
    #
    def open(filename, save_or_load); end
  end

  #
  # Memory Store Definition.
  #
  # Unlike the FXFileStream, the FXMemoryStream reads its data from (or writes
  # its data to) a buffer in memory.
  #
  class FXMemoryStream < FXStream

    # Available space [Integer]
    attr_accessor :space

    #
    # Return an initialized FXMemoryStream instance.
    #
    # ==== Parameters:
    #
    # +cont+::	the container object, or +nil+ if there is none [FXObject].
    #
    def initialize(cont=nil) # :yields: theMemoryStream
    end
  
    #
    # Open memory stream for reading or writing; returns +true+ if successful,
    # +false+ otherwise. If _data_ is not +nil+, the memory stream will make
    # a copy of it and use that for the stream buffer's initial contents; this
    # is what you'd usually do when reading from a stream:
    #
    #   stream = FXMemoryStream.new
    #   stream.open(data, FXStreamLoad)
    #   stream.close
    #
    # If _data_ is +nil+, the memory stream will allocate an empty buffer
    # and use that instead. This is the option you'd normally use when writing
    # to a stream, i.e.
    #
    #   stream = FXMemoryStream.new
    #   stream.open(nil, FXStreamSave)
    #   stream.close
    #
    # ==== Parameters:
    #
    # +data+::		memory buffer used for the stream, or +nil+ if the buffer is to be initially empty [String].
    # +save_or_load+::	access mode, either +FXStreamSave+ or +FXStreamLoad+ [Integer].
    #
    def open(data, save_or_load); end
    
    #
    # Return a String containing the current buffer contents, and then reset the
    # memory stream's buffer to empty.
    #
    def takeBuffer; end

    #
    # Replace the memory stream's current buffer with a copy of
    # _buffer_.
    #
    def giveBuffer(buffer); end

    #
    # Return the available space (in bytes) for this buffer.
    #
    def getSpace; end

    #
    # Resize the buffer to _sp_ bytes.
    #
    def setSpace(sp); end
  end
end

