octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #45318] Unable to save HDF5 file using C++ API


From: Dmitry Messerman
Subject: [Octave-bug-tracker] [bug #45318] Unable to save HDF5 file using C++ API
Date: Sun, 14 Jun 2015 12:23:49 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0

Follow-up Comment #1, bug #45318 (project octave):

Update:

I've succeeded solution myself.
Code, attached at the end of this message works.
Unless I'm missing something here, the issue is interface inconsistency.
Namely, opening file for consequent HDF5 write should be done differently.

Regards,
  Dmitry 

#include <fstream>
#include <string>
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/toplev.h>
#include <octave/load-save.h>
#include <octave/parse.h>
#include <octave/ls-hdf5.h>

using namespace std;

typedef symbol_table::symbol_record OctaveSymbolRecord;
 
int main (int argc, char** argv)
{

    auto A = ComplexNDArray(dim_vector(10,20));

    OctaveSymbolRecord a_record = OctaveSymbolRecord(0, string("A"),
octave_value(A));

    hdf5_ofstream ofs(argv[1]);
    if( ofs.file_id  > 0 ) {
         load_save_format fmt = load_save_format(LS_HDF5);
         write_header(ofs, fmt);
         do_save(ofs, a_record, fmt, false); 
     } else {
         cerr << "ERROR: failed to open " << argv[1] << " for writing" <<
endl;
     }
     ofs.close();

    return 0;
}


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?45318>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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