help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting an octave_value to a stream


From: Muthiah Annamalai
Subject: Re: Converting an octave_value to a stream
Date: Sun, 30 Dec 2007 14:44:58 -0600

On Dec 30, 2007 10:44 AM, John W. Eaton <address@hidden> wrote:
> On 30-Dec-2007, Thomas Weber wrote:
>
> | I'm trying to convert some .oct files from 2.1 to 3.0. The problematic
> | lines are
> |
> | DEFUN_DLD( pfsopen, args, , helpString)
> | {
> | ...
> |     octave_stream fid = args(0).stream_value();
> |
> |
> | According to src/ChangeLog, the stream_value() and related functions
> | were removed in 2005. So, how do I get the stream from an octave_value?
>
> What is the type of args(0) expected to be?  I guess it was a stream
> (file) object in the past?  That no longer exists, and we use integers
> (stored as doubles) for file numbers now.  See the functions in
> src/file-io.cc, for example.
>
> jwe


Im not sure if I get your problem right.

In some of my gd-octave code that works with Octave 3.0
I use the code below for implementing a function gdImagePtr gdImageCreateFromPng
whose first argument is a octave_stream type created using fopen()
within Octave.

DEFUN_DLD( gdImageCreateFromPng , args , , " gdImagePtr
gdImageCreateFromPng(FILE *fd); " )
{
octave_stream  _fd;
FILE *fd ;
 if(args.length()!= 1 )
  {
   std::cout<< "eg:  gdImagePtr gdImageCreateFromPng(FILE *fd); " <<std::endl;
   return octave_value(-1);
  }
#ifdef DEBUG
std::cout<<" gdImageCreateFromPng "<<std::endl;
#endif /* DEBUG */
string __mode_str;
_fd = octave_stream_list::lookup(\
octave_stream_list::get_file_number(args(0)) );
__mode_str= _fd .mode_as_string( _fd .mode());
fd = fdopen( ( octave_stream_list::get_file_number(args(0)) ) ,
__mode_str.c_str());
long int ret_type= (long int) gdImageCreateFromPng ( fd);
fflush(fd);
return octave_value(ret_type);
}



HTH,
Muthu


reply via email to

[Prev in Thread] Current Thread [Next in Thread]