[SAGA-RG] saga::file::read and saga::file::write etc.

Hartmut Kaiser hartmut.kaiser at gmail.com
Mon Oct 8 17:25:47 CDT 2007


Resending because of mailer problems...


Hi all,

While trying to implement the latest changes of the spec I have the
following comments:

1. we added the option for a const correct buffer class to the spec,
shouldn't the same be allowed for the iovec class (i.e. a const correct
version of the iovec type)

2. I'ld suggest to change the saga::file::read and saga::file::write API
functions as follows:

   saga::ssize_t read(saga::mutable_buffer, saga::ssize_t bytes = 0)
   saga::ssize_t write(saga::const_buffer, saga::ssize_t bytes = 0)

The rationale behind this is that the buffer already contains a size, which
by default could be used for the operation (if the 'bytes' parameter is
zero). In C++ this would allow to simplify the code significantly. i.e.

  saga::file f(...);

  char cb[100];
  f.read(buffer(cb));       // read 100 char's

  std::vector<double> v(20);
  f.read(buffer(v, 10));    // read 10 doubles

Or

  std::vector<int> vi;
  // fill vi ...
  f.write(buffer(vi));      // write all elements of vi

Etc.

Regards Hartmut




More information about the saga-rg mailing list