Method: Fox::FXMemoryStream.open
- Defined in:
- lib/fox16/iterators.rb
.open(save_or_load, data, cont = nil) ⇒ Object
Construct a new FXMemoryStream object with the specified data flow direction, data and container object. If an optional code block is given, it will be passed this memory stream as an argument, and the memory stream will automatically be closed when the block terminates. If no code block is provided, this method just returns the new memory stream in an opened state.
Raises FXStreamAllocError if some kind of memory allocation failed while initializing the stream.
Parameters:
save_or_load:: access mode, either FXStreamSave or FXStreamLoad [Integer] data:: memory buffer used for the stream, or nil if the buffer is to be initially empty [String]. cont:: the container object, or nil if there is none [FXObject]
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/fox16/iterators.rb', line 321 def FXMemoryStream.open(save_or_load, data, cont=nil) # :yields: theMemoryStream stream = FXMemoryStream.new(cont) if stream.open(save_or_load, data) if block_given? begin yield stream ensure stream.close end else stream end else # FXFileStream#open returned false, so report error raise FXStreamError.makeStreamError(stream.status) end end |