[SAGA-RG] saga::file::read and saga::file::write etc.
Hartmut Kaiser
hkaiser at cct.lsu.edu
Mon Oct 8 17:43:15 CDT 2007
Hi all,
> 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
The same is true for saga::stream::read and saga::stream::write, BTW.
Regards Hartmut
More information about the saga-rg
mailing list