class Fox::FXFileStream

Public Class Methods

new(*args) click to toggle source
SWIGINTERN VALUE
_wrap_new_FXFileStream(int argc, VALUE *argv, VALUE self) {
  FXObject *arg1 = (FXObject *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  FXFileStream *result = 0 ;
  
  if ((argc < 0) || (argc > 1)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  if (argc > 0) {
    res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_FXObject, 0 |  0 );
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXObject const *","FXFileStream", 1, argv[0] )); 
    }
    arg1 = reinterpret_cast< FXObject * >(argp1);
  }
  {
    result = (FXFileStream *)new_FXFileStream((FXObject const *)arg1);
    DATA_PTR(self) = result; FXRbRegisterRubyObj(self, result);
    if(rb_block_given_p()){
      rb_yield(self);
    }
  }
  return self;
fail:
  return Qnil;
}
new(*args, &blk) click to toggle source
# File lib/fox16/kwargs.rb, line 1073
def initialize(*args, &blk)
  argument_names = %w{cont}
  default_params = { :cont => nil }
  params = {}
  params = args.pop if args.last.is_a? Hash
  args.each_with_index { |e, i| params[argument_names[i].intern] = e }
  params.keys.each { |key| raise ArgumentError, "Unrecognized parameter #{key}" unless default_params.keys.include?(key) }
  params = default_params.merge(params)
  old_initialize(params[:cont], &blk)
end
Also aliased as: old_initialize
open(filename, save_or_load, size=8192, container=nil) { |theFileStream| ... } click to toggle source

Construct a new FXFileStream object with the specified data flow direction (save_or_load) and container object. If an optional code block is given, it will be passed this file stream as an argument, and the file stream will automatically be closed when the block terminates. If no code block is provided, this method just returns the new file stream in an opened state.

Raises FXStreamNoWriteError if save_or_load is FXStreamSave but the file cannot be opened for writing. Raises FXStreamNoReadError if save_or_load is FXStreamLoad but the file cannot be opened for reading.

# File lib/fox16/iterators.rb, line 283
def FXFileStream.open(filename, save_or_load, size=8192, container=nil) # :yields: theFileStream
  fstream = FXFileStream.new(container)
  if fstream.open(filename, save_or_load, size)
    if block_given?
      begin
        yield fstream
      ensure
        fstream.close
      end
    else
      fstream
    end
  else
    # FXFileStream#open returned false, so report error
    raise FXStreamError.makeStreamError(fstream.status)
  end
end

Public Instance Methods

close(*args) click to toggle source
SWIGINTERN VALUE
_wrap_FXFileStream_close(int argc, VALUE *argv, VALUE self) {
  FXFileStream *arg1 = (FXFileStream *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  bool result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_FXFileStream, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXFileStream *","close", 1, self )); 
  }
  arg1 = reinterpret_cast< FXFileStream * >(argp1);
  result = (bool)FXFileStream_close(arg1);
  vresult = SWIG_From_bool(static_cast< bool >(result));
  return vresult;
fail:
  return Qnil;
}
flush(*args) click to toggle source
SWIGINTERN VALUE
_wrap_FXFileStream_flush(int argc, VALUE *argv, VALUE self) {
  FXFileStream *arg1 = (FXFileStream *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  bool result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_FXFileStream, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXFileStream *","flush", 1, self )); 
  }
  arg1 = reinterpret_cast< FXFileStream * >(argp1);
  result = (bool)FXFileStream_flush(arg1);
  vresult = SWIG_From_bool(static_cast< bool >(result));
  return vresult;
fail:
  return Qnil;
}
getPosition(*args) click to toggle source
SWIGINTERN VALUE
_wrap_FXFileStream_getPosition(int argc, VALUE *argv, VALUE self) {
  FXFileStream *arg1 = (FXFileStream *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  FXlong result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_FXFileStream, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXFileStream const *","position", 1, self )); 
  }
  arg1 = reinterpret_cast< FXFileStream * >(argp1);
  result = ((FXFileStream const *)arg1)->position();
  vresult = LONG2NUM(result);
  return vresult;
fail:
  return Qnil;
}
old_initialize(*args, &blk)
Alias for: new
open(*args) click to toggle source
SWIGINTERN VALUE
_wrap_FXFileStream_open(int argc, VALUE *argv, VALUE self) {
  FXFileStream *arg1 = (FXFileStream *) 0 ;
  FXString *arg2 = 0 ;
  FXStreamDirection arg3 ;
  FXuval arg4 = (FXuval) 8192 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  SwigValueWrapper< FXString > p2 ;
  int val3 ;
  int ecode3 = 0 ;
  unsigned long val4 ;
  int ecode4 = 0 ;
  bool result;
  VALUE vresult = Qnil;
  
  if ((argc < 2) || (argc > 3)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
  }
  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_FXFileStream, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXFileStream *","open", 1, self )); 
  }
  arg1 = reinterpret_cast< FXFileStream * >(argp1);
  p2 = to_FXString(argv[0]); arg2 = &p2;
  ecode3 = SWIG_AsVal_int(argv[1], &val3);
  if (!SWIG_IsOK(ecode3)) {
    SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "FXStreamDirection","open", 3, argv[1] ));
  } 
  arg3 = static_cast< FXStreamDirection >(val3);
  if (argc > 2) {
    ecode4 = SWIG_AsVal_unsigned_SS_long(argv[2], &val4);
    if (!SWIG_IsOK(ecode4)) {
      SWIG_exception_fail(SWIG_ArgError(ecode4), Ruby_Format_TypeError( "", "FXuval","open", 4, argv[2] ));
    } 
    arg4 = static_cast< FXuval >(val4);
  }
  result = (bool)(arg1)->open((FXString const &)*arg2,arg3,arg4);
  vresult = SWIG_From_bool(static_cast< bool >(result));
  return vresult;
fail:
  return Qnil;
}
setPosition(*args) click to toggle source
SWIGINTERN VALUE
_wrap_FXFileStream_setPosition(int argc, VALUE *argv, VALUE self) {
  FXFileStream *arg1 = (FXFileStream *) 0 ;
  FXlong arg2 ;
  FXWhence arg3 = (FXWhence) FXFromStart ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int val3 ;
  int ecode3 = 0 ;
  bool result;
  VALUE vresult = Qnil;
  
  if ((argc < 1) || (argc > 2)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
  }
  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_FXFileStream, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXFileStream *","position", 1, self )); 
  }
  arg1 = reinterpret_cast< FXFileStream * >(argp1);
  arg2 = static_cast<FXlong>(NUM2LONG(argv[0]));
  if (argc > 1) {
    ecode3 = SWIG_AsVal_int(argv[1], &val3);
    if (!SWIG_IsOK(ecode3)) {
      SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "FXWhence","position", 3, argv[1] ));
    } 
    arg3 = static_cast< FXWhence >(val3);
  }
  result = (bool)FXFileStream_position(arg1,arg2,arg3);
  vresult = SWIG_From_bool(static_cast< bool >(result));
  return vresult;
fail:
  return Qnil;
}