octave-maintainers
[Top][All Lists]
Advanced

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

Re: "save" to and "load" from file descriptor


From: John W. Eaton
Subject: Re: "save" to and "load" from file descriptor
Date: Tue, 12 Jun 2007 18:37:44 -0400

On 12-Jun-2007, David Bateman wrote:

| In fact a change like that wouldn't be too difficult as the prototypes
| for octave's binary format
| 
| extern bool
| save_binary_data (std::ostream& os, const octave_value& tc,
|                   const std::string& name, const std::string& doc,
|                   bool mark_as_global, bool save_as_floats);
| 
| extern std::string
| read_binary_data (std::istream& is, bool swap,
|                   oct_mach_info::float_format fmt,
|                   const std::string& filename, bool& global,
|                   octave_value& tc, std::string& doc);
| 
| would tell you. You just need a wrapper to setup the iostreams on both
| sides and then install the variables into memory on the reader's side...
| Should be relatively easy..

So how would these be used?

  fid = fopen ("foo.mat", "w");
  fsave (fid, "var1", "var2");
  fclose (fid);

or would you pass the value itself?  If you pass the value, what name
would be used in the save/load functions?

Would it be possible to write

  fid = fopen ("foo.mat", "w");
  fsave (fid, "var1");
  fsave (fid, "var2");
  fclose (fid);

What would happen on the second call to fsave?  How would fsave know
to omit the header info (for example, for the MAT binary formats)?

Because of these issues, I think maybe what you want to do is use the
exported functions to write specialized functions that send and
receive data using a particular transport method rather than writing
fsend/fsave that accept file IDs.

jwe


reply via email to

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