HDF5 (WIP): first objects and h5dump implementation: 21/8921/2
Calixte DENIZET [Mon, 3 Sep 2012 17:33:50 +0000 (19:33 +0200)]
a=[1 2; 3 4; 5 6];
save("/tmp/foo.sod","a");
h5dump("/tmp/foo.sod")

Change-Id: I3388a8911c8287107099b71af1551fbcd5d92466

46 files changed:
scilab/modules/hdf5/Makefile.am
scilab/modules/hdf5/Makefile.in
scilab/modules/hdf5/includes/HDF5Objects.h [new file with mode: 0644]
scilab/modules/hdf5/includes/gw_hdf5.h
scilab/modules/hdf5/sci_gateway/c/gw_hdf5.c
scilab/modules/hdf5/sci_gateway/cpp/sci_h5dump.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/hdf5_gateway.xml
scilab/modules/hdf5/src/cpp/H5Attribute.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Attribute.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5AttributesList.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5AttributesList.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5BasicData.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5BitfieldData.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5CompoundData.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Data.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5DataConverter.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5DataConverter.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5DataFactory.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5DataFactory.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Dataset.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Dataset.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5DatasetsList.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5DatasetsList.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Dataspace.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Dataspace.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Exception.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5File.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5File.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5FloatData.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Group.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Group.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5GroupsList.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5GroupsList.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5LinksList.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5LinksList.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5ListObject.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5NamedObjectsList.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Object.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Object.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5OpaqueData.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5ReferenceData.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5StringData.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5TimeData.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Type.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Type.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5TypesList.hxx [new file with mode: 0644]

index 694a9ea..4f42bc7 100644 (file)
@@ -22,14 +22,25 @@ src/c/h5_readDataFromFile_v1.c \
 src/cpp/import_from_hdf5_v1.cpp \
 src/cpp/listvar_in_hdf5_v1.cpp
 
-
+HDF5_CXX_SOURCES = src/cpp/H5Attribute.cpp \
+                  src/cpp/H5AttributesList.cpp \
+                  src/cpp/H5DataConverter.cpp \
+                  src/cpp/H5Dataset.cpp \
+                  src/cpp/H5Dataspace.cpp \
+                  src/cpp/H5File.cpp \
+                  src/cpp/H5Group.cpp \
+                  src/cpp/H5LinksList.cpp \
+                  src/cpp/H5Object.cpp \
+                  src/cpp/H5Type.cpp \
+                  src/cpp/H5DataFactory.cpp
 
 GATEWAY_C_SOURCES = sci_gateway/c/gw_hdf5.c
 
 GATEWAY_CXX_SOURCES = sci_gateway/cpp/sci_export_to_hdf5.cpp \
 sci_gateway/cpp/sci_import_from_hdf5.cpp \
 sci_gateway/cpp/sci_is_hdf5_file.cpp \
-sci_gateway/cpp/sci_listvar_in_hdf5.cpp
+sci_gateway/cpp/sci_listvar_in_hdf5.cpp \
+sci_gateway/cpp/sci_h5dump.cpp
 
 if GIWS
 BUILT_SOURCES=giws
@@ -67,7 +78,7 @@ noinst_LTLIBRARIES += libscihdf5-algo.la
 
 libscihdf5_la_LDFLAGS = $(HDF5_LIBS) $(AM_LDFLAGS)
 
-libscihdf5_algo_la_SOURCES = $(HDF5_SOURCES)
+libscihdf5_algo_la_SOURCES = $(HDF5_SOURCES) $(HDF5_CXX_SOURCES)
 libscihdf5_la_SOURCES = $(GATEWAY_CXX_SOURCES) $(GATEWAY_C_SOURCES)
 libscihdf5_algo_la_CPPFLAGS = $(libscihdf5_la_CPPFLAGS)
 
index 8f8ec47..ac6ef85 100644 (file)
@@ -144,15 +144,25 @@ am__objects_1 = libscihdf5_algo_la-h5_fileManagement.lo \
        libscihdf5_algo_la-h5_readDataFromFile_v1.lo \
        libscihdf5_algo_la-import_from_hdf5_v1.lo \
        libscihdf5_algo_la-listvar_in_hdf5_v1.lo
-am_libscihdf5_algo_la_OBJECTS = $(am__objects_1)
+am__objects_2 = libscihdf5_algo_la-H5Attribute.lo \
+       libscihdf5_algo_la-H5AttributesList.lo \
+       libscihdf5_algo_la-H5DataConverter.lo \
+       libscihdf5_algo_la-H5Dataset.lo \
+       libscihdf5_algo_la-H5Dataspace.lo libscihdf5_algo_la-H5File.lo \
+       libscihdf5_algo_la-H5Group.lo \
+       libscihdf5_algo_la-H5LinksList.lo \
+       libscihdf5_algo_la-H5Object.lo libscihdf5_algo_la-H5Type.lo \
+       libscihdf5_algo_la-H5DataFactory.lo
+am_libscihdf5_algo_la_OBJECTS = $(am__objects_1) $(am__objects_2)
 libscihdf5_algo_la_OBJECTS = $(am_libscihdf5_algo_la_OBJECTS)
 libscihdf5_la_DEPENDENCIES = libscihdf5-algo.la
-am__objects_2 = libscihdf5_la-sci_export_to_hdf5.lo \
+am__objects_3 = libscihdf5_la-sci_export_to_hdf5.lo \
        libscihdf5_la-sci_import_from_hdf5.lo \
        libscihdf5_la-sci_is_hdf5_file.lo \
-       libscihdf5_la-sci_listvar_in_hdf5.lo
-am__objects_3 = libscihdf5_la-gw_hdf5.lo
-am_libscihdf5_la_OBJECTS = $(am__objects_2) $(am__objects_3)
+       libscihdf5_la-sci_listvar_in_hdf5.lo \
+       libscihdf5_la-sci_h5dump.lo
+am__objects_4 = libscihdf5_la-gw_hdf5.lo
+am_libscihdf5_la_OBJECTS = $(am__objects_3) $(am__objects_4)
 libscihdf5_la_OBJECTS = $(am_libscihdf5_la_OBJECTS)
 libscihdf5_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
@@ -454,11 +464,24 @@ src/c/h5_readDataFromFile_v1.c \
 src/cpp/import_from_hdf5_v1.cpp \
 src/cpp/listvar_in_hdf5_v1.cpp
 
+HDF5_CXX_SOURCES = src/cpp/H5Attribute.cpp \
+                  src/cpp/H5AttributesList.cpp \
+                  src/cpp/H5DataConverter.cpp \
+                  src/cpp/H5Dataset.cpp \
+                  src/cpp/H5Dataspace.cpp \
+                  src/cpp/H5File.cpp \
+                  src/cpp/H5Group.cpp \
+                  src/cpp/H5LinksList.cpp \
+                  src/cpp/H5Object.cpp \
+                  src/cpp/H5Type.cpp \
+                  src/cpp/H5DataFactory.cpp
+
 GATEWAY_C_SOURCES = sci_gateway/c/gw_hdf5.c
 GATEWAY_CXX_SOURCES = sci_gateway/cpp/sci_export_to_hdf5.cpp \
 sci_gateway/cpp/sci_import_from_hdf5.cpp \
 sci_gateway/cpp/sci_is_hdf5_file.cpp \
-sci_gateway/cpp/sci_listvar_in_hdf5.cpp
+sci_gateway/cpp/sci_listvar_in_hdf5.cpp \
+sci_gateway/cpp/sci_h5dump.cpp
 
 @GIWS_TRUE@BUILT_SOURCES = giws
 
@@ -487,7 +510,7 @@ noinst_LTLIBRARIES = libscihdf5-algo.la
 
 # When Scilab is built with HDF5, we need some libraries for a workaround
 libscihdf5_la_LDFLAGS = $(HDF5_LIBS) $(AM_LDFLAGS)
-libscihdf5_algo_la_SOURCES = $(HDF5_SOURCES)
+libscihdf5_algo_la_SOURCES = $(HDF5_SOURCES) $(HDF5_CXX_SOURCES)
 libscihdf5_la_SOURCES = $(GATEWAY_CXX_SOURCES) $(GATEWAY_C_SOURCES)
 libscihdf5_algo_la_CPPFLAGS = $(libscihdf5_la_CPPFLAGS)
 
@@ -727,6 +750,17 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5Attribute.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5AttributesList.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5DataConverter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5DataFactory.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5Dataset.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5Dataspace.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5File.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5Group.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5LinksList.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5Object.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5Type.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-h5_fileManagement.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-h5_readDataFromFile.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-h5_readDataFromFile_v1.Plo@am__quote@
@@ -735,6 +769,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-listvar_in_hdf5_v1.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-gw_hdf5.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_export_to_hdf5.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_h5dump.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_import_from_hdf5.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_is_hdf5_file.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_listvar_in_hdf5.Plo@am__quote@
@@ -830,6 +865,83 @@ libscihdf5_algo_la-listvar_in_hdf5_v1.lo: src/cpp/listvar_in_hdf5_v1.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-listvar_in_hdf5_v1.lo `test -f 'src/cpp/listvar_in_hdf5_v1.cpp' || echo '$(srcdir)/'`src/cpp/listvar_in_hdf5_v1.cpp
 
+libscihdf5_algo_la-H5Attribute.lo: src/cpp/H5Attribute.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5Attribute.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5Attribute.Tpo -c -o libscihdf5_algo_la-H5Attribute.lo `test -f 'src/cpp/H5Attribute.cpp' || echo '$(srcdir)/'`src/cpp/H5Attribute.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5Attribute.Tpo $(DEPDIR)/libscihdf5_algo_la-H5Attribute.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5Attribute.cpp' object='libscihdf5_algo_la-H5Attribute.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5Attribute.lo `test -f 'src/cpp/H5Attribute.cpp' || echo '$(srcdir)/'`src/cpp/H5Attribute.cpp
+
+libscihdf5_algo_la-H5AttributesList.lo: src/cpp/H5AttributesList.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5AttributesList.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5AttributesList.Tpo -c -o libscihdf5_algo_la-H5AttributesList.lo `test -f 'src/cpp/H5AttributesList.cpp' || echo '$(srcdir)/'`src/cpp/H5AttributesList.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5AttributesList.Tpo $(DEPDIR)/libscihdf5_algo_la-H5AttributesList.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5AttributesList.cpp' object='libscihdf5_algo_la-H5AttributesList.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5AttributesList.lo `test -f 'src/cpp/H5AttributesList.cpp' || echo '$(srcdir)/'`src/cpp/H5AttributesList.cpp
+
+libscihdf5_algo_la-H5DataConverter.lo: src/cpp/H5DataConverter.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5DataConverter.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5DataConverter.Tpo -c -o libscihdf5_algo_la-H5DataConverter.lo `test -f 'src/cpp/H5DataConverter.cpp' || echo '$(srcdir)/'`src/cpp/H5DataConverter.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5DataConverter.Tpo $(DEPDIR)/libscihdf5_algo_la-H5DataConverter.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5DataConverter.cpp' object='libscihdf5_algo_la-H5DataConverter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5DataConverter.lo `test -f 'src/cpp/H5DataConverter.cpp' || echo '$(srcdir)/'`src/cpp/H5DataConverter.cpp
+
+libscihdf5_algo_la-H5Dataset.lo: src/cpp/H5Dataset.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5Dataset.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5Dataset.Tpo -c -o libscihdf5_algo_la-H5Dataset.lo `test -f 'src/cpp/H5Dataset.cpp' || echo '$(srcdir)/'`src/cpp/H5Dataset.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5Dataset.Tpo $(DEPDIR)/libscihdf5_algo_la-H5Dataset.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5Dataset.cpp' object='libscihdf5_algo_la-H5Dataset.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5Dataset.lo `test -f 'src/cpp/H5Dataset.cpp' || echo '$(srcdir)/'`src/cpp/H5Dataset.cpp
+
+libscihdf5_algo_la-H5Dataspace.lo: src/cpp/H5Dataspace.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5Dataspace.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5Dataspace.Tpo -c -o libscihdf5_algo_la-H5Dataspace.lo `test -f 'src/cpp/H5Dataspace.cpp' || echo '$(srcdir)/'`src/cpp/H5Dataspace.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5Dataspace.Tpo $(DEPDIR)/libscihdf5_algo_la-H5Dataspace.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5Dataspace.cpp' object='libscihdf5_algo_la-H5Dataspace.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5Dataspace.lo `test -f 'src/cpp/H5Dataspace.cpp' || echo '$(srcdir)/'`src/cpp/H5Dataspace.cpp
+
+libscihdf5_algo_la-H5File.lo: src/cpp/H5File.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5File.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5File.Tpo -c -o libscihdf5_algo_la-H5File.lo `test -f 'src/cpp/H5File.cpp' || echo '$(srcdir)/'`src/cpp/H5File.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5File.Tpo $(DEPDIR)/libscihdf5_algo_la-H5File.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5File.cpp' object='libscihdf5_algo_la-H5File.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5File.lo `test -f 'src/cpp/H5File.cpp' || echo '$(srcdir)/'`src/cpp/H5File.cpp
+
+libscihdf5_algo_la-H5Group.lo: src/cpp/H5Group.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5Group.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5Group.Tpo -c -o libscihdf5_algo_la-H5Group.lo `test -f 'src/cpp/H5Group.cpp' || echo '$(srcdir)/'`src/cpp/H5Group.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5Group.Tpo $(DEPDIR)/libscihdf5_algo_la-H5Group.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5Group.cpp' object='libscihdf5_algo_la-H5Group.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5Group.lo `test -f 'src/cpp/H5Group.cpp' || echo '$(srcdir)/'`src/cpp/H5Group.cpp
+
+libscihdf5_algo_la-H5LinksList.lo: src/cpp/H5LinksList.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5LinksList.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5LinksList.Tpo -c -o libscihdf5_algo_la-H5LinksList.lo `test -f 'src/cpp/H5LinksList.cpp' || echo '$(srcdir)/'`src/cpp/H5LinksList.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5LinksList.Tpo $(DEPDIR)/libscihdf5_algo_la-H5LinksList.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5LinksList.cpp' object='libscihdf5_algo_la-H5LinksList.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5LinksList.lo `test -f 'src/cpp/H5LinksList.cpp' || echo '$(srcdir)/'`src/cpp/H5LinksList.cpp
+
+libscihdf5_algo_la-H5Object.lo: src/cpp/H5Object.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5Object.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5Object.Tpo -c -o libscihdf5_algo_la-H5Object.lo `test -f 'src/cpp/H5Object.cpp' || echo '$(srcdir)/'`src/cpp/H5Object.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5Object.Tpo $(DEPDIR)/libscihdf5_algo_la-H5Object.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5Object.cpp' object='libscihdf5_algo_la-H5Object.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5Object.lo `test -f 'src/cpp/H5Object.cpp' || echo '$(srcdir)/'`src/cpp/H5Object.cpp
+
+libscihdf5_algo_la-H5Type.lo: src/cpp/H5Type.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5Type.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5Type.Tpo -c -o libscihdf5_algo_la-H5Type.lo `test -f 'src/cpp/H5Type.cpp' || echo '$(srcdir)/'`src/cpp/H5Type.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5Type.Tpo $(DEPDIR)/libscihdf5_algo_la-H5Type.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5Type.cpp' object='libscihdf5_algo_la-H5Type.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5Type.lo `test -f 'src/cpp/H5Type.cpp' || echo '$(srcdir)/'`src/cpp/H5Type.cpp
+
+libscihdf5_algo_la-H5DataFactory.lo: src/cpp/H5DataFactory.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5DataFactory.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5DataFactory.Tpo -c -o libscihdf5_algo_la-H5DataFactory.lo `test -f 'src/cpp/H5DataFactory.cpp' || echo '$(srcdir)/'`src/cpp/H5DataFactory.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5DataFactory.Tpo $(DEPDIR)/libscihdf5_algo_la-H5DataFactory.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5DataFactory.cpp' object='libscihdf5_algo_la-H5DataFactory.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5DataFactory.lo `test -f 'src/cpp/H5DataFactory.cpp' || echo '$(srcdir)/'`src/cpp/H5DataFactory.cpp
+
 libscihdf5_la-sci_export_to_hdf5.lo: sci_gateway/cpp/sci_export_to_hdf5.cpp
 @am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_export_to_hdf5.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_export_to_hdf5.Tpo -c -o libscihdf5_la-sci_export_to_hdf5.lo `test -f 'sci_gateway/cpp/sci_export_to_hdf5.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_export_to_hdf5.cpp
 @am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_export_to_hdf5.Tpo $(DEPDIR)/libscihdf5_la-sci_export_to_hdf5.Plo
@@ -858,6 +970,13 @@ libscihdf5_la-sci_listvar_in_hdf5.lo: sci_gateway/cpp/sci_listvar_in_hdf5.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_listvar_in_hdf5.lo `test -f 'sci_gateway/cpp/sci_listvar_in_hdf5.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_listvar_in_hdf5.cpp
 
+libscihdf5_la-sci_h5dump.lo: sci_gateway/cpp/sci_h5dump.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_h5dump.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_h5dump.Tpo -c -o libscihdf5_la-sci_h5dump.lo `test -f 'sci_gateway/cpp/sci_h5dump.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5dump.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_h5dump.Tpo $(DEPDIR)/libscihdf5_la-sci_h5dump.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_h5dump.cpp' object='libscihdf5_la-sci_h5dump.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_h5dump.lo `test -f 'sci_gateway/cpp/sci_h5dump.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5dump.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
diff --git a/scilab/modules/hdf5/includes/HDF5Objects.h b/scilab/modules/hdf5/includes/HDF5Objects.h
new file mode 100644 (file)
index 0000000..5c87892
--- /dev/null
@@ -0,0 +1 @@
+#define HDF5OBJECTS_DEBUG
index 264cafd..58b2574 100644 (file)
@@ -21,6 +21,7 @@ HDF5_SCILAB_IMPEXP int sci_export_to_hdf5(char *fname,unsigned long fname_len);
 HDF5_SCILAB_IMPEXP int sci_import_from_hdf5(char *fname,unsigned long fname_len);
 HDF5_SCILAB_IMPEXP int sci_listvar_in_hdf5(char *fname,unsigned long fname_len);
 HDF5_SCILAB_IMPEXP int sci_is_hdf5_file(char *fname,unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5dump(char *fname,unsigned long fname_len);
 /*--------------------------------------------------------------------------*/ 
 #endif /* __GW_HDF5_H__ */
 /*--------------------------------------------------------------------------*/
index 5b065e4..b7b638d 100644 (file)
@@ -23,7 +23,8 @@ static gw_generic_table Tab[] =
        {sci_export_to_hdf5, "export_to_hdf5"},
        {sci_import_from_hdf5, "import_from_hdf5"},
        {sci_listvar_in_hdf5, "listvar_in_hdf5"},
-       {sci_is_hdf5_file, "is_hdf5_file"}
+       {sci_is_hdf5_file, "is_hdf5_file"},
+       {sci_h5dump, "h5dump"}
 };
 /*--------------------------------------------------------------------------*/ 
 int gw_hdf5(void)
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_h5dump.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_h5dump.cpp
new file mode 100644 (file)
index 0000000..b8b7e0a
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+extern "C"
+{
+#include "gw_hdf5.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "localization.h"
+#include "sciprint.h"
+}
+
+#include "H5File.hxx"
+
+using namespace org_modules_hdf5;
+
+/*--------------------------------------------------------------------------*/
+int sci_h5dump(char *fname, unsigned long fname_len)
+{
+    H5File * h5file = 0;
+    SciErr err;
+    int * addr = 0;
+    char * path = 0;
+
+    CheckLhs(1, 1);
+    CheckRhs(1, 1);
+
+    err = getVarAddressFromPosition(pvApiCtx, 1, &addr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+        return 0;
+    }
+
+    if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+    {
+        Scierror(999, gettext("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
+        return 0;
+    }
+
+    if (getAllocatedSingleString(pvApiCtx, addr, &path) != 0)
+    {
+        Scierror(999, _("%s: No more memory.\n"), fname);
+        return 0;
+    }
+
+
+    try
+    {
+       h5file = new H5File((const char *)path);
+       freeAllocatedSingleString(path);
+    }
+    catch (const H5Exception & e)
+    {
+       Scierror(999, _("%s: %s\n"), fname, e.what());
+       freeAllocatedSingleString(path);
+       return 0;
+    }
+
+    try
+    {
+       sciprint("%s\n", h5file->toString(0).c_str());
+       delete h5file;
+    }
+     catch (const H5Exception & e)
+    {
+       Scierror(999, _("%s: %s\n"), fname, e.what());
+       delete h5file;
+       return 0;
+    }
+
+    LhsVar(1) = 0;
+    PutLhsVar();
+
+    return 0;
+}
+
+/*--------------------------------------------------------------------------*/
index 75a3305..8fe5cd3 100644 (file)
@@ -33,5 +33,5 @@
 <PRIMITIVE gatewayId="62" primitiveId="2" primitiveName="import_from_hdf5" />
 <PRIMITIVE gatewayId="62" primitiveId="3" primitiveName="listvar_in_hdf5" />
 <PRIMITIVE gatewayId="62" primitiveId="4" primitiveName="is_hdf5_file" />
-
+<PRIMITIVE gatewayId="62" primitiveId="5" primitiveName="h5dump" />
 </GATEWAY>
diff --git a/scilab/modules/hdf5/src/cpp/H5Attribute.cpp b/scilab/modules/hdf5/src/cpp/H5Attribute.cpp
new file mode 100644 (file)
index 0000000..cf023b4
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5Attribute.hxx"
+#include "H5DataFactory.hxx"
+
+namespace org_modules_hdf5
+{
+
+    H5Attribute::H5Attribute(H5Object & _parent, const hid_t parentId, const unsigned int pos) : H5Object(_parent)
+    {
+        attr = H5Aopen_by_idx(parentId, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)pos, H5P_DEFAULT, H5P_DEFAULT);
+        if (attr < 0)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot open attribute at position %u."), pos);
+        }
+
+        ssize_t size = H5Aget_name(attr, 0, 0);
+        if (size <= 0)
+        {
+            name = strdup("");
+        }
+        else
+        {
+           char * _name = (char *)MALLOC(sizeof(char) * (size + 1));
+            H5Aget_name(attr, size + 1, _name);
+           name = const_cast<const char *>(_name);
+        }
+    }
+
+    H5Attribute::~H5Attribute()
+    {
+        if (attr >= 0)
+        {
+            H5Aclose(attr);
+        }
+        FREE(const_cast<char *>(name));
+    }
+
+    H5Data & H5Attribute::getData()
+    {
+       return H5DataFactory::getData(*this, attr, true);
+    }
+
+    H5Type & H5Attribute::getDataType()
+    {
+        hid_t type = H5Aget_type(attr);
+        if (type < 0)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot get the attribute type"));
+        }
+
+        return *new H5Type(*this, type);
+    }
+
+    H5Dataspace & H5Attribute::getSpace()
+    {
+        hid_t space = H5Aget_space(attr);
+        if (space < 0)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot get the attribute dataspace"));
+        }
+
+        return *new H5Dataspace(*this, space);
+    }
+
+    std::string H5Attribute::dump(const unsigned int indentLevel) const
+    {
+       std::ostringstream os;
+       const H5Type & type = const_cast<H5Attribute *>(this)->getDataType();
+       const H5Dataspace & space = const_cast<H5Attribute *>(this)->getSpace();
+       const H5Data & data = const_cast<H5Attribute *>(this)->getData();
+
+       os << H5Object::getIndentString(indentLevel) << "ATTRIBUTE \"" << name << "\" {" << std::endl
+          << type.dump(indentLevel + 1)
+          << space.dump(indentLevel + 1)
+          << data.dump(indentLevel + 1)
+          << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+
+       delete &type;
+       delete &space;
+       delete &data;
+
+       return os.str();
+    }
+
+    std::string H5Attribute::toString(const unsigned int indentLevel) const
+    {
+       std::ostringstream os;
+       const std::string indentString = H5Object::getIndentString(indentLevel);
+       const H5Type & type = const_cast<H5Attribute *>(this)->getDataType();
+       
+       os << indentString << _("Filename") << ": " << getFile().getFileName() << std::endl
+          << indentString << _("Attribute name") << ": " << name << std::endl
+          << indentString << _("Attribute path") << ": " << getCompletePath() << std::endl
+          << indentString << _("Value class") << ": " << type.getClassName();
+
+       delete &type;
+
+       return os.str();
+    }
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5Attribute.hxx b/scilab/modules/hdf5/src/cpp/H5Attribute.hxx
new file mode 100644 (file)
index 0000000..543213e
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5ATTRIBUTES_HXX__
+#define __H5ATTRIBUTES_HXX__
+
+#include "H5Object.hxx"
+#include "H5Type.hxx"
+#include "H5Data.hxx"
+#include "H5Dataspace.hxx"
+#include "H5File.hxx"
+
+namespace org_modules_hdf5
+{
+    class H5Attribute : protected H5Object
+    {
+       hid_t attr;
+       const char * name;
+
+    public :
+       
+       H5Attribute(H5Object & _parent, const hid_t parentId, const unsigned int pos);
+       
+       ~H5Attribute();
+
+       hid_t getH5Id() const { return attr; }
+       virtual std::string getName() const { return std::string(name); }
+       H5Data & getData();
+       H5Type & getDataType();
+       H5Dataspace & getSpace();
+
+       virtual std::string dump(const unsigned int indentLevel) const; 
+       virtual std::string toString(const unsigned int indentLevel) const; 
+    };
+}
+
+#endif // __H5ATTRIBUTE_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5AttributesList.cpp b/scilab/modules/hdf5/src/cpp/H5AttributesList.cpp
new file mode 100644 (file)
index 0000000..98474af
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5AttributesList.hxx"
+#include "H5Attribute.hxx"
+
+namespace org_modules_hdf5
+{
+    
+    H5AttributesList::H5AttributesList(H5Object & _parent) : H5ListObject(_parent) { }
+
+    H5AttributesList::~H5AttributesList() { }
+
+    const unsigned int H5AttributesList::getSize() const
+    {
+       H5O_info_t info;
+       herr_t err = H5Oget_info(parent.getH5Id(), &info);
+       
+       if (err < 0)
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Cannot get the size of attribute list."));
+       }
+       
+       return (unsigned int)info.num_attrs;
+    }
+
+    void H5AttributesList::setObject(const unsigned int pos, H5Attribute & attribute)
+    {
+       
+    }
+
+    H5Attribute & H5AttributesList::getObject(const int pos)
+    {
+       return getObject(pos, true);
+    }
+
+    H5Attribute & H5AttributesList::getObject(const int pos, const bool checkPos)
+    {
+       if (checkPos)
+       {
+           unsigned int size = getSize();
+           if (pos < 0 || pos >= size)
+           {
+               throw H5Exception(__LINE__, __FILE__, _("Invalid index %u: must be between 0 and %u."), pos, size);
+           }
+       }
+
+       return *new H5Attribute(parent, parent.getH5Id(), (const unsigned int)pos);
+    }
+
+    std::string H5AttributesList::dump(const unsigned int indentLevel) const
+    {
+       std::ostringstream os;
+       unsigned int size = getSize();
+       
+       for (unsigned int i = 0; i < size; i++)
+       {
+           const H5Attribute & attr = const_cast<H5AttributesList *>(this)->getObject(i, false);
+           os << attr.dump(indentLevel);
+
+           delete &attr;
+       }
+       
+       return os.str();
+    }
+
+    std::string H5AttributesList::toString(const unsigned int indentLevel) const
+    {
+       std::ostringstream os;
+       std::string indentString = H5Object::getIndentString(indentLevel);
+       
+       os << indentString << _("Filename") << ": " << getFile().getFileName() << std::endl
+          << indentString << _("Number of attributes") << ": " << getSize();
+
+       return os.str();
+    }
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5AttributesList.hxx b/scilab/modules/hdf5/src/cpp/H5AttributesList.hxx
new file mode 100644 (file)
index 0000000..3a505e0
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5ATTRIBUTESLIST_HXX__
+#define __H5ATTRIBUTESLIST_HXX__
+
+#include "H5ListObject.hxx"
+
+namespace org_modules_hdf5
+{
+    class H5Attribute;
+
+    class H5AttributesList : protected H5ListObject<H5Attribute>
+    {
+
+    public :
+       
+       H5AttributesList(H5Object & _parent);
+       
+       ~H5AttributesList();
+
+       void setObject(const unsigned int pos, H5Attribute & attribute);
+       H5Attribute & getObject(const int pos);
+       const unsigned int getSize() const;
+       
+       virtual std::string dump(const unsigned int indentLevel) const;
+        virtual std::string toString(const unsigned int indentLevel) const;
+
+    private:
+       H5Attribute & getObject(const int pos, const bool checkPos);
+    };
+}
+
+#endif // __H5ATTRIBUTESLIST_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5BasicData.hxx b/scilab/modules/hdf5/src/cpp/H5BasicData.hxx
new file mode 100644 (file)
index 0000000..5a165b6
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5BASICDATA_HXX__
+#define __H5BASICDATA_HXX__
+
+#include "H5Data.hxx"
+#include "H5Object.hxx"
+#include "H5DataConverter.hxx"
+
+#define __SCILAB_STACK_CREATOR__(U,NAME) static void create(void * pvApiCtx, const int position, const int rows, const int cols, U * ptr, int * list, const int listPosition) \
+    {                                                                   \
+        SciErr err;                                                     \
+        if (list)                                                       \
+        {                                                               \
+            err = createMatrixOf##NAME##InList(pvApiCtx, position, list, listPosition, rows, cols, ptr); \
+        }                                                               \
+        else                                                            \
+        {                                                               \
+            err = createMatrixOf##NAME(pvApiCtx, position, rows, cols, ptr); \
+        }                                                               \
+        if (err.iErr)                                                   \
+        {                                                               \
+            throw H5Exception(__LINE__, __FILE__, "Cannot allocate memory"); \
+        }                                                               \
+    }
+
+#define __SCILAB_STACK_ALLOCATOR__(U,NAME) static void alloc(void * pvApiCtx, const int position, const int rows, const int cols, int * list, const int listPosition, U ** ptr) \
+    {                                                                   \
+        SciErr err;                                                     \
+        if (list)                                                       \
+        {                                                               \
+            err = allocMatrixOf##NAME##InList(pvApiCtx, position, list, listPosition, rows, cols, ptr); \
+        }                                                               \
+        else                                                            \
+        {                                                               \
+            err = allocMatrixOf##NAME(pvApiCtx, position, rows, cols, ptr); \
+        }                                                               \
+        if (err.iErr)                                                   \
+        {                                                               \
+            throw H5Exception(__LINE__, __FILE__, "Cannot allocate memory"); \
+        }                                                               \
+    }
+
+#define __SCILAB_ALLOCATORS_CREATORS__(U,NAME) __SCILAB_STACK_CREATOR__(U,NAME) \
+    __SCILAB_STACK_ALLOCATOR__(U,NAME)
+
+
+namespace org_modules_hdf5
+{
+    template<typename T>
+    class H5BasicData : public H5Data
+    {
+
+    protected:
+
+        T * transformedData;
+
+    public:
+
+        H5BasicData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, T * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5Data(_parent, _totalSize, _dataSize, _ndims, _dims, static_cast<void *>(_data), _stride, _offset, _dataOwner), transformedData(0)
+            {
+
+            }
+
+        virtual ~H5BasicData()
+            {
+                if (transformedData)
+                {
+                    delete[] transformedData;
+                }
+            }
+
+
+
+        virtual void copyData(T * dest) const
+            {
+                if (dest)
+                {
+                    if (stride == -1)
+                    {
+                        memcpy(static_cast<void *>(dest), data, totalSize * sizeof(T));
+                    }
+                    else if (transformedData)
+                    {
+                        memcpy(static_cast<void *>(dest), static_cast<void *>(transformedData), totalSize * sizeof(T));
+                    }
+                    else
+                    {
+                        char * cdata = static_cast<char *>(data) + offset;
+                        for (int i = 0; i < totalSize; i++)
+                        {
+                            dest[i] = *((T *)cdata);
+                            cdata += stride;
+                        }
+                    }
+                }
+                else
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot copy data to an empty pointer"));
+                }
+            }
+
+        virtual void * getData() const
+            {
+                if (stride == -1)
+                {
+                    return data;
+                }
+                else
+                {
+                    if (!transformedData)
+                    {
+                        const_cast<H5BasicData *>(this)->transformedData = new T[totalSize];
+                        copyData(transformedData);
+                    }
+
+                    return static_cast<void *>(transformedData);
+                }
+            }
+
+        virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const
+            {
+                SciErr err;
+                T * newData = 0;
+                if (ndims == 1)
+                {
+                    alloc(pvApiCtx, lhsPosition, 1, *dims, parentList, listPosition, &newData);
+                    copyData(newData);
+                }
+                else
+                {
+                    if (ndims == 2)
+                    {
+                        alloc(pvApiCtx, lhsPosition, dims[0], dims[1], parentList, listPosition, &newData);
+                        H5DataConverter::C2FHypermatrix(2, dims, 0, static_cast<T *>(getData()), newData);
+                    }
+                    else
+                    {
+                        int * list = getHypermatrix(pvApiCtx, lhsPosition, parentList, listPosition);
+                       alloc(pvApiCtx, lhsPosition, 1, totalSize, list, 3, &newData);
+                        H5DataConverter::C2FHypermatrix(ndims, dims, totalSize, static_cast<T *>(getData()), newData);
+                    }
+                }
+            }
+
+        virtual std::string dump(const unsigned int indentLevel) const
+            {
+                return H5DataConverter::dump(indentLevel, ndims, dims, static_cast<T *>(getData()), *this);
+            }
+
+        __SCILAB_ALLOCATORS_CREATORS__(double,Double)
+        __SCILAB_ALLOCATORS_CREATORS__(char,Integer8)
+        __SCILAB_ALLOCATORS_CREATORS__(unsigned char,UnsignedInteger8)
+        __SCILAB_ALLOCATORS_CREATORS__(short,Integer16)
+        __SCILAB_ALLOCATORS_CREATORS__(unsigned short,UnsignedInteger16)
+        __SCILAB_ALLOCATORS_CREATORS__(int,Integer32)
+        __SCILAB_ALLOCATORS_CREATORS__(unsigned int,UnsignedInteger32)
+
+#ifdef  _SCILAB_INT64__
+        __SCILAB_ALLOCATORS_CREATORS__(long long,Integer64)
+        __SCILAB_ALLOCATORS_CREATORS__(unsigned long long,UnsignedInteger64)
+#endif
+
+        __SCILAB_STACK_CREATOR__(char *,String)
+    };
+}
+
+
+#undef __SCILAB_STACK_CREATOR__
+#undef __SCILAB_STACK_ALLOCATOR__
+#undef __SCILAB_LIST_CREATOR__
+#undef __SCILAB_LIST_ALLOCATOR__
+#undef __SCILAB_ALLOCATORS_CREATORS__
+
+#endif // __H5BASICDATA_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5BitfieldData.hxx b/scilab/modules/hdf5/src/cpp/H5BitfieldData.hxx
new file mode 100644 (file)
index 0000000..cb411d4
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5BITFIELDDATA_HXX__
+#define __H5BITFIELDDATA_HXX__
+
+#include "H5Data.hxx"
+
+namespace org_modules_hdf5
+{
+
+    class H5BitfieldData : public H5BasicData<char>
+    {
+       
+    public:
+       
+       H5BitfieldData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5BasicData(_parent, _totalSize, _dataSize, _ndims + 1, _dims, _data, _stride, _offset, _dataOwner)
+           {
+               //dims[ndims - 1] = dataSize;
+           }
+
+       virtual ~H5BitfieldData()
+           {
+           }
+    };
+}
+
+#endif // __H5BITFIELDDATA_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5CompoundData.hxx b/scilab/modules/hdf5/src/cpp/H5CompoundData.hxx
new file mode 100644 (file)
index 0000000..7f08381
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5COMPOUNDDATA_HXX__
+#define __H5COMPOUNDDATA_HXX__
+
+#include "H5Data.hxx"
+
+namespace org_modules_hdf5
+{
+
+    class H5CompoundData : public H5BasicData<char>
+    {
+       const unsigned int nfields;
+       const std::string * fieldsname;
+       H5Data ** fieldsvalue;
+       
+    public:
+       
+       H5CompoundData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const unsigned int _nfields, std::string * _fieldsname, H5Data ** _fieldsvalue, char * _data, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _data, -1, 0, _dataOwner), nfields(_nfields), fieldsname(_fieldsname), fieldsvalue(_fieldsvalue)  
+           {
+
+           }
+
+       virtual ~H5CompoundData()
+           {
+               delete[] fieldsname;
+               delete[] fieldsvalue;
+           }
+
+       H5Data & getData(const std::string fieldname)
+           {
+               for (unsigned int i = 0; i < nfields; i++)
+               {
+                   if (fieldname == fieldsname[i])
+                   {
+                       return *fieldsvalue[i];
+                   }
+               }
+
+               throw H5Exception(__LINE__, __FILE__, _("Invalid field name: %s"), fieldname.c_str());
+           }
+
+       virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const
+           {
+               static int structdims[2] = { 1, 1 };
+               const char ** _fieldsname = new const char *[nfields + 2];
+               SciErr err;
+               int * scilabStruct = 0;
+
+               _fieldsname[0] = "st";
+               _fieldsname[1] = "dims";
+               for (int i = 0; i < nfields; i++)
+               {
+                   _fieldsname[i + 2] = fieldsname[i].c_str();
+               }
+               
+                
+               if (parentList)
+                {
+                    err = createMListInList(pvApiCtx, lhsPosition, parentList, listPosition, nfields + 1, &scilabStruct);
+                }
+                else
+                {
+                    err = createMList(pvApiCtx, lhsPosition, nfields + 1, &scilabStruct);
+                }
+
+                if (err.iErr)
+                {
+                   delete[] _fieldsname;
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create a struct on the stack"));
+                }
+
+                err = createMatrixOfStringInList(pvApiCtx, lhsPosition, scilabStruct, 1, 1, nfields + 2, _fieldsname);
+               delete[] _fieldsname;
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create a struct on the stack"));
+                }
+
+                err = createMatrixOfInteger32InList(pvApiCtx, lhsPosition, scilabStruct, 2, 1, 2, structdims);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create a struct on the stack"));
+                }
+
+               for (int i = 0; i < nfields; i++)
+               {
+                   fieldsvalue[i]->toScilab(pvApiCtx, lhsPosition, scilabStruct, i + 3);
+               }
+           }
+    };
+}
+
+#endif // __H5COMPOUNDDATA_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5Data.hxx b/scilab/modules/hdf5/src/cpp/H5Data.hxx
new file mode 100644 (file)
index 0000000..2a7205c
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5DATA_HXX__
+#define __H5DATA_HXX__
+
+#include "H5Data.hxx"
+#include "H5Object.hxx"
+
+namespace org_modules_hdf5
+{
+    class H5Data : public H5Object
+    {
+
+    protected:
+
+        void * data;
+        const hsize_t totalSize;
+        const hsize_t dataSize;
+        const hsize_t ndims;
+        const hsize_t * dims;
+        const hsize_t stride;
+        const size_t offset;
+        const bool dataOwner;
+
+    public:
+
+        H5Data(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, void * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5Object(_parent), totalSize(_totalSize), dataSize(_dataSize), ndims(_ndims), dims(_dims), data(_data), stride(_stride), offset(_offset), dataOwner(_dataOwner)
+            {
+
+            }
+
+        virtual ~H5Data()
+            {
+                if (dataOwner)
+                {
+                    delete[] dims;
+                    FREE(data);
+                }
+            }
+
+        virtual void * getData() const { return data; }
+
+       virtual void printData(std::ostream & os, void * data) const { }
+
+        virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const = 0;
+
+    protected:
+
+        int * getHypermatrix(void * pvApiCtx, const int position, int * parentList = 0, const int listPosition = 0) const
+            {
+                static const char * hypermat[3] = {"hm", "dims", "entries"};
+
+                int * list = 0;
+                SciErr err;
+                if (parentList)
+                {
+                    err = createMListInList(pvApiCtx, position, parentList, listPosition, 3, &list);
+                }
+                else
+                {
+                    err = createMList(pvApiCtx, position, 3, &list);
+                }
+
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                }
+
+                err = createMatrixOfStringInList(pvApiCtx, position, list, 1, 1, 3, hypermat);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                }
+
+                if (sizeof(int) == sizeof(hsize_t))
+                {
+                    err = createMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, (int *)dims);
+                    if (err.iErr)
+                    {
+                        throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                    }
+                }
+                else
+                {
+                    int * _dims = 0;
+                    err = allocMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, &_dims);
+                    if (err.iErr)
+                    {
+                        throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                    }
+                    for (int i = 0; i < ndims; i++)
+                    {
+                        _dims[i] = dims[i];
+                    }
+                }
+
+                return list;
+            }
+    };
+}
+
+#endif // __H5DATA_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5DataConverter.cpp b/scilab/modules/hdf5/src/cpp/H5DataConverter.cpp
new file mode 100644 (file)
index 0000000..d528c50
--- /dev/null
@@ -0,0 +1,488 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5DataConverter.hxx"
+
+namespace org_modules_hdf5
+{
+
+    int * H5DataConverter::getHypermatrix(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims)
+    {
+        static const char * hypermat[3] = {"hm", "dims", "entries"};
+
+        int * list = 0;
+        SciErr err = createMList(pvApiCtx, position, 3, &list);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+        }
+
+        err = createMatrixOfStringInList(pvApiCtx, position, list, 1, 1, 3, hypermat);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+        }
+
+       if (sizeof(int) == sizeof(hsize_t))
+       {
+           err = createMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, (int *)dims);
+           if (err.iErr)
+           {
+               throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+           }
+       }
+       else
+       {
+           int * _dims = 0;
+           err = allocMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, &_dims);
+           if (err.iErr)
+           {
+               throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+           }
+           for (int i = 0; i < ndims; i++)
+           {
+               _dims[i] = dims[i];
+           }
+       }
+
+        return list;
+    }
+
+    void H5DataConverter::toScilabString(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, char ** data)
+    {
+       SciErr err;
+        if (ndims == 1)
+        {
+            err = createMatrixOfString(pvApiCtx, position, 1, *dims, data);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create a double matrix on the stack"));
+            }
+        }
+        else
+        {
+            if (ndims == 2)
+            {
+                char ** newData = new char*[dims[0] * dims[1]];
+                C2FHypermatrix(2, dims, 0, data, newData);
+                err = createMatrixOfString(pvApiCtx, position, dims[0], dims[1], newData);
+                delete[] newData;
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot allocate a double matrix on the stack"));
+                }
+            }
+            else
+            {
+                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+                hsize_t size = dims[0];
+                for (int i = 1; i < ndims; i++)
+                {
+                    size *= dims[i];
+                }
+                char ** newData = new char*[size];
+                C2FHypermatrix(ndims, dims, size, data, newData);
+
+                err = createMatrixOfStringInList(pvApiCtx, position, list, 3, 1, (int)size, newData);
+                delete[] newData;
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                }
+            }
+        }
+    }
+
+    void H5DataConverter::toScilabDouble(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, double * data)
+    {
+       SciErr err;
+        if (ndims == 1)
+        {
+            err = createMatrixOfDouble(pvApiCtx, position, 1, *dims, data);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create a double matrix on the stack"));
+            }
+        }
+        else
+        {
+            double * newData = 0;
+            if (ndims == 2)
+            {
+                err = allocMatrixOfDouble(pvApiCtx, position, dims[0], dims[1], &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot allocate a double matrix on the stack"));
+                }
+                C2FHypermatrix(2, dims, 0, data, newData);
+            }
+            else
+            {
+                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+                hsize_t size = dims[0];
+                for (int i = 1; i < ndims; i++)
+                {
+                    size *= dims[i];
+                }
+
+                err = allocMatrixOfDoubleInList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                }
+                C2FHypermatrix(ndims, dims, size, data, newData);
+            }
+        }
+    }
+
+    void H5DataConverter::toScilabInt8(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, char * data)
+    {
+       SciErr err;
+        if (ndims == 1)
+        {
+            err = createMatrixOfInteger8(pvApiCtx, position, 1, *dims, data);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an int8 matrix on the stack"));
+            }
+        }
+        else
+        {
+            char * newData = 0;
+            if (ndims == 2)
+            {
+
+                err = allocMatrixOfInteger8(pvApiCtx, position, dims[0], dims[1], &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an int8 matrix on the stack"));
+                }
+                C2FHypermatrix(2, dims, 0, data, newData);
+            }
+            else
+            {
+                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+                hsize_t size = dims[0];
+                for (int i = 1; i < ndims; i++)
+                {
+                    size *= dims[i];
+                }
+
+                err = allocMatrixOfInteger8InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                }
+                C2FHypermatrix(ndims, dims, size, data, newData);
+            }
+        }
+    }
+
+    void H5DataConverter::toScilabUInt8(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned char * data)
+    {
+       SciErr err;
+       if (ndims == 1)
+        {
+            err = createMatrixOfUnsignedInteger8(pvApiCtx, position, 1, *dims, data);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint8 matrix on the stack"));
+            }
+        }
+        else
+        {
+            unsigned char * newData = 0;
+            if (ndims == 2)
+            {
+                err = allocMatrixOfUnsignedInteger8(pvApiCtx, position, dims[0], dims[1], &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint8 matrix on the stack"));
+                }
+                C2FHypermatrix(2, dims, 0, data, newData);
+            }
+            else
+            {
+                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+                hsize_t size = dims[0];
+                for (int i = 1; i < ndims; i++)
+                {
+                    size *= dims[i];
+                }
+
+                err = allocMatrixOfUnsignedInteger8InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                }
+                C2FHypermatrix(ndims, dims, size, data, newData);
+            }
+        }
+    }
+
+    void H5DataConverter::toScilabInt16(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, short * data)
+    {
+       SciErr err;
+        if (ndims == 1)
+        {
+            err = createMatrixOfInteger16(pvApiCtx, position, 1, *dims, data);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an int16 matrix on the stack"));
+            }
+        }
+        else
+        {
+            short * newData = 0;
+            if (ndims == 2)
+            {
+                err = allocMatrixOfInteger16(pvApiCtx, position, dims[0], dims[1], &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an int16 matrix on the stack"));
+                }
+                C2FHypermatrix(2, dims, 0, data, newData);
+            }
+            else
+            {
+                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+                hsize_t size = dims[0];
+                for (int i = 1; i < ndims; i++)
+                {
+                    size *= dims[i];
+                }
+
+                err = allocMatrixOfInteger16InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                }
+                C2FHypermatrix(ndims, dims, size, data, newData);
+            }
+        }
+    }
+
+    void H5DataConverter::toScilabUInt16(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned short * data)
+    {
+       SciErr err;
+        if (ndims == 1)
+        {
+            err = createMatrixOfUnsignedInteger16(pvApiCtx, position, 1, *dims, data);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint16 matrix on the stack"));
+            }
+        }
+        else
+        {
+            unsigned short * newData = 0;
+            if (ndims == 2)
+            {
+                err = allocMatrixOfUnsignedInteger16(pvApiCtx, position, dims[0], dims[1], &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint16 matrix on the stack"));
+                }
+                C2FHypermatrix(2, dims, 0, data, newData);
+            }
+            else
+            {
+                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+                hsize_t size = dims[0];
+                for (int i = 1; i < ndims; i++)
+                {
+                    size *= dims[i];
+                }
+
+                err = allocMatrixOfUnsignedInteger16InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                }
+                C2FHypermatrix(ndims, dims, size, data, newData);
+            }
+        }
+    }
+
+    void H5DataConverter::toScilabInt32(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, int * data)
+    {
+       SciErr err;
+        if (ndims == 1)
+        {
+            err = createMatrixOfInteger32(pvApiCtx, position, 1, *dims, data);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an int32 matrix on the stack"));
+            }
+        }
+        else
+        {
+            int * newData = 0;
+            if (ndims == 2)
+            {
+                err = allocMatrixOfInteger32(pvApiCtx, position, dims[0], dims[1], &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an int32 matrix on the stack"));
+                }
+                C2FHypermatrix(2, dims, 0, data, newData);
+            }
+            else
+            {
+                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+                hsize_t size = dims[0];
+                for (int i = 1; i < ndims; i++)
+                {
+                    size *= dims[i];
+                }
+
+                err = allocMatrixOfInteger32InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                }
+                C2FHypermatrix(ndims, dims, size, data, newData);
+            }
+        }
+    }
+
+    void H5DataConverter::toScilabUInt32(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned int * data)
+    {
+       SciErr err;
+        if (ndims == 1)
+        {
+            err = createMatrixOfUnsignedInteger32(pvApiCtx, position, 1, *dims, data);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint32 matrix on the stack"));
+            }
+        }
+        else
+        {
+            unsigned int * newData = 0;
+            if (ndims == 2)
+            {
+                err = allocMatrixOfUnsignedInteger32(pvApiCtx, position, dims[0], dims[1], &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint32 matrix on the stack"));
+                }
+                C2FHypermatrix(2, dims, 0, data, newData);
+            }
+            else
+            {
+                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+                hsize_t size = dims[0];
+                for (int i = 1; i < ndims; i++)
+                {
+                    size *= dims[i];
+                }
+
+                err = allocMatrixOfUnsignedInteger32InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                }
+                C2FHypermatrix(ndims, dims, size, data, newData);
+            }
+        }
+    }
+
+#ifdef __SCILAB_INT64__
+
+    void H5DataConverter::toScilabInt64(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, long long * data)
+    {
+       SciErr err;
+        if (ndims == 1)
+        {
+            err = createMatrixOfInteger64(pvApiCtx, position, 1, *dims, data);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an int64 matrix on the stack"));
+            }
+        }
+        else
+        {
+            long long * newData = 0;
+            if (ndims == 2)
+            {
+                err = allocMatrixOfInteger64(pvApiCtx, position, dims[0], dims[1], &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an int64 matrix on the stack"));
+                }
+                C2FHypermatrix(2, dims, 0, data, newData);
+            }
+            else
+            {
+                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+                hsize_t size = dims[0];
+                for (int i = 1; i < ndims; i++)
+                {
+                    size *= dims[i];
+                }
+
+                err = allocMatrixOfInteger64InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                }
+                C2FHypermatrix(ndims, dims, size, data, newData);
+            }
+        }
+    }
+
+    void H5DataConverter::toScilabUInt64(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned long long * data)
+    {
+       SciErr err;
+        if (ndims == 1)
+        {
+            err = createMatrixOfUnsignedInteger64(pvApiCtx, position, 1, *dims, data);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint64 matrix on the stack"));
+            }
+        }
+        else
+        {
+            unsigned long long * newData = 0;
+            if (ndims == 2)
+            {
+                err = allocMatrixOfUnsignedInteger64(pvApiCtx, position, dims[0], dims[1], &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint64 matrix on the stack"));
+                }
+                C2FHypermatrix(2, dims, 0, data, newData);
+            }
+            else
+            {
+                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+                hsize_t size = dims[0];
+                for (int i = 1; i < ndims; i++)
+                {
+                    size *= dims[i];
+                }
+
+                err = allocMatrixOfUnsignedInteger64InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+                if (err.iErr)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+                }
+                C2FHypermatrix(ndims, dims, size, data, newData);
+            }
+        }
+    }
+
+#endif // __SCILAB_INT64__
+
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5DataConverter.hxx b/scilab/modules/hdf5/src/cpp/H5DataConverter.hxx
new file mode 100644 (file)
index 0000000..c7c8cb0
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5DATACONVERTER_HXX__
+#define __H5DATACONVERTER_HXX__
+
+#include <hdf5.h>
+#include "H5Exception.hxx"
+#include "H5Object.hxx"
+#include "H5Data.hxx"
+
+extern "C"
+{
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+}
+
+namespace org_modules_hdf5
+{
+
+    class H5DataConverter
+    {
+
+    public:
+
+        template <typename T>
+        static std::string dump(const unsigned int indentLevel, const int ndims, const hsize_t * dims, T * data, const H5Data & obj)
+            {
+                std::ostringstream os;
+                std::string indent = H5Object::getIndentString(indentLevel);
+
+                os << indent << "DATA {" << std::endl;
+               printData(indentLevel, indent + "(", os, ndims, dims, &data, obj);
+                os << indent << "}" << std::endl;
+
+                return os.str();
+            }
+
+        template <typename T>
+        static void printData(const unsigned int indentLevel, const std::string & start, std::ostringstream & os, const int ndims, const hsize_t * dims, T ** data, const H5Data & obj)
+            {
+                std::string indent = H5Object::getIndentString(indentLevel);
+
+               if (ndims == 0)
+               {
+                   os << start << "0): 0";
+               }
+                else if (ndims == 1)
+                {
+                    os << start << "0): ";
+                    for (hsize_t i = 0; i < dims[0] - 1; i++)
+                    {
+                       printOneData(os, (*data)[i], obj);
+                        os << ", ";
+                    }
+                    printOneData(os, (*data)[dims[0] - 1], obj);
+                    os << std::endl;
+                    *data += dims[0];
+                }
+                else
+                {
+                    std::ostringstream oss;
+                    for (hsize_t i = 0; i < dims[0]; i++)
+                    {
+                        oss << start << (unsigned int)i << ",";
+                        printData(0, oss.str(), os, ndims - 1, dims + 1, data, obj);
+                        oss.str("");
+                    }
+                }
+            }
+
+        template <typename T>
+        static inline void printOneData(std::ostream & os, T data, const H5Data & obj)
+            {
+                os << data;
+            }
+
+        static inline void printOneData(std::ostream & os, char * data, const H5Data & obj)
+            {
+                os << "\"" << data << "\"";
+            }
+
+       static inline void printOneData(std::ostream & os, void * data, const H5Data & obj)
+            {
+               obj.printData(os, data);
+            }
+
+        static void toScilabString(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, char ** data);
+
+        static void toScilabDouble(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, double * data);
+
+        static void toScilabInt8(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, char * data);
+
+        static void toScilabUInt8(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned char * data);
+
+        static void toScilabInt16(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, short * data);
+
+        static void toScilabUInt16(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned short * data);
+
+        static void toScilabInt32(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, int * data);
+
+        static void toScilabUInt32(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned int * data);
+
+#ifdef __SCILAB_INT64__
+
+        static void toScilabInt64(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, long long * data);
+
+        static void toScilabUInt64(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned long long * data);
+
+#endif // __SCILAB_INT64__
+
+        template <typename T>
+        static void C2FHypermatrix(const int ndims, const hsize_t * dims, const hsize_t size, const T * src, T * dest)
+            {
+                if (ndims == 2)
+                {
+                    for (int i = 0; i < dims[0]; i++)
+                    {
+                        for (int j = 0; j < dims[1]; j++)
+                        {
+                            dest[i + dims[0] * j] = src[j + dims[1] * i];
+                        }
+                    }
+                }
+                else
+                {
+                    hsize_t * cumprod = new hsize_t[ndims];
+                    hsize_t * cumdiv = new hsize_t[ndims];
+                    cumprod[0] = 1;
+                    cumdiv[ndims - 1] = 1;
+                    for (int i = 0; i < ndims - 1; i++)
+                    {
+                        cumprod[i + 1] = dims[i] * cumprod[i];
+                        cumdiv[i] = size / cumprod[i + 1];
+                    }
+
+                    reorder(ndims, dims, cumprod, cumdiv, src, dest);
+                    delete[] cumprod;
+                    delete[] cumdiv;
+                }
+            }
+
+    private:
+
+        static int * getHypermatrix(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims);
+
+        template <typename T>
+        static void reorder(const int ndims, const hsize_t * dims, const hsize_t * cumprod, const hsize_t * cumdiv, const T * src, T * dest)
+            {
+                if (ndims == 1)
+                {
+                    for (int i = 0; i < *dims; i++)
+                    {
+                        *dest = src[i];
+                        dest += *cumprod;
+                    }
+                }
+                else
+                {
+                    for (int i = 0; i < *dims; i++)
+                    {
+                        reorder(ndims - 1, dims + 1, cumprod + 1, cumdiv + 1, src, dest);
+                        dest += *cumprod;
+                        src += *cumdiv;
+                    }
+                }
+            }
+    };
+}
+
+#endif // __H5DATACONVERTER_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5DataFactory.cpp b/scilab/modules/hdf5/src/cpp/H5DataFactory.cpp
new file mode 100644 (file)
index 0000000..27f328c
--- /dev/null
@@ -0,0 +1,503 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5DataFactory.hxx"
+
+#define __SCILAB_HDF5_MAX_DIMS__ 64
+
+namespace org_modules_hdf5
+{
+
+    H5Data & H5DataFactory::getData(H5Object & parent, const hid_t obj, const bool isAttribute)
+    {
+        const hid_t type = isAttribute ? H5Aget_type(obj) : H5Dget_type(obj);
+       if (type < 0)
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Cannot get the data type"));
+       }
+       H5Data * data = 0;
+       // TODO: le type est ferme dans getNativeData: bonne idee ou pas ??
+
+        switch (H5Tget_class(type))
+        {
+        case H5T_INTEGER:
+            data = &getIntegerData(parent, obj, type, isAttribute);
+           break;
+        case H5T_FLOAT:
+            data = &getFloatingData(parent, obj, type, isAttribute);
+           break;
+        case H5T_TIME:
+            data = &getTimeData(parent, obj, type, isAttribute);
+           break;
+        case H5T_STRING:
+            data = &getStringData(parent, obj, type, isAttribute);
+           break;
+        case H5T_BITFIELD:
+            data = &getBitfieldData(parent, obj, type, isAttribute);
+           break;
+        case H5T_OPAQUE:
+            data = &getOpaqueData(parent, obj, type, isAttribute);
+           break;
+        case H5T_COMPOUND:
+            data = &getCompoundData(parent, obj, type, isAttribute);
+           break;
+        case H5T_REFERENCE:
+            data = &getReferenceData(parent, obj, type, isAttribute);
+           break;
+        case H5T_ENUM:
+            //data = &getEnumData(parent, obj, type, isAttribute);
+           //break;
+        case H5T_VLEN:
+            //data = &getVlenData(parent, obj, type, isAttribute);
+           //break;
+        case H5T_ARRAY:
+            //data = &getArrayData(parent, obj, type, isAttribute);
+           //break;
+        default:
+           H5Tclose(type);
+            throw H5Exception(__LINE__, __FILE__, _("Cannot get data from an unknown data type."));
+        }
+
+       return *data;
+    }
+
+    H5Data & H5DataFactory::getData(H5Object & parent, const hsize_t totalSize, const hid_t type, hsize_t ndims, hsize_t * dims, void * data, const hsize_t stride, const size_t offset, const bool dataOwner)
+    {
+       hsize_t dataSize = H5Tget_size(type);
+        if (H5Tget_class(type) == H5T_STRING && !H5Tis_variable_str(type))
+        {
+            // We have a C-string so it is null terminated
+            dataSize++;
+        } 
+
+        switch (H5Tget_class(type))
+        {
+        case H5T_INTEGER:
+            if (H5Tequal(type, H5T_NATIVE_SCHAR))
+            {
+                return *new H5BasicData<char>(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, false);
+            }
+            else if (H5Tequal(type, H5T_NATIVE_UCHAR))
+            {
+                return *new H5BasicData<unsigned char>(parent, totalSize, dataSize, ndims, dims, (unsigned char *)data, stride, offset, false);
+            }
+            else if (H5Tequal(type, H5T_NATIVE_SHORT))
+            {
+                return *new H5BasicData<short>(parent, totalSize, dataSize, ndims, dims, (short *)data, stride, offset, false);
+            }
+            else if (H5Tequal(type, H5T_NATIVE_USHORT))
+            {
+                return *new H5BasicData<unsigned short>(parent, totalSize, dataSize, ndims, dims, (unsigned short *)data, stride, offset, false);
+            }
+            else if (H5Tequal(type, H5T_NATIVE_INT))
+            {
+                return *new H5BasicData<int>(parent, totalSize, dataSize, ndims, dims, (int *)data, stride, offset, false);
+            }
+            else if (H5Tequal(type, H5T_NATIVE_UINT))
+            {
+                return *new H5BasicData<unsigned int>(parent, totalSize, dataSize, ndims, dims, (unsigned int *)data, stride, offset, false);
+            }
+
+#ifdef __SCILAB_INT64__
+
+            else if (H5Tequal(type, H5T_NATIVE_LONG))
+            {
+                return *new H5BasicData(parent, totalSize, dataSize, ndims, dims, (long long *)data, stride, offset, false);
+            }
+            else if (H5Tequal(type, H5T_NATIVE_ULONG))
+            {
+                return *new H5BasicData(parent, totalSize, dataSize, ndims, dims, (unsigned long long *)data, stride, offset, false);
+            }
+
+#endif // __SCILAB_INT64__
+
+           else
+           {
+               H5Tclose(type);
+               throw H5Exception(__LINE__, __FILE__, _("Unknown integer datatype."));
+           }
+            break;
+        case H5T_FLOAT:
+            if (H5Tequal(type, H5T_NATIVE_FLOAT))
+            {
+                return *new H5FloatData(parent, totalSize, dataSize, ndims, dims, (float *)data, stride, offset, false);
+            }
+            else if (H5Tequal(type, H5T_NATIVE_DOUBLE))
+            {
+                return *new H5BasicData<double>(parent, totalSize, dataSize, ndims, dims, (double *)data, stride, offset, false);
+            }
+           else
+           {
+               throw H5Exception(__LINE__, __FILE__, _("Unknown floating-point datatype."));
+           }
+            break;
+        case H5T_TIME:
+            return *new H5TimeData(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, false);
+        case H5T_STRING:
+           if (H5Tis_variable_str(type))
+           {
+               return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char **)data, stride, offset, false);
+           }
+           else
+           {
+               return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, false);
+           }
+        case H5T_BITFIELD:
+            return *new H5BitfieldData(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, false);
+        case H5T_OPAQUE:
+            return *new H5OpaqueData(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, false);
+        case H5T_COMPOUND:
+        {
+            const unsigned int nmembers = (unsigned int)H5Tget_nmembers(type);
+            std::string * names = new std::string[nmembers];
+            size_t offs;
+            H5Data ** fields = new H5Data *[nmembers];
+
+            for (unsigned int i = 0; i < nmembers; i++)
+            {
+                hid_t mtype = H5Tget_member_type(type, i);
+                char * mname = H5Tget_member_name(type, i);
+                size_t offs = H5Tget_member_offset(type, i);
+                names[i] = std::string(mname);
+                free(mname);
+                fields[i] = &getData(parent, totalSize, mtype, ndims, dims, data, stride, offset + offs, false);
+            }
+
+            return *new H5CompoundData(parent, totalSize, dataSize, ndims, dims, nmembers, names, fields, (char *)data, dataOwner);
+        }
+        case H5T_REFERENCE:
+           // TODO: virer le false
+            return *new H5ReferenceData(parent, false, totalSize, dataSize, ndims, dims, (char *)data, offset);
+        case H5T_ENUM:
+        {
+            /*int nmembers = H5Tget_nmembers(type);
+            std::string * names = new std::string[nmembers];
+
+            for (unsigned int i = 0; i < nmembers; i++)
+            {
+                char * mname = H5Tget_member_name(type, i);
+                names[i] = std::string(mname);
+                free(mname);
+            }
+            return *new H5EnumData(parent, totalSize, dataSize, ndims, dims, data, offset, names);*/
+        }
+        case H5T_VLEN:
+            //return *new H5VlenData(parent, totalSize, dataSize, ndims, dims, data, offset);
+        case H5T_ARRAY:
+            //return *new H5ArrayData(parent, totalSize, dataSize, ndims, dims, data, offset);
+        default:
+            throw H5Exception(__LINE__, __FILE__, _("Cannot get data from an unknown data type."));
+        }
+
+       throw H5Exception(__LINE__, __FILE__, _("Cannot get data from an unknown data type."));
+    }
+
+    H5Data & H5DataFactory::getIntegerData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    {
+        hsize_t ndims;
+        hsize_t * dims = 0;
+       hsize_t totalSize;
+       hsize_t dataSize;
+        void * data = 0;
+       H5Data * dataObj = 0;
+       const hid_t nativeType = H5Tget_native_type(type, H5T_DIR_DEFAULT);
+
+        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+        if (H5Tequal(nativeType, H5T_NATIVE_SCHAR))
+        {
+            dataObj = new H5BasicData<char>(parent, totalSize, dataSize, ndims, dims, (char *)data);
+        }
+        else if (H5Tequal(nativeType, H5T_NATIVE_UCHAR))
+        {
+            dataObj = new H5BasicData<unsigned char>(parent, totalSize, dataSize, ndims, dims, (unsigned char *)data);
+        }
+        else if (H5Tequal(nativeType, H5T_NATIVE_SHORT))
+        {
+            dataObj = new H5BasicData<short>(parent, totalSize, dataSize, ndims, dims, (short *)data);
+        }
+        else if (H5Tequal(nativeType, H5T_NATIVE_USHORT))
+        {
+            dataObj = new H5BasicData<unsigned short>(parent, totalSize, dataSize, ndims, dims, (unsigned short *)data);
+        }
+        else if (H5Tequal(nativeType, H5T_NATIVE_INT))
+        {
+            dataObj = new H5BasicData<int>(parent, totalSize, dataSize, ndims, dims, (int *)data);
+        }
+        else if (H5Tequal(nativeType, H5T_NATIVE_UINT))
+        {
+            dataObj = new H5BasicData<unsigned int>(parent, totalSize, dataSize, ndims, dims, (unsigned int *)data);
+        }
+
+#ifdef __SCILAB_INT64__
+
+        else if (H5Tequal(nativeType, H5T_NATIVE_LONG))
+        {
+            dataObj = new H5BasicData<long long>(parent, totalSize, dataSize, ndims, dims, (long long *)data);
+        }
+        else if (H5Tequal(nativeType, H5T_NATIVE_ULONG))
+        {
+            dataObj = new H5BasicData<unsigned long long>(parent, totalSize, dataSize, ndims, dims, (unsigned long long *)data);
+        }
+
+#endif // __SCILAB_INT64__
+       
+       else
+       {
+           H5Tclose(nativeType);
+           delete[] dims;
+           FREE(data);
+           throw H5Exception(__LINE__, __FILE__, _("Unknown integer datatype."));
+       }
+
+       H5Tclose(nativeType);
+
+       return *dataObj;
+    }
+
+    H5Data & H5DataFactory::getFloatingData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    {
+        hsize_t ndims;
+       hsize_t totalSize;
+       hsize_t dataSize;
+        hsize_t * dims = 0;
+        void * data = 0;
+       H5Data * dataObj = 0;
+       const hid_t nativeType = H5Tget_native_type(type, H5T_DIR_DEFAULT);
+
+        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+       if (H5Tequal(nativeType, H5T_NATIVE_FLOAT))
+       {
+           dataObj = new H5FloatData(parent, totalSize, dataSize, ndims, dims, (float *)data);
+       }
+       else if (H5Tequal(nativeType, H5T_NATIVE_DOUBLE))
+       {
+           dataObj = new H5BasicData<double>(parent, totalSize, dataSize, ndims, dims, (double *)data);
+       }
+       else
+       {
+           H5Tclose(nativeType);
+           delete[] dims;
+           FREE(data);
+           throw H5Exception(__LINE__, __FILE__, _("Unknown floating-point datatype."));
+       }
+
+       H5Tclose(nativeType);
+
+       return *dataObj;
+    }
+
+    H5StringData & H5DataFactory::getStringData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    {
+        hsize_t ndims;
+       hsize_t totalSize;
+       hsize_t dataSize;
+        hsize_t * dims = 0;
+        void * data = 0;
+
+        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+       if (H5Tis_variable_str(type))
+       {
+           return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char **)data);
+       }
+       else
+       {
+           return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char *)data);
+       }
+    }
+
+    H5TimeData & H5DataFactory::getTimeData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    {
+        hsize_t ndims;
+       hsize_t totalSize;
+       hsize_t dataSize;
+        hsize_t * dims = 0;
+        void * data = 0;
+
+        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+        return *new H5TimeData(parent, totalSize, dataSize, ndims, dims, static_cast<char *>(data));
+    }
+
+    H5BitfieldData & H5DataFactory::getBitfieldData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    {
+        hsize_t ndims;
+       hsize_t totalSize;
+       hsize_t dataSize;
+        hsize_t * dims = 0;
+        void * data = 0;
+
+        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+       
+        return *new H5BitfieldData(parent, totalSize, dataSize, ndims, dims, static_cast<char *>(data));
+    }
+
+    H5OpaqueData & H5DataFactory::getOpaqueData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    {
+        hsize_t ndims;
+       hsize_t totalSize;
+       hsize_t dataSize;
+        hsize_t * dims = 0;
+        void * data = 0;
+
+        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+       
+        return *new H5OpaqueData(parent, totalSize, dataSize, ndims, dims, static_cast<char *>(data));
+    }
+
+    H5Data & H5DataFactory::getCompoundData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    {
+        hsize_t ndims;
+       hsize_t totalSize;
+       hsize_t dataSize;
+        hsize_t * dims = 0;
+        void * data = 0;
+       const hid_t nativeType = H5Tget_native_type(type, H5T_DIR_DEFAULT);
+       getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+       try
+       {
+           return getData(parent, totalSize, nativeType, ndims, dims, data, dataSize, 0, true);
+       }
+       catch (const H5Exception & e)
+       {
+           H5Tclose(nativeType);
+           throw;
+       }
+    }
+
+    H5ReferenceData & H5DataFactory::getReferenceData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    {
+        hsize_t ndims;
+       hsize_t totalSize;
+       hsize_t dataSize;
+        hsize_t * dims = 0;
+        void * data = 0;
+
+        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+       std::cout << "ref size = " << ndims << std::endl; 
+        return *new H5ReferenceData(parent, H5Tequal(type, H5T_STD_REF_DSETREG) > 0, totalSize, dataSize, ndims, dims, (char *)data);
+    }
+
+    /*H5EnumData & H5DataFactory::getEnumData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    {
+        hsize_t ndims;
+       hsize_t totalSize;
+       hisze_t dataSize;
+        hsize_t * dims = 0;
+        void * data = 0;
+        int nmembers = H5Tget_nmembers(type);
+        std::string * names = new std::string[nmembers];
+
+        for (unsigned int i = 0; i < nmembers; i++)
+        {
+            char * mname = H5Tget_member_name(type, i);
+            names[i] = std::string(mname);
+            free(mname);
+        }
+
+        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+        return *new H5EnumData(parent, totalSize, dataSize, ndims, dims, data, names);
+    }
+
+    H5VlenData & H5DataFactory::getVlenData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    {
+        hsize_t ndims;
+       hsize_t totalSize;
+       hisze_t dataSize;
+        hsize_t * dims = 0;
+        void * data = 0;
+
+        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+        return *new H5VlenData(parent, totalSize, dataSize, ndims, dims, data);
+    }
+
+    H5ArrayData & H5DataFactory::getArrayData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    {
+        hsize_t ndims;
+       hsize_t totalSize;
+       hisze_t dataSize;
+        hsize_t * dims = 0;
+        void * data = 0;
+
+        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+        return *new H5ArrayData(parent, totalSize, dataSize, ndims, dims, data);
+       }*/
+
+    //  getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+    //return *new H5StringData(parent, totalSize, dataSize, ndims, dims, data);
+
+    void H5DataFactory::getNativeData(const hid_t obj, const hid_t type, hsize_t * totalSize, hsize_t * dataSize, hsize_t * ndims, hsize_t ** dims, void ** data, const bool isAttribute)
+    {
+        hid_t nativeType = H5Tget_native_type(type, H5T_DIR_DEFAULT);
+       const hid_t space = isAttribute ? H5Aget_space(obj) : H5Dget_space(obj);
+        hsize_t size = H5Tget_size(nativeType);
+       *totalSize = 1;
+       *dims = new hsize_t[__SCILAB_HDF5_MAX_DIMS__ + 1];
+        *ndims = H5Sget_simple_extent_dims(space, *dims, 0);
+
+        if (H5Tget_class(nativeType) == H5T_STRING && !H5Tis_variable_str(nativeType))
+        {
+            // We have a C-string so it is null terminated
+            size++;
+        }
+
+       *dataSize = size;
+
+        for (int i = 0; i < *ndims; i++)
+        {
+            *totalSize *= (*dims)[i];
+        }
+
+       size *= *totalSize;
+
+        if ((hsize_t)((size_t)size) != size)
+        {
+           H5Tclose(type);
+            H5Tclose(nativeType);
+            H5Sclose(space);
+            delete[] *dims;
+            throw H5Exception(__LINE__, __FILE__, _("Memory to allocate is too big"));
+        }
+
+        *data = MALLOC((size_t)size);
+        if (!*data)
+        {
+           H5Tclose(type);
+            H5Tclose(nativeType);
+            H5Sclose(space);
+            delete[] *dims;
+            throw H5Exception(__LINE__, __FILE__, _("Cannot allocate memory to get the data"));
+        }
+
+        if ((isAttribute && H5Aread(obj, nativeType, *data) < 0)
+            || (!isAttribute && H5Dread(obj, nativeType, H5S_ALL, H5S_ALL, H5P_DEFAULT, *data) < 0))
+        {
+           H5Tclose(type);
+            H5Tclose(nativeType);
+            H5Sclose(space);
+            FREE(*data);
+            delete[] *dims;
+            throw H5Exception(__LINE__, __FILE__, _("Cannot retrieve the data from the attribute"));
+        }
+
+        H5Tclose(nativeType);
+        H5Sclose(space);
+    }
+}
+
+#undef __SCILAB_HDF5_MAX_DIMS__
diff --git a/scilab/modules/hdf5/src/cpp/H5DataFactory.hxx b/scilab/modules/hdf5/src/cpp/H5DataFactory.hxx
new file mode 100644 (file)
index 0000000..ad6dfda
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5DATAFACTORY_HXX__
+#define __H5DATAFACTORY_HXX__
+
+#include "H5Object.hxx"
+#include "H5Data.hxx"
+#include "H5StringData.hxx"
+#include "H5TimeData.hxx"
+#include "H5BitfieldData.hxx"
+#include "H5ReferenceData.hxx"
+#include "H5CompoundData.hxx"
+#include "H5OpaqueData.hxx"
+#include "H5FloatData.hxx"
+
+namespace org_modules_hdf5
+{
+    class H5DataFactory
+    {
+       
+    public:
+       
+       static H5Data & getData(H5Object & parent, const hid_t obj, const bool isAttribute);
+       static H5Data & getData(H5Object & parent, const hsize_t totalSize, const hid_t type, hsize_t ndims, hsize_t * dims, void * data, const hsize_t stride, const size_t offset, const bool dataOwner = false);
+       static H5Data & getIntegerData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+       static H5Data & getFloatingData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+       static H5StringData & getStringData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+       static H5TimeData & getTimeData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+       static H5BitfieldData & getBitfieldData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+       static H5OpaqueData & getOpaqueData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+       static H5Data & getCompoundData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+       static H5ReferenceData & getReferenceData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+       static void getNativeData(const hid_t obj, const hid_t type, hsize_t * totalSize, hsize_t * dataSize, hsize_t * ndims, hsize_t ** dims, void ** data, const bool isAttribute);
+    };
+}
+
+#endif // __H5DATAFACTORY_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5Dataset.cpp b/scilab/modules/hdf5/src/cpp/H5Dataset.cpp
new file mode 100644 (file)
index 0000000..e3e086d
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5Dataset.hxx"
+#include "H5DataFactory.hxx"
+
+namespace org_modules_hdf5
+{
+    
+    H5Dataset::H5Dataset(H5Object & _parent, const char * _name) : H5Object(_parent), name(_name), dataset((hid_t)-1)
+    {
+       dataset = H5Dopen2(_parent.getH5Id(), name, H5P_DEFAULT);
+       if (dataset < 0)
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Cannot open the given dataset %s."), name);
+       }
+    }
+
+    H5Dataset::H5Dataset(H5Object & _parent, hid_t _dataset, const char * _name) : H5Object(_parent), dataset(_dataset), name(_name)
+    {
+
+    }
+
+    H5Dataset::~H5Dataset()
+    {
+       if (dataset >= 0)
+       {
+           H5Dclose(dataset);
+       }
+       if (name)
+       {
+           FREE(const_cast<char *>(name));
+       }
+    }
+
+    H5Data & H5Dataset::getData()
+    {
+       return H5DataFactory::getData(*this, dataset, false);
+    }
+    
+    H5Dataspace & H5Dataset::getSpace()
+    {
+       hid_t space = H5Dget_space(dataset);
+       if (space < 0)
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Cannot get the dataspace associated with dataset named %s."), name);
+       }
+       
+       return *new H5Dataspace(*this, space);
+    }
+
+    H5Type & H5Dataset::getDataType()
+    {
+       hid_t type = H5Dget_type(dataset);
+       if (type < 0)
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Cannot get the dataspace associated with dataset named %s."), name);
+       }
+       
+       return *new H5Type(*this, type);
+    }
+
+    std::string H5Dataset::dump(const unsigned int indentLevel) const
+    { 
+       std::ostringstream os;
+       const H5Type & type = const_cast<H5Dataset *>(this)->getDataType();
+       const H5Dataspace & space = const_cast<H5Dataset *>(this)->getSpace();
+       const H5AttributesList & attrs = const_cast<H5Dataset *>(this)->getAttributes();
+       const H5Data & data = const_cast<H5Dataset *>(this)->getData();
+
+       os << H5Object::getIndentString(indentLevel) << "DATASET \"" << name << "\" {" << std::endl
+           << type.dump(indentLevel + 1)
+           << space.dump(indentLevel + 1)
+           << data.dump(indentLevel + 1)
+           << attrs.dump(indentLevel + 1)
+          << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+
+       delete &type;
+       delete &space;
+       delete &data;
+       delete &attrs;
+       
+       return os.str();
+    } 
+
+    std::string H5Dataset::toString(const unsigned int indentLevel) const
+    { 
+       return "";
+    }
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5Dataset.hxx b/scilab/modules/hdf5/src/cpp/H5Dataset.hxx
new file mode 100644 (file)
index 0000000..0d80f7a
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5DATASET_HXX__
+#define __H5DATASET_HXX__
+
+#include "H5Object.hxx"
+#include "H5Data.hxx"
+#include "H5Dataspace.hxx"
+#include "H5Type.hxx"
+#include "H5AttributesList.hxx"
+
+namespace org_modules_hdf5
+{
+    class H5Dataset : public H5Object
+    {
+       hid_t dataset;
+       const char * name;
+
+    public :
+       
+       H5Dataset(H5Object & _parent, const char * _name);
+       H5Dataset(H5Object & _parent, hid_t _dataset, const char * _name);
+
+       virtual ~H5Dataset();
+
+       hid_t getH5Id() const { return dataset; }
+       std::string getName() const { return std::string(name); }
+       
+       H5Data & getData();
+       H5Dataspace & getSpace();
+       H5Type & getDataType();
+       
+       virtual std::string dump(const unsigned int indentLevel) const;
+       virtual std::string toString(const unsigned int indentLevel) const;
+    };
+}
+
+#endif // __H5DATASET_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5DatasetsList.cpp b/scilab/modules/hdf5/src/cpp/H5DatasetsList.cpp
new file mode 100644 (file)
index 0000000..15c309a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5DatasetsList.hxx"
+#include "H5Group.hxx"
+
+namespace org_modules_hdf5
+{
+
+    H5DatasetsList::H5DatasetsList(H5Group & _parent) : H5NamedObjectsList(_parent, H5G_DATASET, "H5 Dataset")
+    {
+    
+    }
+       
+    H5DatasetsList::~H5DatasetsList()
+    {
+
+    }
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5DatasetsList.hxx b/scilab/modules/hdf5/src/cpp/H5DatasetsList.hxx
new file mode 100644 (file)
index 0000000..6091ff6
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5DATASETSLIST_HXX__
+#define __H5DATASETSLIST_HXX__
+
+#include "H5NamedObjectsList.hxx"
+#include "H5Dataset.hxx"
+
+namespace org_modules_hdf5
+{
+
+    class H5Group;
+
+    class H5DatasetsList : public H5NamedObjectsList<H5Dataset>
+    {
+
+    public :
+       
+       H5DatasetsList(H5Group & _parent) : H5NamedObjectsList<H5Dataset>(_parent, H5G_DATASET, "H5 Dataset") { }
+       
+       ~H5DatasetsList() { }
+    };
+}
+
+#endif // __H5DATASETSLIST_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5Dataspace.cpp b/scilab/modules/hdf5/src/cpp/H5Dataspace.cpp
new file mode 100644 (file)
index 0000000..c0e2e34
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5Dataspace.hxx"
+
+namespace org_modules_hdf5
+{
+    
+    H5Dataspace::H5Dataspace(H5Object & _parent, hid_t _space) : H5Object(_parent), space(_space)
+    {
+    }
+
+    H5Dataspace::~H5Dataspace()
+    {
+       if (space >= 0)
+       {
+           H5Sclose(space);
+       }
+    }
+
+    hid_t H5Dataspace::getH5Id()
+    {
+       return space;
+    }
+    
+    std::string H5Dataspace::dump(unsigned int indentLevel) const
+    {
+       std::ostringstream os;
+       hsize_t dims[64];
+       hsize_t maxdims[64];
+       int ndims;
+       H5S_class_t _class = H5Sget_simple_extent_type(space);
+       
+       os << H5Object::getIndentString(indentLevel);
+
+       switch (_class)
+       {
+       case H5S_SCALAR:
+           os << "DATASPACE SCALAR";
+           break;
+       case H5S_SIMPLE:
+           os << "DATASPACE SIMPLE { ";
+           ndims = H5Sget_simple_extent_dims(space, (hsize_t *)dims, (hsize_t *)maxdims);
+           os << "( ";
+           for (int i = 0; i < ndims - 1; i++)
+           {
+               os << dims[i] << ", ";
+           }
+           os << dims[ndims -1] << " ) / ( ";
+           for (int i = 0; i < ndims - 1; i++)
+           {
+               if (maxdims[i] == H5S_UNLIMITED)
+               {
+                   os << "H5S_UNLIMITED, ";
+               }
+               else
+               {
+                   os << maxdims[i] << ", ";
+               }
+           }
+           if (maxdims[ndims - 1] == H5S_UNLIMITED)
+           {
+               os << "H5S_UNLIMITED ) }";
+           }
+           else
+           {
+               os << maxdims[ndims - 1] << " ) }";
+           }
+           break;
+       case H5S_NULL:
+           os << "DATASPACE NULL";
+           break;
+       case H5S_NO_CLASS:
+       default:
+           os << _("Unknown dataspace");
+       }
+       
+       os << std::endl;
+
+       return os.str();
+    }
+
+    std::string H5Dataspace::toString(unsigned int indentLevel) const
+    {
+       return "";
+    }
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5Dataspace.hxx b/scilab/modules/hdf5/src/cpp/H5Dataspace.hxx
new file mode 100644 (file)
index 0000000..9bc2e6e
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5DATASPACE_HXX__
+#define __H5DATASPACE_HXX__
+
+#include "H5Object.hxx"
+
+namespace org_modules_hdf5
+{
+    
+    class H5Dataspace : public H5Object
+    {
+       hid_t space;
+
+    public:
+
+       H5Dataspace(H5Object & _parent, hid_t _space);
+       ~H5Dataspace();
+
+       virtual hid_t getH5Id();
+    
+       virtual std::string dump(unsigned int indentLevel) const;
+       virtual std::string toString(unsigned int indentLevel) const;
+    };
+}
+
+#endif // __H5DATASPACE_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5Exception.hxx b/scilab/modules/hdf5/src/cpp/H5Exception.hxx
new file mode 100644 (file)
index 0000000..e59b264
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5EXCEPTION_HXX__
+#define __H5EXCEPTION_HXX__
+
+extern "C"
+{
+#include "localization.h"
+#include "backtrace_print.h"
+}
+
+#include "HDF5Objects.h"
+
+#include <cstdlib>
+#include <exception>
+#include <sstream>
+#include <string>
+#include <cstdio>
+#include <stdarg.h>
+
+#define BUFFER_SIZE 1024
+
+namespace org_modules_hdf5
+{
+    class H5Exception
+    {
+       std::string message;
+       std::string file;
+       int line;
+
+    public :
+       
+       H5Exception(const int _line, const char * _file, std::string _message, ...) : message(""), file(_file), line(_line)
+           {
+               char str[BUFFER_SIZE];
+               va_list args;
+               
+               va_start(args, _message);
+               vsnprintf(str, BUFFER_SIZE, _message.c_str(), args);
+               va_end(args);
+               
+               message = getDescription(std::string(str));
+           }
+
+       H5Exception(const int _line, const char * _file, const char * _message, ...) : message(""), file(_file), line(_line)
+           {
+               char str[BUFFER_SIZE];
+               va_list args;
+               
+               va_start(args, _message);
+               vsnprintf(str, BUFFER_SIZE, _message, args);
+               va_end(args);
+               
+               message = getDescription(std::string(str));
+           }
+       
+       virtual ~H5Exception() throw() { }
+
+       virtual const char * what() const throw()
+           {
+               return message.c_str();
+           }
+
+private:
+
+    inline std::string getDescription(std::string m) const
+    {
+
+#if defined(HDF5OBJECTS_DEBUG)
+
+        if (line == -1)
+        {
+            return m;
+        }
+
+        std::ostringstream os;
+        const char * bt = backtrace_print(0, 1);
+
+        os << m << std::endl
+           << "DEBUG Informations:" << std::endl
+           << gettext("Exception thrown in file") << " " << file << " " << gettext("at line") << " " << line << std::endl
+           << bt;
+
+        free(const_cast<char *>(bt));
+        os.flush();
+
+        return os.str();
+
+#else
+
+        return m;
+
+#endif
+    }
+    };
+}
+
+#endif // __H5EXCEPTION_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5File.cpp b/scilab/modules/hdf5/src/cpp/H5File.cpp
new file mode 100644 (file)
index 0000000..bbeec3e
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5Group.hxx"
+#include "H5File.hxx"
+
+namespace org_modules_hdf5
+{
+
+    H5File::H5File(const char * _filename, const char * _path, const bool _readonly) : H5Object(H5Object::getRoot()), filename(strdup(_filename)), path(_path), root(0)
+    {
+       if (!H5Fis_hdf5(_filename))
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Invalid hdf5 file: %s"), _filename);
+       }
+
+       file = H5Fopen(_filename, _readonly ? H5F_ACC_RDONLY : H5F_ACC_RDWR, H5P_DEFAULT);
+
+       if (file < 0)
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Cannot open the given hdf5 file: %s"), _filename);
+       }
+    }
+
+    H5File::~H5File()
+    {
+       if (file >= 0)
+       {
+           H5Fclose(file);
+       }
+       FREE(const_cast<char *>(filename));
+    }
+
+    H5Group & H5File::getRootGroup()
+    {
+       if (!root)
+       {
+           root = new H5Group(*this, strdup("/"));
+       }
+       return *root;
+    }
+
+    std::string H5File::getCompletePath() const
+    {
+       return "";
+    }
+
+    std::string H5File::dump(const unsigned int indentLevel) const
+    {
+       std::ostringstream os;
+       H5Group & _root = const_cast<H5File *>(this)->getRootGroup();
+       os << H5Object::getIndentString(indentLevel) << "HDF5 \"" << filename << "\" {" << std::endl
+          << _root.dump(indentLevel + 1)
+          << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+
+       return os.str();
+    }
+
+    std::string H5File::toString(const unsigned int indentLevel) const
+    {
+       herr_t err;
+       hsize_t size = 0;
+       std::ostringstream os;
+       unsigned int major = 0, minor = 0, release = 0;
+       std::string indentString = H5Object::getIndentString(indentLevel);
+
+       err = H5Fget_filesize(file, &size);
+       if (err < 0)
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Cannot retrieve file size: %s"), filename); 
+       }
+
+       err = H5get_libversion(&major, &minor, &release);
+       os << indentString << _("Filename") << ": " << filename << std::endl
+          << indentString << _("HDF5 library version") << ": " << major << "." << minor << "." << release << std::endl
+          << indentString << _("File size") << ": " << size << std::endl
+          << indentString << _("Group name") << ": " << path << std::flush;
+
+       os << std::endl << "DEBUG FILE" << std::endl << dump(0) << std::endl;
+
+       return os.str();
+    }
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5File.hxx b/scilab/modules/hdf5/src/cpp/H5File.hxx
new file mode 100644 (file)
index 0000000..9ba086d
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5FILE_HXX__
+#define __H5FILE_HXX__
+
+#include "H5Object.hxx"
+
+namespace org_modules_hdf5
+{
+    class H5Group;
+
+    class H5File : public H5Object
+    {
+       const char * filename;
+       const char * path;
+       hid_t file;
+       H5Group * root;
+
+    public :
+       
+       H5File(const char * _filename, const char * _path = "/", const bool _readonly = false);
+       
+       ~H5File();
+
+       H5Group & getRootGroup();
+       hid_t getH5Id() const { return file; }
+       virtual std::string getCompletePath() const;
+       const char * getFileName() const { return filename; }
+       const char * getRootPath() const { return path; }
+
+       virtual std::string toString(const unsigned int indentLevel) const;
+       virtual std::string dump(const unsigned int indentLevel = 0) const;
+    };
+}
+
+#endif // __H5FILE_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5FloatData.hxx b/scilab/modules/hdf5/src/cpp/H5FloatData.hxx
new file mode 100644 (file)
index 0000000..7b06f27
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5FLOATDATA_HXX__
+#define __H5FLOATDATA_HXX__
+
+#include "H5BasicData.hxx"
+
+namespace org_modules_hdf5
+{
+
+    class H5FloatData : public H5Data
+    {
+
+    protected:
+
+        double * transformedData;
+
+    public:
+       
+       H5FloatData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, float * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5Data(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner)
+           {
+               transformedData = new double[totalSize];
+
+               if (stride == -1)
+               { 
+                   for (unsigned int i = 0; i < (unsigned int)totalSize; i++)
+                   {
+                       transformedData[i] = (double)(_data[i]); 
+                   }
+               }
+               else
+               {
+                   char * __data = (char *)_data;
+                   for (unsigned int i = 0; i < (unsigned int)totalSize; i++)
+                   {
+                       transformedData[i] = (double)(*((float *)(__data + offset)));
+                       __data += stride;
+                   }
+               }
+           }
+
+       virtual ~H5FloatData()
+           {
+               delete[] transformedData;
+           }
+
+       virtual void * getData() const
+           {
+               return transformedData;
+           }
+
+        virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const
+            {
+               SciErr err;
+                double * newData = 0;
+                if (ndims == 1)
+                {
+                    H5BasicData<char>::alloc(pvApiCtx, lhsPosition, 1, *dims, parentList, listPosition, &newData);
+                    memcpy(static_cast<void *>(newData), static_cast<void *>(transformedData), totalSize * sizeof(double));
+                }
+                else
+                {
+                    if (ndims == 2)
+                    {
+                        H5BasicData<char>::alloc(pvApiCtx, lhsPosition, dims[0], dims[1], parentList, listPosition, &newData);
+                        H5DataConverter::C2FHypermatrix(2, dims, 0, static_cast<double *>(getData()), newData);
+                    }
+                    else
+                    {
+                        int * list = getHypermatrix(pvApiCtx, lhsPosition, parentList, listPosition);
+                       H5BasicData<char>::alloc(pvApiCtx, lhsPosition, 1, totalSize, list, 3, &newData);
+                        H5DataConverter::C2FHypermatrix(ndims, dims, totalSize, static_cast<double *>(getData()), newData);
+                    }
+                }
+            }
+
+        virtual std::string dump(const unsigned int indentLevel) const
+            {
+               return H5DataConverter::dump(indentLevel, ndims, dims, static_cast<double *>(getData()), *this);
+           }
+    };
+}
+
+#endif // __H5FLOATDATA_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5Group.cpp b/scilab/modules/hdf5/src/cpp/H5Group.cpp
new file mode 100644 (file)
index 0000000..74edbef
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5Group.hxx"
+#include "H5File.hxx"
+#include "H5LinksList.hxx"
+#include "H5GroupsList.hxx"
+#include "H5DatasetsList.hxx"
+#include "H5TypesList.hxx"
+
+namespace org_modules_hdf5
+{
+
+    H5Group::H5Group(H5Object & _parent, const char * _name) : H5Object(_parent), name(_name)
+    {
+       group = H5Gopen(_parent.getH5Id(), name, H5P_DEFAULT);
+       if (group < 0)
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Cannot open the group %s."), name);
+       }
+    }
+
+    H5Group::H5Group(H5Object & _parent, hid_t _group, const char * _name) : H5Object(_parent), group(_group), name(_name)
+    {
+
+    }
+
+    H5Group::~H5Group()
+    {
+       if (group >= 0)
+       {
+           H5Gclose(group);
+       }
+       if (name)
+       {
+           FREE(const_cast<char *>(name));
+       }
+    }
+
+    H5LinksList & H5Group::getLinks()
+    {
+       return *new H5LinksList(*this);
+    }
+
+    H5GroupsList & H5Group::getGroups()
+    {
+       return *new H5GroupsList(*this);
+    }
+
+    H5DatasetsList & H5Group::getDatasets()
+    {
+       return *new H5DatasetsList(*this);
+    }
+
+    H5TypesList & H5Group::getTypes()
+    {
+       return *new H5TypesList(*this);
+    }
+
+    std::string H5Group::dump(const unsigned int indentLevel) const
+    {
+       std::ostringstream os;
+       H5AttributesList & attrs = const_cast<H5Group *>(this)->getAttributes();
+       H5LinksList & links = const_cast<H5Group *>(this)->getLinks();
+       
+       os << H5Object::getIndentString(indentLevel) << "GROUP \"" << name << "\" {" << std::endl
+          << attrs.dump(indentLevel + 1)
+          << links.dump(indentLevel + 1)
+          << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+
+       delete &attrs;
+       delete &links;
+
+       return os.str();
+    }
+
+    std::string H5Group::toString(const unsigned int indentLevel) const
+    {
+       std::ostringstream os;
+       std::string indentString = H5Object::getIndentString(indentLevel);
+       const H5GroupsList & groups = const_cast<H5Group *>(this)->getGroups();
+       const H5DatasetsList & datasets = const_cast<H5Group *>(this)->getDatasets();
+       const H5TypesList & types = const_cast<H5Group *>(this)->getTypes();
+       const H5AttributesList & attrs = const_cast<H5Group *>(this)->getAttributes();
+       
+       os << indentString << _("Filename") << ": " << getFile().getFileName() << std::endl
+          << indentString << _("Group name") << ": " << name << std::endl
+          << indentString << _("Group path") << ": " << getCompletePath() << std::endl
+          << indentString << _("Number of attributes") << ": " << attrs.getSize() << std::endl
+          << indentString << _("Number of named groups") << ": " << groups.getSize() << std::endl
+          << indentString << _("Number of named datasets") << ": " << datasets.getSize() << std::endl
+          << indentString << _("Number of named types") << ": " << types.getSize();
+
+       delete &groups;
+       delete &datasets;
+       delete &types;
+       delete &attrs;
+
+       return os.str();
+    }
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5Group.hxx b/scilab/modules/hdf5/src/cpp/H5Group.hxx
new file mode 100644 (file)
index 0000000..2ec20e2
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5GROUP_HXX__
+#define __H5GROUP_HXX__
+
+#include "H5Object.hxx"
+#include "H5AttributesList.hxx"
+
+namespace org_modules_hdf5
+{
+    
+    class H5LinksList;
+    class H5GroupsList;
+    class H5DatasetsList;
+    class H5TypesList;
+    class H5File;
+
+    class H5Group : public H5Object
+    {
+       hid_t group;
+       const char * name;
+
+    public:
+
+       H5Group(H5Object & _parent, const char * name);
+       H5Group(H5Object & _parent, hid_t _group, const char * _name);
+       
+       virtual ~H5Group();
+
+       virtual hid_t getH5Id() const { return group; }
+        virtual H5LinksList & getLinks();
+        virtual H5GroupsList & getGroups();
+        virtual H5DatasetsList & getDatasets();
+        virtual H5TypesList & getTypes();
+       virtual std::string getName() const { return std::string(name); }
+       virtual std::string toString(const unsigned int indentLevel) const;
+       virtual std::string dump(const unsigned int indentLevel = 0) const;
+    };
+}
+
+#endif // __H5GROUP_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5GroupsList.cpp b/scilab/modules/hdf5/src/cpp/H5GroupsList.cpp
new file mode 100644 (file)
index 0000000..847832e
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5GroupsList.hxx"
+
+namespace org_modules_hdf5
+{
+    H5GroupsList::H5GroupsList(H5Object & _parent) : H5ListObject(_parent) { }
+
+    H5GroupsList::~H5GroupsList() { }
+    
+    const unsigned int H5GroupsList::getSize() const
+    {
+       H5G_info_t info;
+       hsize_t count = 0;
+       hid_t parentId = getParent().getH5Id();
+       herr_t err = H5Gget_info(parentId, &info);
+       
+       if (err < 0)
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of groups."));
+       }
+       
+       for (hsize_t i = 0; i < info.nlinks; i++)
+       {
+           int type = H5Gget_objtype_by_idx(parentId, i);
+           if (type == H5G_GROUP)
+           {
+               count++;
+           }
+       }
+       
+       return (unsigned int)count;
+    }
+
+    void H5GroupsList::setObject(const unsigned int pos, H5Group & obj)
+    {
+
+    }
+
+    H5Group & H5GroupsList::getObject(const int pos)
+    {
+       return getObject(pos, true);
+    }
+
+    H5Group & H5GroupsList::getObject(const int pos, const bool checkPos)
+    {
+       int type;
+       herr_t err;
+       hsize_t count = 0;
+       hsize_t index = 0;
+       hid_t parentId = getParent().getH5Id();
+       ssize_t nameSize;
+       char * name = 0;
+
+       if (checkPos)
+       {
+           unsigned int size = getSize();
+           if (pos < 0 || pos >= size)
+           {
+               throw H5Exception(__LINE__, __FILE__, _("Invalid index %u: must be between 0 and %u."), pos, size);
+           }
+       }
+
+       err = H5Gget_info(parentId, &info);
+       if (err < 0)
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of groups."));
+       }
+       
+       for (; index < info.nlinks; index++)
+       {
+           int type = H5Gget_objtype_by_idx(parentId, index);
+           if (type == H5G_GROUP)
+           {
+               count++;
+               if (count == pos)
+               {
+                   break;
+               }
+           }
+       }
+           
+       nameSize = H5Gget_objname_by_idx(parentId, index, 0, 0);
+       name = (char *)MALLOC((nameSize + 1) * sizeof(char));
+       H5Gget_objname_by_idx(parentId, index, name, nameSize + 1);
+       
+       return *new H5Group(getParent(), name);
+    }
+
+    std::string H5GroupsList::dump(const unsigned int indentLevel) const
+    {
+       std::ostringstream os;
+       const unsigned int size = getSize();
+
+       for (unsigned int i = 0; i < size; i++)
+       {
+           const H5Group & group = const_cast<H5GroupsList *>(this)->getObject(i, false);
+           os << group.toString(indentLevel) << std::endl;
+
+           delete &group;
+       }
+       
+       return os.str();
+    }
+
+    std::string H5GroupsList::toString(const unsigned int indentLevel) const
+    {
+
+    }
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5GroupsList.hxx b/scilab/modules/hdf5/src/cpp/H5GroupsList.hxx
new file mode 100644 (file)
index 0000000..0fc083b
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5GROUPSLIST_HXX__
+#define __H5GROUPSLIST_HXX__
+
+#include "H5NamedObjectsList.hxx"
+#include "H5Group.hxx"
+
+namespace org_modules_hdf5
+{
+
+    class H5GroupsList : public H5NamedObjectsList<H5Group>
+    {
+
+    public :
+       
+       H5GroupsList(H5Group & _parent) : H5NamedObjectsList(_parent, H5G_GROUP, "H5 Group") { }
+       
+       ~H5GroupsList()
+           {
+
+           }
+    };
+}
+
+#endif // __H5GROUPSLIST_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5LinksList.cpp b/scilab/modules/hdf5/src/cpp/H5LinksList.cpp
new file mode 100644 (file)
index 0000000..91dfb6e
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5LinksList.hxx"
+
+namespace org_modules_hdf5
+{
+    H5LinksList::H5LinksList(H5Object & _parent) : H5ListObject(_parent) { }
+
+    H5LinksList::~H5LinksList() { }
+    
+    const unsigned int H5LinksList::getSize() const
+    {
+       H5G_info_t info;
+       herr_t err = H5Gget_info(getParent().getH5Id(), &info);
+       
+       if (err < 0)
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of links."));
+       }
+
+       return (unsigned int)info.nlinks;
+    }
+
+    void H5LinksList::setObject(const unsigned int pos, H5Object & obj)
+    {
+
+    }
+
+    H5Object & H5LinksList::getObject(const int pos)
+    {
+       return getObject(pos, true);
+    }
+
+    H5Object & H5LinksList::getObject(const int pos, const bool checkPos)
+    {
+       if (checkPos)
+       {
+           unsigned int size = getSize();
+           if (pos < 0 || pos >= size)
+           {
+               throw H5Exception(__LINE__, __FILE__, _("Invalid index %u: must be between 0 and %u."), pos, size);
+           }
+       }
+           
+       H5Object * obj = 0;
+       hid_t parentId = getParent().getH5Id();
+       ssize_t nameSize = H5Gget_objname_by_idx(parentId, (hsize_t)pos, 0, 0);
+       char * name = (char *)MALLOC((nameSize + 1) * sizeof(char));
+       H5Gget_objname_by_idx(parentId, (hsize_t)pos, name, nameSize + 1);
+       int type = H5Gget_objtype_by_idx(parentId, (hsize_t)pos);
+
+       switch (type)
+       {
+       case H5G_LINK:
+           //obj = new H5Link(parent, name);
+           break;
+       case H5G_GROUP:
+           obj = new H5Group(getParent(), name);
+           break;
+       case H5G_DATASET:
+           obj = new H5Dataset(getParent(), name);
+           break;
+       case H5G_TYPE:
+           obj = new H5Type(getParent(), name);
+           break;
+       }
+
+       return *obj;
+    }
+
+    std::string H5LinksList::dump(const unsigned int indentLevel) const
+    {
+       std::ostringstream os;
+       const unsigned int size = getSize();
+
+       for (unsigned int i = 0; i < size; i++)
+       {
+           const H5Object & obj = const_cast<H5LinksList *>(this)->getObject(i, false);
+           os << obj.dump(indentLevel);
+
+           delete &obj;
+       }
+       
+       return os.str();
+    }
+
+    std::string H5LinksList::toString(const unsigned int indentLevel) const
+    {
+       return "";
+    }
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5LinksList.hxx b/scilab/modules/hdf5/src/cpp/H5LinksList.hxx
new file mode 100644 (file)
index 0000000..5cdb80d
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5LINKSLIST_HXX__
+#define __H5LINKSLIST_HXX__
+
+#include "H5Object.hxx"
+#include "H5ListObject.hxx"
+#include "H5Group.hxx"
+#include "H5Dataset.hxx"
+#include "H5Type.hxx"
+
+namespace org_modules_hdf5
+{
+    class H5Attribute;
+
+    class H5LinksList : public H5ListObject<H5Object>
+    {
+
+    public :
+       
+       H5LinksList(H5Object & _parent);
+       
+       ~H5LinksList();
+
+       void setObject(const unsigned int pos, H5Object & obj);
+       H5Object & getObject(const int pos);
+       const unsigned int getSize() const;
+       
+       virtual std::string dump(const unsigned int indentLevel) const;
+        virtual std::string toString(const unsigned int indentLevel) const;
+
+    private:
+
+       H5Object & getObject(const int pos, const bool checkPos);
+    };
+}
+
+#endif // __H5LINKSLIST_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5ListObject.hxx b/scilab/modules/hdf5/src/cpp/H5ListObject.hxx
new file mode 100644 (file)
index 0000000..9f17cb4
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5LISTOBJECT_HXX__
+#define __H5LISTOBJECT_HXX__
+
+#include "H5Object.hxx"
+
+namespace org_modules_hdf5
+{
+
+    template<typename T>
+    class H5ListObject : public H5Object
+    {
+
+    public :
+
+       H5ListObject(H5Object & _parent) : H5Object(_parent) { }
+
+        virtual void setObject(const unsigned int pos, T & object) = 0;
+        virtual T & getObject(const int pos) = 0;
+        virtual const unsigned int getSize() const = 0;
+    };
+}
+
+#endif // __H5FILE_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5NamedObjectsList.hxx b/scilab/modules/hdf5/src/cpp/H5NamedObjectsList.hxx
new file mode 100644 (file)
index 0000000..2ac3f64
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5NAMEDOBJECTSLIST_HXX__
+#define __H5NAMEDOBJECTSLIST_HXX__
+
+#include "H5Object.hxx"
+#include "H5File.hxx"
+#include "H5ListObject.hxx"
+
+namespace org_modules_hdf5
+{
+
+    class H5Group;
+
+    template <typename T>
+    class H5NamedObjectsList : public H5ListObject<T>
+    {
+
+    public :
+
+        H5NamedObjectsList(H5Group & _parent, const int _baseType, const std::string _baseTypeName) : H5ListObject<T>(_parent), baseType(_baseType), baseTypeName(_baseTypeName) { }
+
+        virtual ~H5NamedObjectsList()
+            {
+
+            }
+
+        void setObject(const unsigned int pos, T & obj)
+            {
+
+            }
+
+        T & getObject(const int pos)
+            {
+                return getObject(pos, true);
+            }
+
+        const unsigned int getSize() const
+            {
+                H5G_info_t info;
+                hsize_t count = 0;
+                hid_t parentId = H5Object::getParent().getH5Id();
+                herr_t err = H5Gget_info(parentId, &info);
+
+                if (err < 0)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of groups."));
+                }
+
+                for (hsize_t i = 0; i < info.nlinks; i++)
+                {
+                    int type = H5Gget_objtype_by_idx(parentId, i);
+                    if (type == baseType)
+                    {
+                        count++;
+                    }
+                }
+
+                return (unsigned int)count;
+            }
+
+        std::string dump(const unsigned int indentLevel) const
+            {
+                std::ostringstream os;
+                const unsigned int size = getSize();
+               
+                for (unsigned int i = 0; i < size; i++)
+                {
+                    const T & obj = const_cast<H5NamedObjectsList *>(this)->getObject(i, false);
+                    os << obj.toString(indentLevel) << std::endl;
+
+                    delete &obj;
+                }
+
+                return os.str();
+            }
+
+        virtual std::string toString(const unsigned int indentLevel) const
+            {
+                std::ostringstream os;
+               std::string indentString = H5Object::getIndentString(indentLevel);
+                const unsigned int size = getSize();
+
+                os << indentString << _("Filename") << ": " << H5Object::getParent().getFile().getFileName() << std::endl
+                   << indentString << _("Parent group name") << ": " << H5Object::getParent().getName() << std::endl
+                   << indentString << _("Parent group path") << ": " << H5Object::getParent().getCompletePath() << std::endl
+                   << indentString << _("Elements type") << ": " << baseTypeName << std::endl
+                   << indentString << _("Number of elements") << ": " << size;
+
+                return os.str();
+            }
+
+    protected :
+
+        const int baseType;
+        const std::string baseTypeName;
+
+    private:
+
+        T & getObject(const int pos, const bool checkPos)
+            {
+                int type;
+                herr_t err;
+                hsize_t count = 0;
+                hsize_t index = 0;
+                hid_t parentId = H5Object::getParent().getH5Id();
+               H5G_info_t info;
+                ssize_t nameSize;
+                char * name = 0;
+
+                if (checkPos)
+                {
+                    unsigned int size = getSize();
+                    if (pos < 0 || pos >= size)
+                    {
+                        throw H5Exception(__LINE__, __FILE__, _("Invalid index %u: must be between 0 and %u."), pos, size);
+                    }
+                }
+
+                err = H5Gget_info(parentId, &info);
+                if (err < 0)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of groups."));
+                }
+
+                for (; index < info.nlinks; index++)
+                {
+                    int type = H5Gget_objtype_by_idx(parentId, index);
+                    if (type == baseType)
+                    {
+                        count++;
+                        if (count == pos)
+                        {
+                            break;
+                        }
+                    }
+                }
+
+                nameSize = H5Gget_objname_by_idx(parentId, index, 0, 0);
+                name = (char *)MALLOC((nameSize + 1) * sizeof(char));
+                H5Gget_objname_by_idx(parentId, index, name, nameSize + 1);
+
+                return *new T(H5Object::getParent(), name);
+            }
+    };
+}
+
+#endif // __H5NAMEDOBJECTSLIST_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5Object.cpp b/scilab/modules/hdf5/src/cpp/H5Object.cpp
new file mode 100644 (file)
index 0000000..5438f2b
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5Object.hxx"
+#include "H5File.hxx"
+#include "H5Group.hxx"
+#include "H5Dataset.hxx"
+#include "H5Type.hxx"
+#include "H5AttributesList.hxx"
+
+namespace org_modules_hdf5
+{
+
+    H5Object & H5Object::root = *new H5Object();
+
+    H5Object::H5Object(H5Object & _parent) : parent(_parent), children(std::set<H5Object *>()), locked(false)
+    {
+       parent.registerChild(this);
+    }
+
+    H5Object::~H5Object()
+    {
+       locked = true;
+       for (std::set<H5Object *>::iterator it = children.begin(); it != children.end(); it++)
+       {
+           delete *it;
+       }
+       locked = false;
+       parent.unregisterChild(this);
+    }
+
+    hid_t H5Object::getH5Id() const
+    {
+       return (hid_t)-1;
+    }
+
+    H5File & H5Object::getFile() const
+    {
+       const H5Object * sobj = this;
+       const H5Object * obj = &parent;
+       while (obj != &root)
+       {
+           sobj = obj;
+           obj = &(obj->parent);
+       }
+
+       return *reinterpret_cast<H5File *>(const_cast<H5Object *>(sobj));
+    }
+
+    H5AttributesList & H5Object::getAttributes()
+    {
+       return *new H5AttributesList(*this);
+    }
+
+    H5Object & H5Object::getObject(H5Object & parent, hid_t obj)
+    {
+       H5O_info_t info;
+       herr_t err = H5Oget_info(obj, &info);
+       ssize_t size;
+       char * name = 0;
+       
+       if (err <= 0)
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Cannot retrieve informations about the object"));
+       }
+       
+       size = H5Iget_name(obj, 0, 0);
+       name = (char *)MALLOC((size + 1) * sizeof(char));
+       H5Iget_name(obj, name, size + 1);
+
+       switch (info.type)
+       {
+       case H5O_TYPE_GROUP:
+           return *new H5Group(parent, obj, name);
+       case H5O_TYPE_DATASET:
+           return *new H5Dataset(parent, obj, name);
+       case H5O_TYPE_NAMED_DATATYPE:
+           return *new H5Type(parent, obj, name);
+       case H5O_TYPE_UNKNOWN:
+       default:
+           throw H5Exception(__LINE__, __FILE__, _("Unknown HDF5 object"));
+       }
+    }
+
+    std::string H5Object::getCompletePath() const
+    {
+       std::string name = getName();
+       if (this != &root && name != "")
+       {
+           std::string path = parent.getCompletePath();
+           if (path == "/")
+           {
+               return "/" + name;
+           }
+           else
+           {
+               return path + name;
+           }
+       }
+       return "";
+    }
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5Object.hxx b/scilab/modules/hdf5/src/cpp/H5Object.hxx
new file mode 100644 (file)
index 0000000..e8ec8a8
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5OBJECT_HXX__
+#define __H5OBJECT_HXX__
+
+#include <hdf5.h>
+
+#include <iostream>
+#include <string>
+#include <set>
+#include <cstdlib>
+
+extern "C"
+{
+#include "MALLOC.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "localization.h"
+}
+
+#include "H5Exception.hxx"
+
+#define H5_INDENT_LENGTH 3
+
+namespace org_modules_hdf5
+{
+    class H5AttributesList;
+    class H5File;
+
+    class H5Object
+    {
+       static H5Object & root;
+
+       bool locked;
+       H5Object & parent;
+
+       friend class H5AttributesList;
+       friend class H5LinkList;
+       friend class H5Dataset;
+
+    public :
+       
+       H5Object(H5Object & _parent);
+       virtual ~H5Object();
+
+       virtual hid_t getH5Id() const;
+       virtual H5AttributesList & getAttributes();
+
+       virtual H5O_info_t getInfo() const
+           {
+               H5O_info_t info;
+               H5Oget_info(getH5Id(), &info);
+               
+               return info;
+           }
+
+       virtual std::string getName() const { return ""; }
+       virtual std::string getCompletePath() const;
+       virtual std::string dump(const unsigned int indentLevel = 0) const { return ""; }
+       virtual std::string toString() const { return toString(0); } 
+       virtual std::string toString(const unsigned int indentLevel) const { return ""; } 
+
+       H5Object & getParent() const { return parent; }
+       H5File & getFile() const;
+
+       static std::string getIndentString(const unsigned int indentLevel)
+           {
+               return std::string((size_t)(H5_INDENT_LENGTH * indentLevel), ' ');
+           }
+
+       static H5Object & getRoot()
+           {
+               return root;
+           }
+
+       static H5Object & getObject(H5Object & parent, hid_t obj);
+
+    protected :
+       std::set<H5Object *> children;
+       void registerChild(H5Object * child) { if (!locked) children.insert(child); }
+       void unregisterChild(H5Object * child) { if (!locked) children.erase(child); }
+
+    private :
+       H5Object() : parent(*this) { }
+    };
+}
+
+#undef H5_INDENT_LENGTH
+#endif // __H5OBJECT_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5OpaqueData.hxx b/scilab/modules/hdf5/src/cpp/H5OpaqueData.hxx
new file mode 100644 (file)
index 0000000..07a6202
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5OPAQUEDATA_HXX__
+#define __H5OPAQUEDATA_HXX__
+
+#include "H5Data.hxx"
+
+namespace org_modules_hdf5
+{
+
+    class H5OpaqueData : public H5BasicData<char>
+    {
+       
+    public:
+       
+       H5OpaqueData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5BasicData(_parent, _totalSize, _dataSize, _ndims + 1, _dims, _data, _stride, _offset, _dataOwner)
+           {
+               //dims[ndims - 1] = dataSize;
+           }
+
+       virtual ~H5OpaqueData()
+           {
+           }
+    };
+}
+
+#endif // __H5OPAQUEDATA_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5ReferenceData.hxx b/scilab/modules/hdf5/src/cpp/H5ReferenceData.hxx
new file mode 100644 (file)
index 0000000..81a112d
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5REFERENCEDATA_HXX__
+#define __H5REFERENCEDATA_HXX__
+
+#include "H5File.hxx"
+#include "H5BasicData.hxx"
+
+namespace org_modules_hdf5
+{
+
+    class H5ReferenceData : public H5BasicData<char>
+    {
+       
+       const bool datasetReference;
+       
+    public:
+       
+       H5ReferenceData(H5Object & _parent, const bool _datasetReference, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner), datasetReference(_datasetReference)
+           {
+               
+           }
+
+       virtual ~H5ReferenceData()
+           {
+               
+           }
+
+       const char ** getReferencesName() const
+           {
+               // TODO: tenir compte du stride
+               hid_t file = getFile().getH5Id();
+               char * cdata = static_cast<char *>(data) + offset;
+               const char ** names = new const char*[totalSize];
+
+               std::cout << "total=" << totalSize << std::endl;
+
+               for (int i = 0; i < totalSize; i++)
+               {
+                   void * ref = &(((void **)cdata)[i]);
+                   hid_t obj = H5Rdereference(file, datasetReference ? H5R_DATASET_REGION : H5R_OBJECT, ref);
+                   H5O_info_t info;
+                   H5Oget_info(obj, &info);
+                   std::cout << "hello=" << (((void **)cdata)[i]) << "   " << &(((void **)cdata)[i]) << std::endl;
+                   H5Oclose(obj);
+                   ssize_t size = H5Rget_name(file, datasetReference ? H5R_DATASET_REGION : H5R_OBJECT, ref, 0, 0);
+                   char * name = (char *)MALLOC((size + 1) * sizeof(char));
+                   H5Rget_name(file, datasetReference ? H5R_DATASET_REGION : H5R_OBJECT, ref, name, size + 1);
+                   
+                   names[i] = name;
+               }
+               
+               return names;
+           }
+
+       H5Object ** getReferencesObject() const
+           {
+               hid_t file = getFile().getH5Id();
+               char * cdata = static_cast<char *>(data) + offset;
+               H5Object ** objs = new H5Object *[totalSize];
+
+               for (int i = 0; i < totalSize; i++)
+               {
+                   void * ref = &(((void **)cdata)[i]);
+                   hid_t obj = H5Rdereference(file, datasetReference ? H5R_DATASET_REGION : H5R_OBJECT, ref);
+                   objs[i] = &H5Object::getObject(getParent(), obj);
+               }
+
+               return objs;
+           }
+
+       static void deleteReferencesObjects(H5Object ** objs, const unsigned int size)
+           {
+               for (unsigned int i = 0; i < size; i++)
+               {
+                   delete objs[i];
+               }
+               
+               delete[] objs;
+           }
+
+       std::string dump(const unsigned int indentLevel) const
+           {
+               getReferencesName();
+               return H5DataConverter::dump(indentLevel, ndims, dims, (void **)getData(), *this);
+               //std::cout << "zarbi=" << ndims << std::endl;
+               //return "boujou chez toi";
+           }
+
+       virtual void printData(std::ostream & os, void * data) const
+           {
+               void * ref = &data;
+               hid_t file = getFile().getH5Id();
+               hid_t obj = H5Rdereference(file, datasetReference ? H5R_DATASET_REGION : H5R_OBJECT, ref);
+               ssize_t size = H5Rget_name(file, datasetReference ? H5R_DATASET_REGION : H5R_OBJECT, ref, 0, 0);
+               char * name = (char *)MALLOC((size + 1) * sizeof(char));
+               H5O_info_t info;
+               H5Oget_info(obj, &info);
+               H5Oclose(obj);
+               H5Rget_name(file, datasetReference ? H5R_DATASET_REGION : H5R_OBJECT, ref, name, size + 1);
+               
+               switch (info.type)
+               {
+               case H5O_TYPE_GROUP:
+                   os << "GROUP ";
+                   break;
+               case H5O_TYPE_DATASET:
+                   os << "DATASET ";
+                   break;
+               case H5O_TYPE_NAMED_DATATYPE:
+                   os << "DATATYPE ";
+                   break;
+               case H5O_TYPE_UNKNOWN:
+               default:
+                   FREE(name);
+                   throw H5Exception(__LINE__, __FILE__, _("Unknown HDF5 object"));
+               }
+               
+               os << (haddr_t)data << " " << name;
+               FREE(name);
+           }
+    };
+}
+
+#endif // __H5REFERENCEDATA_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5StringData.hxx b/scilab/modules/hdf5/src/cpp/H5StringData.hxx
new file mode 100644 (file)
index 0000000..89faf43
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5STRINGDATA_HXX__
+#define __H5STRINGDATA_HXX__
+
+#include "H5BasicData.hxx"
+
+namespace org_modules_hdf5
+{
+
+    class H5StringData : public H5Data
+    {
+
+    protected:
+
+        char ** transformedData;
+
+    public:
+       
+       H5StringData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _stringSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5Data(_parent, _totalSize, _stringSize, _ndims, _dims, _data, _stride == -1 ? _stringSize : _stride, _offset, _dataOwner)
+           {
+               char * __data = static_cast<char *>(_data);
+               transformedData = new char*[totalSize];
+               
+               if (stride == -1)
+               { 
+                   *transformedData = __data;
+                   for (unsigned int i = 1; i < (unsigned int)totalSize; i++)
+                   {
+                       transformedData[i] = transformedData[i - 1] + dataSize; 
+                   }
+               }
+               else
+               {
+                   for (unsigned int i = 0; i < (unsigned int)totalSize; i++)
+                   {
+                       transformedData[i] = __data + offset;
+                       __data += stride;
+                   }
+               }
+           }
+
+       H5StringData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _stringSize, const hsize_t _ndims, const hsize_t * _dims, char ** _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5Data(_parent, _totalSize, _stringSize, _ndims, _dims, _data, _stride == -1 ? _stringSize : _stride, _offset, _dataOwner), transformedData(0)
+           {
+               
+           }
+
+       virtual ~H5StringData()
+           {
+               if (transformedData)
+               {
+                   delete[] transformedData;
+               }
+           }
+
+       virtual void * getData() const
+           {
+               if (transformedData)
+               {
+                   return transformedData;
+               }
+               else
+               {
+                   return H5Data::getData();
+               }
+           }
+
+        virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const
+            {
+                SciErr err;
+               char ** _data = static_cast<char **>(getData());
+                if (ndims == 1)
+                {
+                   H5BasicData<char>::create(pvApiCtx, lhsPosition, 1, *dims, _data, parentList, listPosition);
+                }
+                else
+                {
+                   char ** newData = new char*[totalSize];
+                    if (ndims == 2)
+                    {
+                        H5DataConverter::C2FHypermatrix(2, dims, 0, _data, newData);
+                       H5BasicData<char>::create(pvApiCtx, lhsPosition, dims[0], dims[1], newData, parentList, listPosition);
+                    }
+                    else
+                    {
+                        int * list = getHypermatrix(pvApiCtx, lhsPosition, parentList, listPosition);
+                        H5DataConverter::C2FHypermatrix(ndims, dims, (int)totalSize, _data, newData);
+                        H5BasicData<char>::create(pvApiCtx, lhsPosition, 1, (int)totalSize, newData, parentList, listPosition);
+                    }
+                   delete[] newData;
+                }
+            }
+
+        virtual std::string dump(const unsigned int indentLevel) const
+            {
+               return H5DataConverter::dump(indentLevel, ndims, dims, static_cast<char **>(getData()), *this);
+           }
+    };
+}
+
+#endif // __H5STRINGDATA_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5TimeData.hxx b/scilab/modules/hdf5/src/cpp/H5TimeData.hxx
new file mode 100644 (file)
index 0000000..4e0ad54
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5TIMEDATA_HXX__
+#define __H5TIMEDATA_HXX__
+
+#include "H5BasicData.hxx"
+
+namespace org_modules_hdf5
+{
+
+    class H5TimeData : public H5BasicData<char>
+    {
+       
+    public:
+       
+       H5TimeData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5BasicData(_parent, _totalSize, _dataSize, _ndims + 1, _dims, _data, _stride, _offset, _dataOwner)
+           {
+               //dims[ndims - 1] = dataSize;
+           }
+
+       virtual ~H5TimeData()
+           {
+           }
+    };
+}
+
+#endif // __H5TIMEDATA_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5Type.cpp b/scilab/modules/hdf5/src/cpp/H5Type.cpp
new file mode 100644 (file)
index 0000000..1a83ddf
--- /dev/null
@@ -0,0 +1,1472 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5Type.hxx"
+
+namespace org_modules_hdf5
+{
+
+    H5Type::H5Type(H5Object & _parent, const hid_t _type) : H5Object(_parent), type(_type), name(0)
+    {
+
+    }
+
+    H5Type::H5Type(H5Object & _parent, const hid_t _type, const char * _name) : H5Object(_parent), type(_type), name(_name)
+    {
+
+    }
+
+    H5Type::H5Type(H5Object & _parent, const char * _name) : H5Object(_parent), name(_name)
+    {
+       type = H5Topen2(_parent.getH5Id(), name, H5P_DEFAULT);
+       if (type < 0)
+       {
+           throw H5Exception(__LINE__, __FILE__, _("Invalid H5Type name: %s."), name);
+       }
+    }
+
+    H5Type::~H5Type()
+    {
+        if (type >= 0)
+        {
+            H5Tclose(type);
+        }
+       if (name)
+       {
+           FREE(const_cast<char *>(name));
+       }
+    }
+
+    std::string H5Type::getClassName() const
+    {
+        switch (H5Tget_class(type)) {
+        case H5T_INTEGER:
+           return "integer";
+        case H5T_FLOAT:
+           return "float";
+        case H5T_TIME:
+           return "time";
+       case H5T_STRING:
+           return "string";
+       case H5T_BITFIELD:
+           return "bitfield";
+       case H5T_OPAQUE:
+           return "opaque";
+       case H5T_COMPOUND:
+           return "compound";
+       case H5T_REFERENCE:
+           return "reference";
+       case H5T_ENUM:
+           return "enum";
+       case H5T_VLEN:
+           return "vlen";
+       case H5T_ARRAY:
+           return "array";
+       default:
+           return "unknown";
+       }
+    }
+
+    std::string H5Type::getTypeName() const
+    {
+        std::string sorder, ssign;
+        std::ostringstream os;
+        H5T_sign_t sign;
+       H5T_order_t order;
+
+       switch (H5Tget_class(type)) {
+        case H5T_INTEGER:
+            if (H5Tequal(type, H5T_STD_I8BE) > 0)
+            {
+                return "H5T_STD_I8BE";
+            }
+            else if (H5Tequal(type, H5T_STD_I8LE) > 0)
+            {
+                return "H5T_STD_I8LE";
+            }
+            else if (H5Tequal(type, H5T_STD_I16BE) > 0)
+            {
+                return "H5T_STD_I16BE";
+            }
+            else if (H5Tequal(type, H5T_STD_I16LE) > 0)
+            {
+                return "H5T_STD_I16LE";
+            }
+            else if (H5Tequal(type, H5T_STD_I32BE) > 0)
+            {
+                return "H5T_STD_I32BE";
+            }
+            else if (H5Tequal(type, H5T_STD_I32LE) > 0)
+            {
+                return "H5T_STD_I32LE";
+            }
+            else if (H5Tequal(type, H5T_STD_I64BE) > 0)
+            {
+                return "H5T_STD_I64BE";
+            }
+            else if (H5Tequal(type, H5T_STD_I64LE) > 0)
+            {
+                return "H5T_STD_I64LE";
+            }
+            else if (H5Tequal(type, H5T_STD_U8BE) > 0)
+            {
+                return "H5T_STD_U8BE";
+            }
+            else if (H5Tequal(type, H5T_STD_U8LE) > 0)
+            {
+                return "H5T_STD_U8LE";
+            }
+            else if (H5Tequal(type, H5T_STD_U16BE) > 0)
+            {
+                return "H5T_STD_U16BE";
+            }
+            else if (H5Tequal(type, H5T_STD_U16LE) > 0)
+            {
+                return "H5T_STD_U16LE";
+            }
+            else if (H5Tequal(type, H5T_STD_U32BE) > 0)
+            {
+                return "H5T_STD_U32BE";
+            }
+            else if (H5Tequal(type, H5T_STD_U32LE) > 0)
+            {
+                return "H5T_STD_U32LE";
+            }
+            else if (H5Tequal(type, H5T_STD_U64BE) > 0)
+            {
+                return "H5T_STD_U64BE";
+            }
+            else if (H5Tequal(type, H5T_STD_U64LE) > 0)
+            {
+                return "H5T_STD_U64LE";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_SCHAR) > 0)
+            {
+                return "H5T_NATIVE_SCHAR";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_UCHAR) > 0)
+            {
+                return "H5T_NATIVE_UCHAR";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_SHORT) > 0)
+            {
+                return "H5T_NATIVE_SHORT";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_USHORT) > 0)
+            {
+                return "H5T_NATIVE_USHORT";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_INT) > 0)
+            {
+                return "H5T_NATIVE_INT";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_UINT) > 0)
+            {
+                return "H5T_NATIVE_UINT";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_LONG) > 0)
+            {
+                return "H5T_NATIVE_LONG";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_ULONG) > 0)
+            {
+                return "H5T_NATIVE_ULONG";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_LLONG) > 0)
+            {
+                return "H5T_NATIVE_LLONG";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_ULLONG) > 0)
+            {
+                return "H5T_NATIVE_ULLONG";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT8) > 0)
+            {
+                return "H5T_NATIVE_INT8";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT8) > 0)
+            {
+                return "H5T_NATIVE_UINT8";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_LEAST8) > 0)
+            {
+                return "H5T_NATIVE_INT_LEAST8";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST8) > 0)
+            {
+                return "H5T_NATIVE_UINT_LEAST8";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_FAST8) > 0)
+            {
+                return "H5T_NATIVE_INT_FAST8";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_FAST8) > 0)
+            {
+                return "H5T_NATIVE_UINT_FAST8";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT16) > 0)
+            {
+                return "H5T_NATIVE_INT16";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT16) > 0)
+            {
+                return "H5T_NATIVE_UINT16";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_LEAST16) > 0)
+            {
+                return "H5T_NATIVE_INT_LEAST16";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST16) > 0)
+            {
+                return "H5T_NATIVE_UINT_LEAST16";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_FAST16) > 0)
+            {
+                return "H5T_NATIVE_INT_FAST16";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_FAST16) > 0)
+            {
+                return "H5T_NATIVE_UINT_FAST16";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT32) > 0)
+            {
+                return "H5T_NATIVE_INT32";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT32) > 0)
+            {
+                return "H5T_NATIVE_UINT32";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_LEAST32) > 0)
+            {
+                return "H5T_NATIVE_INT_LEAST32";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST32) > 0)
+            {
+                return "H5T_NATIVE_UINT_LEAST32";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_FAST32) > 0)
+            {
+                return "H5T_NATIVE_INT_FAST32";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_FAST32) > 0)
+            {
+                return "H5T_NATIVE_UINT_FAST32";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT64) > 0)
+            {
+                return "H5T_NATIVE_INT64";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT64) > 0)
+            {
+                return "H5T_NATIVE_UINT64";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_LEAST64) > 0)
+            {
+                return "H5T_NATIVE_INT_LEAST64";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST64) > 0)
+            {
+                return "H5T_NATIVE_UINT_LEAST64";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_FAST64) > 0)
+            {
+                return "H5T_NATIVE_INT_FAST64";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_FAST64) > 0)
+            {
+                return "H5T_NATIVE_UINT_FAST64";
+            }
+           else if (H5Tequal(type, H5T_INTEL_I8) > 0)
+            {
+                return "H5T_INTEL_I8";
+            }
+            else if (H5Tequal(type, H5T_INTEL_I16) > 0)
+            {
+                return "H5T_INTEL_I16";
+            }
+            else if (H5Tequal(type, H5T_INTEL_I32) > 0)
+            {
+                return "H5T_INTEL_I32";
+            }
+            else if (H5Tequal(type, H5T_INTEL_I64) > 0)
+            {
+                return "H5T_INTEL_I64";
+            }
+            else if (H5Tequal(type, H5T_INTEL_U8) > 0)
+            {
+                return "H5T_INTEL_U8";
+            }
+            else if (H5Tequal(type, H5T_INTEL_U16) > 0)
+            {
+                return "H5T_INTEL_U16";
+            }
+            else if (H5Tequal(type, H5T_INTEL_U32) > 0)
+            {
+                return "H5T_INTEL_U32";
+            }
+            else if (H5Tequal(type, H5T_INTEL_U64) > 0)
+            {
+                return "H5T_INTEL_U64";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_I8) > 0)
+            {
+                return "H5T_ALPHA_I8";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_I16) > 0)
+            {
+                return "H5T_ALPHA_I16";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_I32) > 0)
+            {
+                return "H5T_ALPHA_I32";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_I64) > 0)
+            {
+                return "H5T_ALPHA_I64";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_U8) > 0)
+            {
+                return "H5T_ALPHA_U8";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_U16) > 0)
+            {
+                return "H5T_ALPHA_U16";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_U32) > 0)
+            {
+                return "H5T_ALPHA_U32";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_U64) > 0)
+            {
+                return "H5T_ALPHA_U64";
+            }
+            else if (H5Tequal(type, H5T_MIPS_I8) > 0)
+            {
+                return "H5T_MIPS_I8";
+            }
+            else if (H5Tequal(type, H5T_MIPS_I16) > 0)
+            {
+                return "H5T_MIPS_I16";
+            }
+            else if (H5Tequal(type, H5T_MIPS_I32) > 0)
+            {
+                return "H5T_MIPS_I32";
+            }
+            else if (H5Tequal(type, H5T_MIPS_I64) > 0)
+            {
+                return "H5T_MIPS_I64";
+            }
+            else if (H5Tequal(type, H5T_MIPS_U8) > 0)
+            {
+                return "H5T_MIPS_U8";
+            }
+            else if (H5Tequal(type, H5T_MIPS_U16) > 0)
+            {
+                return "H5T_MIPS_U16";
+            }
+            else if (H5Tequal(type, H5T_MIPS_U32) > 0)
+            {
+                return "H5T_MIPS_U32";
+            }
+            else if (H5Tequal(type, H5T_MIPS_U64) > 0)
+            {
+                return "H5T_MIPS_U64";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_HADDR) > 0)
+            {
+                return "H5T_NATIVE_HADDR";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_HSIZE) > 0)
+            {
+                return "H5T_NATIVE_HSIZE";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_HSSIZE) > 0)
+            {
+                return "H5T_NATIVE_HSSIZE";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_HERR) > 0)
+            {
+                return "H5T_NATIVE_HERR";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_HBOOL) > 0)
+            {
+                return "H5T_NATIVE_HBOOL";
+            }
+            else 
+            {
+                if (H5Tget_size(type) > 1)
+                {
+                    order = H5Tget_order(type);
+                    if (H5T_ORDER_LE == order)
+                    {
+                        sorder = " little-endian";
+                    }
+                    else if (H5T_ORDER_BE == order)
+                    {
+                        sorder = " big-endian";
+                    }
+                    else if (H5T_ORDER_VAX == order)
+                    {
+                        sorder = " mixed-endian";
+                    }
+                    else
+                    {
+                        sorder = " unknown-byte-order";
+                    }
+                }
+                else
+                {
+                    sorder = "";
+                }
+
+                sign = H5Tget_sign(type);
+                if (sign >= 0)
+                {
+                    if (sign == H5T_SGN_NONE)
+                    {
+                        ssign = " unsigned";
+                    }
+                    else if (sign == H5T_SGN_2)
+                    {
+                        ssign = "";
+                    }
+                    else
+                    {
+                        ssign = " unknown-sign";
+                    }
+                }
+                else
+                {
+                    ssign = " unknown-sign";
+                }
+
+                os << (unsigned long)(8 * H5Tget_size(type)) << "-bit"
+                   << sorder
+                   << ssign
+                   << " integer";
+
+               return os.str();
+            }
+            break;
+        case H5T_FLOAT:
+            if (H5Tequal(type, H5T_IEEE_F32BE) > 0)
+            {
+                return "H5T_IEEE_F32BE";
+            }
+            else if (H5Tequal(type, H5T_IEEE_F32LE) > 0)
+            {
+                return "H5T_IEEE_F32LE";
+            }
+            else if (H5Tequal(type, H5T_IEEE_F64BE) > 0)
+            {
+                return "H5T_IEEE_F64BE";
+            }
+            else if (H5Tequal(type, H5T_IEEE_F64LE) > 0)
+            {
+                return "H5T_IEEE_F64LE";
+            }
+            else if (H5Tequal(type, H5T_VAX_F32) > 0)
+            {
+                return "H5T_VAX_F32";
+            }
+            else if (H5Tequal(type, H5T_VAX_F64) > 0)
+            {
+                return "H5T_VAX_F64";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_FLOAT) > 0)
+            {
+                return "H5T_NATIVE_FLOAT";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_DOUBLE) > 0)
+            {
+                return "H5T_NATIVE_DOUBLE";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_LDOUBLE) > 0)
+            {
+                return "H5T_NATIVE_LDOUBLE";
+            }
+            else if (H5Tequal(type, H5T_INTEL_F32) > 0)
+            {
+                return "H5T_INTEL_F32";
+            }
+            else if (H5Tequal(type, H5T_INTEL_F64) > 0)
+            {
+                return "H5T_INTEL_F64";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_F32) > 0)
+            {
+                return "H5T_ALPHA_F32";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_F64) > 0)
+            {
+                return "H5T_ALPHA_F64";
+            }
+            else if (H5Tequal(type, H5T_VAX_F32) > 0)
+            {
+                return "H5T_VAX_F32";
+            }
+            else if (H5Tequal(type, H5T_VAX_F64) > 0)
+            {
+                return "H5T_VAX_F64";
+            }
+            else if (H5Tequal(type, H5T_MIPS_F32) > 0)
+            {
+                return "H5T_MIPS_F32";
+            }
+            else if (H5Tequal(type, H5T_MIPS_F64) > 0)
+            {
+                return "H5T_MIPS_F64";
+            }
+            else 
+            {
+                if (H5Tget_size(type) > 1)
+                {
+                    order = H5Tget_order(type);
+                    if (order == H5T_ORDER_LE)
+                    {
+                        sorder = " little-endian";
+                    }
+                    else if (order == H5T_ORDER_BE)
+                    {
+                        sorder = " big-endian";
+                    }
+                    else if (order == H5T_ORDER_VAX)
+                    {
+                        sorder = " mixed-endian";
+                    }
+                    else
+                    {
+                        sorder = " unknown-byte-order";
+                    }
+                }
+                else
+                {
+                    sorder = "";
+                }
+
+                os << (unsigned long)(8 * H5Tget_size(type)) << "-bit"
+                   << sorder
+                   << " floating-point";
+
+               return os.str();
+            }
+            break;
+        case H5T_TIME:
+            if (H5Tequal(type, H5T_UNIX_D32BE) > 0)
+            {
+                return "H5T_UNIX_D32BE";
+            }
+            else if (H5Tequal(type, H5T_UNIX_D32LE) > 0)
+            {
+                return "H5T_UNIX_D32LE";
+            }
+            else if (H5Tequal(type, H5T_UNIX_D64BE) > 0)
+            {
+                return "H5T_UNIX_D64BE";
+            }
+            else if (H5Tequal(type, H5T_UNIX_D64LE) > 0)
+            {
+                return "H5T_UNIX_D64LE";
+            }
+            else
+            {
+                return "Unknown time format";
+            }
+            break;
+        case H5T_STRING:
+           return "H5T_STRING";
+            break;
+        case H5T_BITFIELD:
+            if (H5Tequal(type, H5T_STD_B8BE) > 0)
+            {
+                return "H5T_STD_B8BE";
+            }
+            else if (H5Tequal(type, H5T_STD_B8LE) > 0)
+            {
+                return "H5T_STD_B8LE";
+            }
+            else if (H5Tequal(type, H5T_STD_B16BE) > 0)
+            {
+                return "H5T_STD_B16BE";
+            }
+            else if (H5Tequal(type, H5T_STD_B16LE) > 0)
+            {
+                return "H5T_STD_B16LE";
+            }
+            else if (H5Tequal(type, H5T_STD_B32BE) > 0)
+            {
+                return "H5T_STD_B32BE";
+            }
+            else if (H5Tequal(type, H5T_STD_B32LE) > 0)
+            {
+                return "H5T_STD_B32LE";
+            }
+            else if (H5Tequal(type, H5T_STD_B64BE) > 0)
+            {
+                return "H5T_STD_B64BE";
+            }
+            else if (H5Tequal(type, H5T_STD_B64LE) > 0)
+            {
+                return "H5T_STD_B64LE";
+            }
+           else if (H5Tequal(type, H5T_INTEL_B8) > 0)
+            {
+                return "H5T_INTEL_B8";
+            }
+           else if (H5Tequal(type, H5T_INTEL_B16) > 0)
+            {
+                return "H5T_INTEL_B16";
+            }
+           else if (H5Tequal(type, H5T_INTEL_B32) > 0)
+            {
+                return "H5T_INTEL_B32";
+            }
+           else if (H5Tequal(type, H5T_INTEL_B64) > 0)
+            {
+                return "H5T_INTEL_B64";
+            }
+           else if (H5Tequal(type, H5T_ALPHA_B8) > 0)
+            {
+                return "H5T_ALPHA_B8";
+            }
+           else if (H5Tequal(type, H5T_ALPHA_B16) > 0)
+            {
+                return "H5T_ALPHA_B16";
+            }
+           else if (H5Tequal(type, H5T_ALPHA_B32) > 0)
+            {
+                return "H5T_ALPHA_B32";
+            }
+           else if (H5Tequal(type, H5T_ALPHA_B64) > 0)
+            {
+                return "H5T_ALPHA_B64";
+            }
+           else if (H5Tequal(type, H5T_MIPS_B8) > 0)
+            {
+                return "H5T_MIPS_B8";
+            }
+           else if (H5Tequal(type, H5T_MIPS_B16) > 0)
+            {
+                return "H5T_MIPS_B16";
+            }
+           else if (H5Tequal(type, H5T_MIPS_B32) > 0)
+            {
+                return "H5T_MIPS_B32";
+            }
+           else if (H5Tequal(type, H5T_MIPS_B64) > 0)
+            {
+                return "H5T_MIPS_B64";
+            }
+           else 
+           {
+                return "undefined bitfield";
+            }
+        case H5T_OPAQUE:
+           return "H5T_OPAQUE";
+        case H5T_COMPOUND:
+           return "H5T_COMPOUND";
+        case H5T_REFERENCE:
+           if (H5Tequal(type, H5T_STD_REF_DSETREG) > 0)
+           {
+               return "H5T_STD_REF_DSETREG";
+           }
+           else
+           {
+               return "H5T_STD_REF_OBJECT";
+           }
+            break;
+        case H5T_ENUM:
+           return "H5T_ENUM";
+        case H5T_VLEN:
+           return "H5T_VLEN";
+        case H5T_ARRAY:
+           return "H5T_ARRAY";
+        default:
+           return _("Unknown datatype");
+        }
+    }
+
+    std::string H5Type::dump(const unsigned int indentLevel) const
+    {
+        std::string sorder, ssign;
+        std::ostringstream os;
+        H5T_sign_t sign;
+       hsize_t * dims = 0;
+       unsigned int ndims;
+       hid_t strType;
+       hid_t super;
+       size_t size;
+       unsigned int nmembers;
+       H5T_order_t order;
+       H5T_str_t strpad;
+       H5T_cset_t cset;
+       htri_t isVariableLength;
+       std::string indent;
+       char * opaqueTag = 0;
+
+       os << H5Object::getIndentString(indentLevel);
+
+       if (name)
+       {
+           os << "DATATYPE \"" << name << "\" ";
+       }
+       else
+       {
+           os << "DATATYPE ";
+       }
+
+        switch (H5Tget_class(type)) {
+        case H5T_INTEGER:
+            if (H5Tequal(type, H5T_STD_I8BE) > 0)
+            {
+                os << "H5T_STD_I8BE";
+            }
+            else if (H5Tequal(type, H5T_STD_I8LE) > 0)
+            {
+                os << "H5T_STD_I8LE";
+            }
+            else if (H5Tequal(type, H5T_STD_I16BE) > 0)
+            {
+                os << "H5T_STD_I16BE";
+            }
+            else if (H5Tequal(type, H5T_STD_I16LE) > 0)
+            {
+                os << "H5T_STD_I16LE";
+            }
+            else if (H5Tequal(type, H5T_STD_I32BE) > 0)
+            {
+                os << "H5T_STD_I32BE";
+            }
+            else if (H5Tequal(type, H5T_STD_I32LE) > 0)
+            {
+                os << "H5T_STD_I32LE";
+            }
+            else if (H5Tequal(type, H5T_STD_I64BE) > 0)
+            {
+                os << "H5T_STD_I64BE";
+            }
+            else if (H5Tequal(type, H5T_STD_I64LE) > 0)
+            {
+                os << "H5T_STD_I64LE";
+            }
+            else if (H5Tequal(type, H5T_STD_U8BE) > 0)
+            {
+                os << "H5T_STD_U8BE";
+            }
+            else if (H5Tequal(type, H5T_STD_U8LE) > 0)
+            {
+                os << "H5T_STD_U8LE";
+            }
+            else if (H5Tequal(type, H5T_STD_U16BE) > 0)
+            {
+                os << "H5T_STD_U16BE";
+            }
+            else if (H5Tequal(type, H5T_STD_U16LE) > 0)
+            {
+                os << "H5T_STD_U16LE";
+            }
+            else if (H5Tequal(type, H5T_STD_U32BE) > 0)
+            {
+                os << "H5T_STD_U32BE";
+            }
+            else if (H5Tequal(type, H5T_STD_U32LE) > 0)
+            {
+                os << "H5T_STD_U32LE";
+            }
+            else if (H5Tequal(type, H5T_STD_U64BE) > 0)
+            {
+                os << "H5T_STD_U64BE";
+            }
+            else if (H5Tequal(type, H5T_STD_U64LE) > 0)
+            {
+                os << "H5T_STD_U64LE";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_SCHAR) > 0)
+            {
+                os << "H5T_NATIVE_SCHAR";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_UCHAR) > 0)
+            {
+                os << "H5T_NATIVE_UCHAR";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_SHORT) > 0)
+            {
+                os << "H5T_NATIVE_SHORT";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_USHORT) > 0)
+            {
+                os << "H5T_NATIVE_USHORT";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_INT) > 0)
+            {
+                os << "H5T_NATIVE_INT";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_UINT) > 0)
+            {
+                os << "H5T_NATIVE_UINT";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_LONG) > 0)
+            {
+                os << "H5T_NATIVE_LONG";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_ULONG) > 0)
+            {
+                os << "H5T_NATIVE_ULONG";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_LLONG) > 0)
+            {
+                os << "H5T_NATIVE_LLONG";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_ULLONG) > 0)
+            {
+                os << "H5T_NATIVE_ULLONG";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT8) > 0)
+            {
+                os << "H5T_NATIVE_INT8";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT8) > 0)
+            {
+                os << "H5T_NATIVE_UINT8";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_LEAST8) > 0)
+            {
+                os << "H5T_NATIVE_INT_LEAST8";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST8) > 0)
+            {
+                os << "H5T_NATIVE_UINT_LEAST8";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_FAST8) > 0)
+            {
+                os << "H5T_NATIVE_INT_FAST8";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_FAST8) > 0)
+            {
+                os << "H5T_NATIVE_UINT_FAST8";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT16) > 0)
+            {
+                os << "H5T_NATIVE_INT16";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT16) > 0)
+            {
+                os << "H5T_NATIVE_UINT16";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_LEAST16) > 0)
+            {
+                os << "H5T_NATIVE_INT_LEAST16";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST16) > 0)
+            {
+                os << "H5T_NATIVE_UINT_LEAST16";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_FAST16) > 0)
+            {
+                os << "H5T_NATIVE_INT_FAST16";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_FAST16) > 0)
+            {
+                os << "H5T_NATIVE_UINT_FAST16";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT32) > 0)
+            {
+                os << "H5T_NATIVE_INT32";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT32) > 0)
+            {
+                os << "H5T_NATIVE_UINT32";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_LEAST32) > 0)
+            {
+                os << "H5T_NATIVE_INT_LEAST32";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST32) > 0)
+            {
+                os << "H5T_NATIVE_UINT_LEAST32";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_FAST32) > 0)
+            {
+                os << "H5T_NATIVE_INT_FAST32";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_FAST32) > 0)
+            {
+                os << "H5T_NATIVE_UINT_FAST32";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT64) > 0)
+            {
+                os << "H5T_NATIVE_INT64";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT64) > 0)
+            {
+                os << "H5T_NATIVE_UINT64";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_LEAST64) > 0)
+            {
+                os << "H5T_NATIVE_INT_LEAST64";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST64) > 0)
+            {
+                os << "H5T_NATIVE_UINT_LEAST64";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_INT_FAST64) > 0)
+            {
+                os << "H5T_NATIVE_INT_FAST64";
+            }
+           else if (H5Tequal(type, H5T_NATIVE_UINT_FAST64) > 0)
+            {
+                os << "H5T_NATIVE_UINT_FAST64";
+            }
+           else if (H5Tequal(type, H5T_INTEL_I8) > 0)
+            {
+                os << "H5T_INTEL_I8";
+            }
+            else if (H5Tequal(type, H5T_INTEL_I16) > 0)
+            {
+                os << "H5T_INTEL_I16";
+            }
+            else if (H5Tequal(type, H5T_INTEL_I32) > 0)
+            {
+                os << "H5T_INTEL_I32";
+            }
+            else if (H5Tequal(type, H5T_INTEL_I64) > 0)
+            {
+                os << "H5T_INTEL_I64";
+            }
+            else if (H5Tequal(type, H5T_INTEL_U8) > 0)
+            {
+                os << "H5T_INTEL_U8";
+            }
+            else if (H5Tequal(type, H5T_INTEL_U16) > 0)
+            {
+                os << "H5T_INTEL_U16";
+            }
+            else if (H5Tequal(type, H5T_INTEL_U32) > 0)
+            {
+                os << "H5T_INTEL_U32";
+            }
+            else if (H5Tequal(type, H5T_INTEL_U64) > 0)
+            {
+                os << "H5T_INTEL_U64";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_I8) > 0)
+            {
+                os << "H5T_ALPHA_I8";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_I16) > 0)
+            {
+                os << "H5T_ALPHA_I16";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_I32) > 0)
+            {
+                os << "H5T_ALPHA_I32";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_I64) > 0)
+            {
+                os << "H5T_ALPHA_I64";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_U8) > 0)
+            {
+                os << "H5T_ALPHA_U8";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_U16) > 0)
+            {
+                os << "H5T_ALPHA_U16";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_U32) > 0)
+            {
+                os << "H5T_ALPHA_U32";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_U64) > 0)
+            {
+                os << "H5T_ALPHA_U64";
+            }
+            else if (H5Tequal(type, H5T_MIPS_I8) > 0)
+            {
+                os << "H5T_MIPS_I8";
+            }
+            else if (H5Tequal(type, H5T_MIPS_I16) > 0)
+            {
+                os << "H5T_MIPS_I16";
+            }
+            else if (H5Tequal(type, H5T_MIPS_I32) > 0)
+            {
+                os << "H5T_MIPS_I32";
+            }
+            else if (H5Tequal(type, H5T_MIPS_I64) > 0)
+            {
+                os << "H5T_MIPS_I64";
+            }
+            else if (H5Tequal(type, H5T_MIPS_U8) > 0)
+            {
+                os << "H5T_MIPS_U8";
+            }
+            else if (H5Tequal(type, H5T_MIPS_U16) > 0)
+            {
+                os << "H5T_MIPS_U16";
+            }
+            else if (H5Tequal(type, H5T_MIPS_U32) > 0)
+            {
+                os << "H5T_MIPS_U32";
+            }
+            else if (H5Tequal(type, H5T_MIPS_U64) > 0)
+            {
+                os << "H5T_MIPS_U64";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_HADDR) > 0)
+            {
+                os << "H5T_NATIVE_HADDR";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_HSIZE) > 0)
+            {
+                os << "H5T_NATIVE_HSIZE";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_HSSIZE) > 0)
+            {
+                os << "H5T_NATIVE_HSSIZE";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_HERR) > 0)
+            {
+                os << "H5T_NATIVE_HERR";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_HBOOL) > 0)
+            {
+                os << "H5T_NATIVE_HBOOL";
+            }
+            else 
+            {
+                if (H5Tget_size(type) > 1)
+                {
+                    order = H5Tget_order(type);
+                    if (H5T_ORDER_LE == order)
+                    {
+                        sorder = " little-endian";
+                    }
+                    else if (H5T_ORDER_BE == order)
+                    {
+                        sorder = " big-endian";
+                    }
+                    else if (H5T_ORDER_VAX == order)
+                    {
+                        sorder = " mixed-endian";
+                    }
+                    else
+                    {
+                        sorder = " unknown-byte-order";
+                    }
+                }
+                else
+                {
+                    sorder = "";
+                }
+
+                sign = H5Tget_sign(type);
+                if (sign >= 0)
+                {
+                    if (sign == H5T_SGN_NONE)
+                    {
+                        ssign = " unsigned";
+                    }
+                    else if (sign == H5T_SGN_2)
+                    {
+                        ssign = "";
+                    }
+                    else
+                    {
+                        ssign = " unknown-sign";
+                    }
+                }
+                else
+                {
+                    ssign = " unknown-sign";
+                }
+
+                os << (unsigned long)(8 * H5Tget_size(type)) << "-bit"
+                   << sorder
+                   << ssign
+                   << " integer";
+            }
+            break;
+        case H5T_FLOAT:
+            if (H5Tequal(type, H5T_IEEE_F32BE) > 0)
+            {
+                os << "H5T_IEEE_F32BE";
+            }
+            else if (H5Tequal(type, H5T_IEEE_F32LE) > 0)
+            {
+                os << "H5T_IEEE_F32LE";
+            }
+            else if (H5Tequal(type, H5T_IEEE_F64BE) > 0)
+            {
+                os << "H5T_IEEE_F64BE";
+            }
+            else if (H5Tequal(type, H5T_IEEE_F64LE) > 0)
+            {
+                os << "H5T_IEEE_F64LE";
+            }
+            else if (H5Tequal(type, H5T_VAX_F32) > 0)
+            {
+                os << "H5T_VAX_F32";
+            }
+            else if (H5Tequal(type, H5T_VAX_F64) > 0)
+            {
+                os << "H5T_VAX_F64";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_FLOAT) > 0)
+            {
+                os << "H5T_NATIVE_FLOAT";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_DOUBLE) > 0)
+            {
+                os << "H5T_NATIVE_DOUBLE";
+            }
+            else if (H5Tequal(type, H5T_NATIVE_LDOUBLE) > 0)
+            {
+                os << "H5T_NATIVE_LDOUBLE";
+            }
+            else if (H5Tequal(type, H5T_INTEL_F32) > 0)
+            {
+                os << "H5T_INTEL_F32";
+            }
+            else if (H5Tequal(type, H5T_INTEL_F64) > 0)
+            {
+                os << "H5T_INTEL_F64";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_F32) > 0)
+            {
+                os << "H5T_ALPHA_F32";
+            }
+            else if (H5Tequal(type, H5T_ALPHA_F64) > 0)
+            {
+                os << "H5T_ALPHA_F64";
+            }
+            else if (H5Tequal(type, H5T_VAX_F32) > 0)
+            {
+                os << "H5T_VAX_F32";
+            }
+            else if (H5Tequal(type, H5T_VAX_F64) > 0)
+            {
+                os << "H5T_VAX_F64";
+            }
+            else if (H5Tequal(type, H5T_MIPS_F32) > 0)
+            {
+                os << "H5T_MIPS_F32";
+            }
+            else if (H5Tequal(type, H5T_MIPS_F64) > 0)
+            {
+                os << "H5T_MIPS_F64";
+            }
+            else 
+            {
+                if (H5Tget_size(type) > 1)
+                {
+                    order = H5Tget_order(type);
+                    if (order == H5T_ORDER_LE)
+                    {
+                        sorder = " little-endian";
+                    }
+                    else if (order == H5T_ORDER_BE)
+                    {
+                        sorder = " big-endian";
+                    }
+                    else if (order == H5T_ORDER_VAX)
+                    {
+                        sorder = " mixed-endian";
+                    }
+                    else
+                    {
+                        sorder = " unknown-byte-order";
+                    }
+                }
+                else
+                {
+                    sorder = "";
+                }
+
+                os << (unsigned long)(8 * H5Tget_size(type)) << "-bit"
+                   << sorder
+                   << " floating-point";
+            }
+            break;
+        case H5T_TIME:
+            if (H5Tequal(type, H5T_UNIX_D32BE) > 0)
+            {
+                os << "H5T_UNIX_D32BE";
+            }
+            else if (H5Tequal(type, H5T_UNIX_D32LE) > 0)
+            {
+                os << "H5T_UNIX_D32LE";
+            }
+            else if (H5Tequal(type, H5T_UNIX_D64BE) > 0)
+            {
+                os << "H5T_UNIX_D64BE";
+            }
+            else if (H5Tequal(type, H5T_UNIX_D64LE) > 0)
+            {
+                os << "H5T_UNIX_D64LE";
+            }
+            else
+            {
+                os << "Unknown time format";
+            }
+            break;
+        case H5T_STRING:
+            size = H5Tget_size(type);
+            strpad = H5Tget_strpad(type);
+            cset = H5Tget_cset(type);
+            isVariableLength = H5Tis_variable_str(type);
+           indent = H5Object::getIndentString(indentLevel + 1);
+
+           strType = H5Tcopy(H5T_C_S1);
+           H5Tset_size(strType, isVariableLength ? H5T_VARIABLE : size); 
+           H5Tset_cset(strType, cset);
+           H5Tset_strpad(strType, strpad);
+
+           os << "H5T_STRING {" << std::endl;
+           if (isVariableLength)
+           {
+               os << indent << "STRSIZE H5T_VARIABLE;" << std::endl;
+           }
+           else
+           {
+               os << indent << "STRSIZE " << (int)size << ";" << std::endl;
+           }
+
+           os << indent << "STRPAD ";
+           switch (strpad)
+           {
+           case H5T_STR_NULLTERM:
+               os << "H5T_STR_NULLTERM;" << std::endl;
+               break;
+           case H5T_STR_NULLPAD:
+               os << "H5T_STR_NULLPAD;" << std::endl;
+               break;
+           case H5T_STR_SPACEPAD:
+               os << "H5T_STR_SPACEPAD;" << std::endl;
+               break;
+           default:
+               os << "H5T_STR_ERROR;" << std::endl;
+               break;
+           }
+
+           os << indent << "CSET ";
+           if (cset == H5T_CSET_ASCII)
+           {
+               os << "H5T_CSET_ASCII;" << std::endl;
+           }
+           else if (cset == H5T_CSET_UTF8)
+           {
+               os << "H5T_CSET_UTF8;" << std::endl;
+           }
+           else
+           {
+               os << "Unknown charset;" << std::endl;
+           }
+
+           // TODO: modif l'endianess (cf h5dump.c::1068)
+           os << indent << "CTYPE ";
+           if (H5Tequal(type, strType) > 0)
+           {
+               H5Tclose(strType);
+               os << "H5T_C_S1;" << std::endl;
+           }
+           else
+           {
+               H5Tclose(strType);
+               strType = H5Tcopy(H5T_FORTRAN_S1);
+               H5Tset_size(strType, size); 
+               H5Tset_cset(strType, cset);
+               H5Tset_strpad(strType, strpad);
+               if (H5Tequal(type, H5T_FORTRAN_S1) > 0)
+               {
+                   os << "H5T_FORTRAN_S1;" << std::endl;
+               }
+               else
+               {
+                   os << "Unknown one character type;" << std::endl;
+               }
+           }
+           
+           os << H5Object::getIndentString(indentLevel) << "}";
+            break;
+        case H5T_BITFIELD:
+            if (H5Tequal(type, H5T_STD_B8BE) > 0)
+            {
+                os << "H5T_STD_B8BE";
+            }
+            else if (H5Tequal(type, H5T_STD_B8LE) > 0)
+            {
+                os << "H5T_STD_B8LE";
+            }
+            else if (H5Tequal(type, H5T_STD_B16BE) > 0)
+            {
+                os << "H5T_STD_B16BE";
+            }
+            else if (H5Tequal(type, H5T_STD_B16LE) > 0)
+            {
+                os << "H5T_STD_B16LE";
+            }
+            else if (H5Tequal(type, H5T_STD_B32BE) > 0)
+            {
+                os << "H5T_STD_B32BE";
+            }
+            else if (H5Tequal(type, H5T_STD_B32LE) > 0)
+            {
+                os << "H5T_STD_B32LE";
+            }
+            else if (H5Tequal(type, H5T_STD_B64BE) > 0)
+            {
+                os << "H5T_STD_B64BE";
+            }
+            else if (H5Tequal(type, H5T_STD_B64LE) > 0)
+            {
+                os << "H5T_STD_B64LE";
+            }
+           else if (H5Tequal(type, H5T_INTEL_B8) > 0)
+            {
+                os << "H5T_INTEL_B8";
+            }
+           else if (H5Tequal(type, H5T_INTEL_B16) > 0)
+            {
+                os << "H5T_INTEL_B16";
+            }
+           else if (H5Tequal(type, H5T_INTEL_B32) > 0)
+            {
+                os << "H5T_INTEL_B32";
+            }
+           else if (H5Tequal(type, H5T_INTEL_B64) > 0)
+            {
+                os << "H5T_INTEL_B64";
+            }
+           else if (H5Tequal(type, H5T_ALPHA_B8) > 0)
+            {
+                os << "H5T_ALPHA_B8";
+            }
+           else if (H5Tequal(type, H5T_ALPHA_B16) > 0)
+            {
+                os << "H5T_ALPHA_B16";
+            }
+           else if (H5Tequal(type, H5T_ALPHA_B32) > 0)
+            {
+                os << "H5T_ALPHA_B32";
+            }
+           else if (H5Tequal(type, H5T_ALPHA_B64) > 0)
+            {
+                os << "H5T_ALPHA_B64";
+            }
+           else if (H5Tequal(type, H5T_MIPS_B8) > 0)
+            {
+                os << "H5T_MIPS_B8";
+            }
+           else if (H5Tequal(type, H5T_MIPS_B16) > 0)
+            {
+                os << "H5T_MIPS_B16";
+            }
+           else if (H5Tequal(type, H5T_MIPS_B32) > 0)
+            {
+                os << "H5T_MIPS_B32";
+            }
+           else if (H5Tequal(type, H5T_MIPS_B64) > 0)
+            {
+                os << "H5T_MIPS_B64";
+            }
+           else 
+           {
+                os << "undefined bitfield";
+            }
+            break;
+        case H5T_OPAQUE:
+           opaqueTag = H5Tget_tag(type);
+            os << "H5T_OPAQUE;" << std::endl
+              << H5Object::getIndentString(indentLevel + 1)
+              << "OPAQUE TAG \"" << opaqueTag << "\";";
+           
+           free(opaqueTag);
+            break;
+        case H5T_COMPOUND:
+            nmembers = H5Tget_nmembers(type);
+           os << "H5T_COMPOUND {" << std::endl;
+
+            for (unsigned int i = 0; i < nmembers; i++)
+            {
+                char * mname = H5Tget_member_name(type, i);
+                hid_t mtype = H5Tget_member_type(type, i);
+               
+               os << H5Type(*const_cast<H5Type *>(this), mtype).dump(0) 
+                  << " " << "\"" << mname << "\";" << std::endl;
+
+               free(mname);
+            }
+
+           os << H5Object::getIndentString(indentLevel) << "}";
+            break;
+        case H5T_REFERENCE:
+           os << "H5T_REFERENCE";
+           if (H5Tequal(type, H5T_STD_REF_DSETREG) > 0)
+           {
+               os << " { H5T_STD_REF_DSETREG }";
+           }
+           else
+           {
+               os << " { H5T_STD_REF_OBJECT }";
+           }
+            break;
+        case H5T_ENUM:
+           // TODO : c'est pas bien ca: il faut print les key->values.
+           os << "H5T_ENUM { "
+              << H5Type(*const_cast<H5Type *>(this), H5Tget_super(type)).dump(0) << std::endl
+              << H5Object::getIndentString(indentLevel) << "}";
+            break;
+        case H5T_VLEN:
+           os << "H5T_VLEN { "
+              << H5Type(*const_cast<H5Type *>(this), H5Tget_super(type)).dump(0) << std::endl
+              << H5Object::getIndentString(indentLevel) << "}";
+            break;
+        case H5T_ARRAY:
+            super = H5Tget_super(type);
+            ndims = H5Tget_array_ndims(type);
+           dims = new hsize_t[ndims];
+            H5Tget_array_dims2(type, dims);
+
+           os << "H5T_ARRAY { ";
+
+            for (unsigned int i = 0; i < ndims; i++)
+           {
+               os << "[" << (unsigned int)dims[i] << "]";
+           }
+             
+           os << H5Type(*const_cast<H5Type *>(this), super).dump(0) << " }";
+           delete[] dims;
+            break;
+        default:
+           os << _("Unknown datatype");
+            break;
+        }
+
+       os << std::endl;
+    
+       return os.str();
+    }
+
+    std::string H5Type::toString(const unsigned int indentLevel) const
+    {
+       std::ostringstream os;
+       std::string indentString = H5Object::getIndentString(indentLevel);
+       
+       os << indentString << _("Filename") << ": " << getFile().getFileName() << std::endl
+          << indentString << _("Name") << ": " << name << std::endl
+          << indentString << _("Class name") << ": " << getClassName() << std::endl
+          << indentString << _("Type name") << ": " << getTypeName();
+
+       return os.str();
+    }
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5Type.hxx b/scilab/modules/hdf5/src/cpp/H5Type.hxx
new file mode 100644 (file)
index 0000000..dc0c61a
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5TYPE_HXX__
+#define __H5TYPE_HXX__
+
+#include "H5Object.hxx"
+#include "H5File.hxx"
+
+namespace org_modules_hdf5
+{
+    
+    class H5Type : public H5Object
+    {
+       hid_t type;
+       const char * name;
+
+    public:
+
+       H5Type(H5Object & _parent, hid_t type);
+       H5Type(H5Object & _parent, const char * name);
+       H5Type(H5Object & _parent, hid_t type, const char * name);
+       virtual ~H5Type();
+
+       virtual hid_t getH5Id() const { return type; }
+       virtual std::string getName() const { return std::string(name); }
+       std::string getClassName() const;
+       std::string getTypeName() const;
+
+       virtual std::string dump(const unsigned int indentLevel) const;
+       virtual std::string toString(const unsigned int indentLevel) const;
+    };
+}
+
+#endif // __H5TYPE_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5TypesList.hxx b/scilab/modules/hdf5/src/cpp/H5TypesList.hxx
new file mode 100644 (file)
index 0000000..5cc17e1
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5TYPESLIST_HXX__
+#define __H5TYPESLIST_HXX__
+
+#include "H5NamedObjectsList.hxx"
+#include "H5Type.hxx"
+
+namespace org_modules_hdf5
+{
+
+    class H5Group;
+
+    class H5TypesList : public H5NamedObjectsList<H5Type>
+    {
+
+    public :
+       
+       H5TypesList(H5Group & _parent) : H5NamedObjectsList(_parent, H5G_TYPE, "H5 Type") { }
+       
+       ~H5TypesList()
+           {
+               
+           }
+    };
+}
+
+#endif // __H5TYPESLIST_HXX__