comparison libinterp/octave-value/ov-struct.cc @ 20070:09ed6f7538dd

avoid needing to include hdf5 in public header files (bug #44370, #43180) * oct-hdf5-id.cc, oct-hdf5-id.h: New files. * libinterp/corefcn/module.mk: Update. * libgui/src/module.mk (src_libgui_src_la_CPPFLAGS): Remove $(HDF5_CPPFLAGS) from the list. * load-save.h (enum load_save_format_type): Always include LS_HDF5 in the list of values. * ls-hdf5.cc (read_hdf5_data, save_hdf5_data): Call check_hdf5_id_type. * oct-hdf5.h: Also #define HDF5_SAVE_TYPE. * ov.h, ov-base.h: Include oct-hdf5-id.h instead of oct-hdf5.h. Always declare load_hdf5 and save_hdf5 functions. * ov-base-int.cc, ov-base-int.h, ov-base.cc, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc, ov-bool.h, ov-cell.cc, ov-cell.h, ov-class.cc, ov-class.h, ov-complex.cc, ov-complex.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc, ov-cx-sparse.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn-inline.cc, ov-fcn-inline.h, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-lazy-idx.h, ov-oncleanup.cc, ov-oncleanup.h, ov-range.cc ov-range.h, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc, ov-str-mat.h, ov-struct.cc, ov-struct.h, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc: Move #ifdef HAVE_HDF5 inside load_hdf5 and save_hdf5 functions. Always declare and define load_hdf5 and save_hdf5 functions.
author John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
date Thu, 26 Feb 2015 10:49:20 -0500
parents e9a0bd0b125c
children 075a5e2e1ba5
comparison
equal deleted inserted replaced
20069:6b851f6acd55 20070:09ed6f7538dd
30 #include "defun.h" 30 #include "defun.h"
31 #include "error.h" 31 #include "error.h"
32 #include "gripes.h" 32 #include "gripes.h"
33 #include "mxarray.h" 33 #include "mxarray.h"
34 #include "oct-lvalue.h" 34 #include "oct-lvalue.h"
35 #include "oct-hdf5.h"
35 #include "ov-struct.h" 36 #include "ov-struct.h"
36 #include "unwind-prot.h" 37 #include "unwind-prot.h"
37 #include "utils.h" 38 #include "utils.h"
38 #include "variables.h" 39 #include "variables.h"
39 40
977 success = false; 978 success = false;
978 979
979 return success; 980 return success;
980 } 981 }
981 982
983 bool
984 octave_struct::save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats)
985 {
982 #if defined (HAVE_HDF5) 986 #if defined (HAVE_HDF5)
983 987
984 bool
985 octave_struct::save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats)
986 {
987 hid_t data_hid = -1; 988 hid_t data_hid = -1;
988 989
989 #if HAVE_HDF5_18 990 #if HAVE_HDF5_18
990 data_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 991 data_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
991 #else 992 #else
1016 } 1017 }
1017 1018
1018 H5Gclose (data_hid); 1019 H5Gclose (data_hid);
1019 1020
1020 return true; 1021 return true;
1022
1023 #else
1024 gripe_save ("hdf5");
1025 return false;
1026 #endif
1021 } 1027 }
1022 1028
1023 bool 1029 bool
1024 octave_struct::load_hdf5 (hid_t loc_id, const char *name) 1030 octave_struct::load_hdf5 (octave_hdf5_id loc_id, const char *name)
1025 { 1031 {
1026 bool retval = false; 1032 bool retval = false;
1033
1034 #if defined (HAVE_HDF5)
1027 1035
1028 hdf5_callback_data dsub; 1036 hdf5_callback_data dsub;
1029 1037
1030 herr_t retval2 = 0; 1038 herr_t retval2 = 0;
1031 octave_map m (dim_vector (1, 1)); 1039 octave_map m (dim_vector (1, 1));
1064 { 1072 {
1065 map = m; 1073 map = m;
1066 retval = true; 1074 retval = true;
1067 } 1075 }
1068 1076
1069 return retval; 1077 #else
1070 } 1078 gripe_load ("hdf5");
1071
1072 #endif 1079 #endif
1080
1081 return retval;
1082 }
1073 1083
1074 mxArray * 1084 mxArray *
1075 octave_struct::as_mxArray (void) const 1085 octave_struct::as_mxArray (void) const
1076 { 1086 {
1077 int nf = nfields (); 1087 int nf = nfields ();
1612 success = false; 1622 success = false;
1613 1623
1614 return success; 1624 return success;
1615 } 1625 }
1616 1626
1627 bool
1628 octave_scalar_struct::save_hdf5 (octave_hdf5_id loc_id, const char *name,
1629 bool save_as_floats)
1630 {
1617 #if defined (HAVE_HDF5) 1631 #if defined (HAVE_HDF5)
1618 1632
1619 bool
1620 octave_scalar_struct::save_hdf5 (hid_t loc_id, const char *name,
1621 bool save_as_floats)
1622 {
1623 hid_t data_hid = -1; 1633 hid_t data_hid = -1;
1624 1634
1625 #if HAVE_HDF5_18 1635 #if HAVE_HDF5_18
1626 data_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 1636 data_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
1627 #else 1637 #else
1652 } 1662 }
1653 1663
1654 H5Gclose (data_hid); 1664 H5Gclose (data_hid);
1655 1665
1656 return true; 1666 return true;
1667
1668 #else
1669 gripe_save ("hdf5");
1670 return false;
1671 #endif
1657 } 1672 }
1658 1673
1659 bool 1674 bool
1660 octave_scalar_struct::load_hdf5 (hid_t loc_id, const char *name) 1675 octave_scalar_struct::load_hdf5 (octave_hdf5_id loc_id, const char *name)
1661 { 1676 {
1662 bool retval = false; 1677 bool retval = false;
1678
1679 #if defined (HAVE_HDF5)
1663 1680
1664 hdf5_callback_data dsub; 1681 hdf5_callback_data dsub;
1665 1682
1666 herr_t retval2 = 0; 1683 herr_t retval2 = 0;
1667 octave_scalar_map m; 1684 octave_scalar_map m;
1698 { 1715 {
1699 map = m; 1716 map = m;
1700 retval = true; 1717 retval = true;
1701 } 1718 }
1702 1719
1703 return retval; 1720 #else
1704 } 1721 gripe_load ("hdf5");
1705
1706 #endif 1722 #endif
1723
1724 return retval;
1725 }
1707 1726
1708 mxArray * 1727 mxArray *
1709 octave_scalar_struct::as_mxArray (void) const 1728 octave_scalar_struct::as_mxArray (void) const
1710 { 1729 {
1711 int nf = nfields (); 1730 int nf = nfields ();