class Fox::FXStream
A stream is a way to serialize data and objects into a byte stream. Each item of data that is saved or loaded from the stream may be byte-swapped, thus allowing little-endian machines to read data produced on big endian ones and vice-versa. Data is serialized exactly as-is. There are no tags or other markers inserted into the stream; thus, the stream may be used to save or load arbitrary binary data. Objects derived from FXObjects may be serialized also; whenever a reference to an object is serialized, a table is consulted to determine if the same object has been encountered previously; if not, the object is added to the table and then its contents are serialized. If the object has been encountered before, only a reference to the object is serialized. When loading back a serialized object, new instances are constructed using the default constructor, and subsequently the object’s contents are loaded. A special container object may be passed in which is placed in the table as if it had been encountered before; this will cause only references to this object to be saved. The container object is typically the top-level document object which manages all objects contained by it. Additional objects may be added using addObject(); these will not be actually saved or loaded.
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
Stream seeking¶ ↑
FXFromStart-
Seek from start position
FXFromCurrent-
Seek from current position
FXFromEnd-
Seek from end position
Attributes
Stream position (an offset from the beginning of the stream) [Integer]
Available buffer space
Public Class Methods
Source
SWIGINTERN VALUE
_wrap_new_FXStream(int argc, VALUE *argv, VALUE self) {
FXObject *arg1 = (FXObject *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
FXStream *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 *","FXStream", 1, argv[0] ));
}
arg1 = reinterpret_cast< FXObject * >(argp1);
}
{
result = (FXStream *)new_FXStream((FXObject const *)arg1);
DATA_PTR(self) = result; FXRbRegisterRubyObj(self, result);
if(rb_block_given_p()){
rb_yield(self);
}
}
return self;
fail:
return Qnil;
}
Source
# File lib/fox16/kwargs.rb, line 2273 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
Public Instance Methods
Source
# File rdoc-sources/FXStream.rb, line 134 def bigEndian=(big); end
Set stream to big endian mode if true. Byte swapping will be enabled if the machine native byte order is not equal to the desired byte order.
Source
# File rdoc-sources/FXStream.rb, line 139 def bigEndian?; end
Return true if big endian mode.
Source
# File rdoc-sources/FXStream.rb, line 124 def bytesSwapped=(swapBytes); end
Set the byte-swapped flag to true or false.
Source
# File rdoc-sources/FXStream.rb, line 127 def bytesSwapped?; end
Returns true if bytes are swapped for this stream
Source
SWIGINTERN VALUE
_wrap_FXStream_close(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 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_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream *","close", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(argp1);
result = (bool)FXStream_close(arg1);
vresult = SWIG_From_bool(static_cast< bool >(result));
return vresult;
fail:
return Qnil;
}
Source
SWIGINTERN VALUE
_wrap_FXStream_container(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
FXObject *result = 0 ;
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_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream const *","container", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(argp1);
result = (FXObject *)((FXStream const *)arg1)->container();
{
swig_type_info *ty = SWIG_TypeDynamicCast(SWIGTYPE_p_FXObject, (void **) &result);
vresult = FXRbGetRubyObj(result, ty);
}
return vresult;
fail:
return Qnil;
}
Parent object {FXObject}
Source
SWIGINTERN VALUE
_wrap_FXStream_direction(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
FXStreamDirection 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_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream const *","direction", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(argp1);
result = (FXStreamDirection)((FXStream const *)arg1)->direction();
vresult = SWIG_From_int(static_cast< int >(result));
return vresult;
fail:
return Qnil;
}
Stream direction, one of FXStreamSave, FXStreamLoad or FXStreamDead.
Source
SWIGINTERN VALUE
_wrap_FXStream_eofq___(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 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_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream const *","eof", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(argp1);
result = (bool)((FXStream const *)arg1)->eof();
vresult = SWIG_From_bool(static_cast< bool >(result));
return vresult;
fail:
return Qnil;
}
Source
# File rdoc-sources/FXStream.rb, line 121 def error=(err); end
Set status code, where err is one of the stream status codes listed above.
Source
SWIGINTERN VALUE
_wrap_FXStream_flush(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 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_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream *","flush", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(argp1);
result = (bool)FXStream_flush(arg1);
vresult = SWIG_From_bool(static_cast< bool >(result));
return vresult;
fail:
return Qnil;
}
Source
SWIGINTERN VALUE
_wrap_FXStream_getPosition(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 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_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream const *","position", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(argp1);
result = ((FXStream const *)arg1)->position();
vresult = LONG2NUM(result);
return vresult;
fail:
return Qnil;
}
Source
SWIGINTERN VALUE
_wrap_FXStream_getSpace(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
FXuval 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_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream const *","getSpace", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(argp1);
result = (FXuval)((FXStream const *)arg1)->getSpace();
vresult = SWIG_From_unsigned_SS_long(static_cast< unsigned long >(result));
return vresult;
fail:
return Qnil;
}
Source
SWIGINTERN VALUE
_wrap_FXStream_isBigEndian(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 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_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream const *","isBigEndian", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(argp1);
result = (bool)((FXStream const *)arg1)->isBigEndian();
vresult = SWIG_From_bool(static_cast< bool >(result));
return vresult;
fail:
return Qnil;
}
Source
SWIGINTERN VALUE
_wrap_FXStream_open(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 0 ;
FXStreamDirection arg2 ;
FXuval arg3 = (FXuval) 8192 ;
FXuchar *arg4 = (FXuchar *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
int val2 ;
int ecode2 = 0 ;
unsigned long val3 ;
int ecode3 = 0 ;
bool result;
VALUE vresult = Qnil;
if ((argc < 1) || (argc > 3)) {
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
}
res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream *","open", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(argp1);
ecode2 = SWIG_AsVal_int(argv[0], &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "FXStreamDirection","open", 2, argv[0] ));
}
arg2 = static_cast< FXStreamDirection >(val2);
if (argc > 1) {
ecode3 = SWIG_AsVal_unsigned_SS_long(argv[1], &val3);
if (!SWIG_IsOK(ecode3)) {
SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "FXuval","open", 3, argv[1] ));
}
arg3 = static_cast< FXuval >(val3);
}
if (argc > 2) {
arg4 = NIL_P(argv[2]) ? 0 : reinterpret_cast<FXuchar*>(StringValuePtr(argv[2]));
}
result = (bool)(arg1)->open(arg2,arg3,arg4);
vresult = SWIG_From_bool(static_cast< bool >(result));
return vresult;
fail:
return Qnil;
}
Source
SWIGINTERN VALUE
_wrap_FXStream_setBigEndian(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 0 ;
bool arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
bool val2 ;
int ecode2 = 0 ;
if ((argc < 1) || (argc > 1)) {
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
}
res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream *","setBigEndian", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(argp1);
ecode2 = SWIG_AsVal_bool(argv[0], &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "bool","setBigEndian", 2, argv[0] ));
}
arg2 = static_cast< bool >(val2);
(arg1)->setBigEndian(arg2);
return Qnil;
fail:
return Qnil;
}
Source
SWIGINTERN VALUE
_wrap_FXStream_setError(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 0 ;
FXStreamStatus arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
int val2 ;
int ecode2 = 0 ;
if ((argc < 1) || (argc > 1)) {
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
}
res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream *","setError", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(argp1);
ecode2 = SWIG_AsVal_int(argv[0], &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "FXStreamStatus","setError", 2, argv[0] ));
}
arg2 = static_cast< FXStreamStatus >(val2);
(arg1)->setError(arg2);
return Qnil;
fail:
return Qnil;
}
Source
SWIGINTERN VALUE
_wrap_FXStream_setPosition(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 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_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream *","position", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(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)FXStream_position(arg1,SWIG_STD_MOVE(arg2),arg3);
vresult = SWIG_From_bool(static_cast< bool >(result));
return vresult;
fail:
return Qnil;
}
Source
SWIGINTERN VALUE
_wrap_FXStream_setSpace(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 0 ;
FXuval arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
unsigned long val2 ;
int ecode2 = 0 ;
if ((argc < 1) || (argc > 1)) {
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
}
res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream *","setSpace", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(argp1);
ecode2 = SWIG_AsVal_unsigned_SS_long(argv[0], &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "FXuval","setSpace", 2, argv[0] ));
}
arg2 = static_cast< FXuval >(val2);
(arg1)->setSpace(arg2);
return Qnil;
fail:
return Qnil;
}
Source
SWIGINTERN VALUE
_wrap_FXStream_status(int argc, VALUE *argv, VALUE self) {
FXStream *arg1 = (FXStream *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
FXStreamStatus 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_FXStream, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "FXStream const *","status", 1, self ));
}
arg1 = reinterpret_cast< FXStream * >(argp1);
result = (FXStreamStatus)((FXStream const *)arg1)->status();
vresult = SWIG_From_int(static_cast< int >(result));
return vresult;
fail:
return Qnil;
}
Stream status [Integer]
Source
SWIGINTERN VALUE _wrap_FXStream_swapBytes(int nargs, VALUE *args, VALUE self) {
int argc;
VALUE argv[3];
int ii;
argc = nargs + 1;
argv[0] = self;
if (argc > 3) SWIG_fail;
for (ii = 1; (ii < argc); ++ii) {
argv[ii] = args[ii-1];
}
if (argc == 1) {
int _v = 0;
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_FXStream, 0);
_v = SWIG_CheckState(res);
if (_v) {
return _wrap_FXStream_swapBytes__SWIG_1(nargs, args, self);
}
}
if (argc == 2) {
int _v = 0;
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_FXStream, 0);
_v = SWIG_CheckState(res);
if (_v) {
{
int res = SWIG_AsVal_bool(argv[1], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
return _wrap_FXStream_swapBytes__SWIG_0(nargs, args, self);
}
}
}
fail:
Ruby_Format_OverloadedError( argc, 3, "FXStream.swapBytes",
" void FXStream.swapBytes(bool s)\n"
" bool FXStream.swapBytes()\n");
return Qnil;
}