Fix bugs with datatype representation 24/9424/10
Calixte DENIZET [Sun, 14 Oct 2012 20:54:08 +0000 (22:54 +0200)]
Change-Id: Ica3e4adadb5391b28f4d48943c6d38a88b549d29

55 files changed:
scilab/modules/data_structures/macros/fieldnames.sci
scilab/modules/hdf5/Makefile.am
scilab/modules/hdf5/Makefile.in
scilab/modules/hdf5/help/en_US/h5isArray.xml [new file with mode: 0644]
scilab/modules/hdf5/help/en_US/h5isAttr.xml
scilab/modules/hdf5/help/en_US/h5isCompound.xml [new file with mode: 0644]
scilab/modules/hdf5/help/en_US/h5isFile.xml
scilab/modules/hdf5/help/en_US/h5isGroup.xml
scilab/modules/hdf5/help/en_US/h5isRef.xml
scilab/modules/hdf5/help/en_US/h5isSet.xml
scilab/modules/hdf5/help/en_US/h5isSpace.xml
scilab/modules/hdf5/help/en_US/h5isType.xml
scilab/modules/hdf5/help/en_US/h5isVlen.xml [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_h5isfoo.cpp
scilab/modules/hdf5/sci_gateway/cpp/sci_percent_H5Object_e.cpp
scilab/modules/hdf5/sci_gateway/cpp/sci_percent_H5Object_fieldnames.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/hdf5_gateway.xml
scilab/modules/hdf5/src/cpp/H5ArrayData.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5ArrayData.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Attribute.cpp
scilab/modules/hdf5/src/cpp/H5AttributesList.cpp
scilab/modules/hdf5/src/cpp/H5BasicData.hxx
scilab/modules/hdf5/src/cpp/H5BitfieldData.hxx
scilab/modules/hdf5/src/cpp/H5CharData.hxx
scilab/modules/hdf5/src/cpp/H5CompoundData.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5CompoundData.hxx
scilab/modules/hdf5/src/cpp/H5Data.hxx
scilab/modules/hdf5/src/cpp/H5DataConverter.hxx
scilab/modules/hdf5/src/cpp/H5DataFactory.cpp
scilab/modules/hdf5/src/cpp/H5DataFactory.hxx
scilab/modules/hdf5/src/cpp/H5Dataset.cpp
scilab/modules/hdf5/src/cpp/H5DatasetsList.cpp
scilab/modules/hdf5/src/cpp/H5EnumData.hxx
scilab/modules/hdf5/src/cpp/H5GroupsList.cpp
scilab/modules/hdf5/src/cpp/H5GroupsList.hxx
scilab/modules/hdf5/src/cpp/H5LinksList.cpp
scilab/modules/hdf5/src/cpp/H5Object.hxx
scilab/modules/hdf5/src/cpp/H5OpaqueData.hxx
scilab/modules/hdf5/src/cpp/H5ReferenceData.cpp
scilab/modules/hdf5/src/cpp/H5ReferenceData.hxx
scilab/modules/hdf5/src/cpp/H5SoftLinksList.hxx
scilab/modules/hdf5/src/cpp/H5StringData.cpp
scilab/modules/hdf5/src/cpp/H5StringData.hxx
scilab/modules/hdf5/src/cpp/H5TimeData.hxx
scilab/modules/hdf5/src/cpp/H5TransformedData.hxx
scilab/modules/hdf5/src/cpp/H5Type.cpp
scilab/modules/hdf5/src/cpp/H5Type.hxx
scilab/modules/hdf5/src/cpp/H5TypesList.hxx
scilab/modules/hdf5/src/cpp/H5UnsignedCharData.hxx
scilab/modules/hdf5/src/cpp/H5VlenData.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5VlenData.hxx
scilab/modules/hdf5/src/cpp/HDF5Scilab.cpp
scilab/modules/hdf5/src/cpp/HDF5Scilab.hxx

index f699783..539c1d4 100644 (file)
@@ -9,11 +9,15 @@
 
 function f=fieldnames(t)
   if or(type(t)==[16,17]) then
-    f=matrix(getfield(1,t),-1,1)
-    if f(1)<>'st' then //ignore type
-      f=f(2:$)
-    else //ignore type and dims
-      f=f(3:$)
+    if h5isCompound(t) then
+      f=%H5Object_fieldnames(t);
+    else
+      f=matrix(getfield(1,t),-1,1)
+      if f(1)<>'st' then //ignore type
+        f=f(2:$)
+      else //ignore type and dims
+        f=f(3:$)
+      end
     end
   else
     f=[]
index a7fd574..c67e024 100644 (file)
@@ -39,7 +39,10 @@ HDF5_CXX_SOURCES = src/cpp/H5Attribute.cpp \
                   src/cpp/H5Link.cpp \
                   src/cpp/HDF5Scilab.cpp \
                   src/cpp/H5StringData.cpp \
-                  src/cpp/H5ReferenceData.cpp
+                  src/cpp/H5ReferenceData.cpp \
+                  src/cpp/H5CompoundData.cpp \
+                  src/cpp/H5ArrayData.cpp \
+                  src/cpp/H5VlenData.cpp
 
 GATEWAY_C_SOURCES = sci_gateway/c/gw_hdf5.c
 
@@ -69,7 +72,8 @@ sci_gateway/cpp/sci_h5umount.cpp \
 sci_gateway/cpp/sci_h5mv.cpp \
 sci_gateway/cpp/sci_h5get.cpp \
 sci_gateway/cpp/sci_h5label.cpp \
-sci_gateway/cpp/sci_h5exists.cpp
+sci_gateway/cpp/sci_h5exists.cpp \
+sci_gateway/cpp/sci_percent_H5Object_fieldnames.cpp
 
 if GIWS
 BUILT_SOURCES=giws
index 1da2aa5..1f8a005 100644 (file)
@@ -158,7 +158,10 @@ am__objects_2 = libscihdf5_algo_la-H5Attribute.lo \
        libscihdf5_algo_la-H5HardLink.lo libscihdf5_algo_la-H5Link.lo \
        libscihdf5_algo_la-HDF5Scilab.lo \
        libscihdf5_algo_la-H5StringData.lo \
-       libscihdf5_algo_la-H5ReferenceData.lo
+       libscihdf5_algo_la-H5ReferenceData.lo \
+       libscihdf5_algo_la-H5CompoundData.lo \
+       libscihdf5_algo_la-H5ArrayData.lo \
+       libscihdf5_algo_la-H5VlenData.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
@@ -178,7 +181,8 @@ am__objects_3 = libscihdf5_la-sci_export_to_hdf5.lo \
        libscihdf5_la-sci_h5cp.lo libscihdf5_la-sci_h5isfoo.lo \
        libscihdf5_la-sci_h5mount.lo libscihdf5_la-sci_h5umount.lo \
        libscihdf5_la-sci_h5mv.lo libscihdf5_la-sci_h5get.lo \
-       libscihdf5_la-sci_h5label.lo libscihdf5_la-sci_h5exists.lo
+       libscihdf5_la-sci_h5label.lo libscihdf5_la-sci_h5exists.lo \
+       libscihdf5_la-sci_percent_H5Object_fieldnames.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)
@@ -499,7 +503,10 @@ HDF5_CXX_SOURCES = src/cpp/H5Attribute.cpp \
                   src/cpp/H5Link.cpp \
                   src/cpp/HDF5Scilab.cpp \
                   src/cpp/H5StringData.cpp \
-                  src/cpp/H5ReferenceData.cpp
+                  src/cpp/H5ReferenceData.cpp \
+                  src/cpp/H5CompoundData.cpp \
+                  src/cpp/H5ArrayData.cpp \
+                  src/cpp/H5VlenData.cpp
 
 GATEWAY_C_SOURCES = sci_gateway/c/gw_hdf5.c
 GATEWAY_CXX_SOURCES = sci_gateway/cpp/sci_export_to_hdf5.cpp \
@@ -528,7 +535,8 @@ sci_gateway/cpp/sci_h5umount.cpp \
 sci_gateway/cpp/sci_h5mv.cpp \
 sci_gateway/cpp/sci_h5get.cpp \
 sci_gateway/cpp/sci_h5label.cpp \
-sci_gateway/cpp/sci_h5exists.cpp
+sci_gateway/cpp/sci_h5exists.cpp \
+sci_gateway/cpp/sci_percent_H5Object_fieldnames.cpp
 
 @GIWS_TRUE@BUILT_SOURCES = giws
 
@@ -802,8 +810,10 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5ArrayData.Plo@am__quote@
 @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-H5CompoundData.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@
@@ -819,6 +829,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5StringData.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-H5VariableScope.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5VlenData.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-HDF5Scilab.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@
@@ -853,6 +864,7 @@ distclean-compile:
 @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@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_percent_H5Object_e.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_percent_H5Object_fieldnames.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_percent_H5Object_p.Plo@am__quote@
 
 .c.o:
@@ -1072,6 +1084,27 @@ libscihdf5_algo_la-H5ReferenceData.lo: src/cpp/H5ReferenceData.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-H5ReferenceData.lo `test -f 'src/cpp/H5ReferenceData.cpp' || echo '$(srcdir)/'`src/cpp/H5ReferenceData.cpp
 
+libscihdf5_algo_la-H5CompoundData.lo: src/cpp/H5CompoundData.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-H5CompoundData.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5CompoundData.Tpo -c -o libscihdf5_algo_la-H5CompoundData.lo `test -f 'src/cpp/H5CompoundData.cpp' || echo '$(srcdir)/'`src/cpp/H5CompoundData.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5CompoundData.Tpo $(DEPDIR)/libscihdf5_algo_la-H5CompoundData.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5CompoundData.cpp' object='libscihdf5_algo_la-H5CompoundData.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-H5CompoundData.lo `test -f 'src/cpp/H5CompoundData.cpp' || echo '$(srcdir)/'`src/cpp/H5CompoundData.cpp
+
+libscihdf5_algo_la-H5ArrayData.lo: src/cpp/H5ArrayData.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-H5ArrayData.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5ArrayData.Tpo -c -o libscihdf5_algo_la-H5ArrayData.lo `test -f 'src/cpp/H5ArrayData.cpp' || echo '$(srcdir)/'`src/cpp/H5ArrayData.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5ArrayData.Tpo $(DEPDIR)/libscihdf5_algo_la-H5ArrayData.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5ArrayData.cpp' object='libscihdf5_algo_la-H5ArrayData.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-H5ArrayData.lo `test -f 'src/cpp/H5ArrayData.cpp' || echo '$(srcdir)/'`src/cpp/H5ArrayData.cpp
+
+libscihdf5_algo_la-H5VlenData.lo: src/cpp/H5VlenData.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-H5VlenData.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5VlenData.Tpo -c -o libscihdf5_algo_la-H5VlenData.lo `test -f 'src/cpp/H5VlenData.cpp' || echo '$(srcdir)/'`src/cpp/H5VlenData.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5VlenData.Tpo $(DEPDIR)/libscihdf5_algo_la-H5VlenData.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5VlenData.cpp' object='libscihdf5_algo_la-H5VlenData.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-H5VlenData.lo `test -f 'src/cpp/H5VlenData.cpp' || echo '$(srcdir)/'`src/cpp/H5VlenData.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
@@ -1261,6 +1294,13 @@ libscihdf5_la-sci_h5exists.lo: sci_gateway/cpp/sci_h5exists.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_h5exists.lo `test -f 'sci_gateway/cpp/sci_h5exists.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5exists.cpp
 
+libscihdf5_la-sci_percent_H5Object_fieldnames.lo: sci_gateway/cpp/sci_percent_H5Object_fieldnames.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_percent_H5Object_fieldnames.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_percent_H5Object_fieldnames.Tpo -c -o libscihdf5_la-sci_percent_H5Object_fieldnames.lo `test -f 'sci_gateway/cpp/sci_percent_H5Object_fieldnames.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_percent_H5Object_fieldnames.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_percent_H5Object_fieldnames.Tpo $(DEPDIR)/libscihdf5_la-sci_percent_H5Object_fieldnames.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_percent_H5Object_fieldnames.cpp' object='libscihdf5_la-sci_percent_H5Object_fieldnames.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_percent_H5Object_fieldnames.lo `test -f 'sci_gateway/cpp/sci_percent_H5Object_fieldnames.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_percent_H5Object_fieldnames.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
diff --git a/scilab/modules/hdf5/help/en_US/h5isArray.xml b/scilab/modules/hdf5/help/en_US/h5isArray.xml
new file mode 100644 (file)
index 0000000..ce6d3f6
--- /dev/null
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+* 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
+*
+-->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="h5isArray" xml:lang="en">
+    <refnamediv>
+        <refname>h5isArray</refname>
+        <refpurpose>Check if the HDF5 object is an array</refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>Calling Sequence</title>
+        <synopsis>
+            b = h5isArray(obj)
+        </synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>obj</term>
+                <listitem>
+                    <para>a H5Object</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>b</term>
+                <listitem>
+                    <para>a boolean</para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>Description</title>
+        <para>Check if an HDF5 object is an array object.</para>
+    </refsection>
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[
+// Create a SOD file which an HDF5 one
+x = (1:10) + %i*(20:29);
+save(TMPDIR + "/x.sod", "x");
+
+// Open the file
+a = h5open(TMPDIR + "/x.sod", "r");
+
+// Test
+h5isArray(a)
+
+// We close all
+h5close(a)
+    ]]></programlisting>
+    </refsection>
+    <refsection role="see also">
+        <title>See Also</title>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isFile">h5isFile</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isSet">h5isSet</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isAttr">h5isAttr</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isSpace">h5isSpace</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isType">h5isType</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isRef">h5isRef</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isCompound">h5isCompound</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isVlen">h5isVlen</link>
+            </member>
+        </simplelist>
+    </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.0</revnumber>
+                <revremark>HDF5 module introduced.</revremark>
+            </revision>
+        </revhistory>
+    </refsection>
+</refentry>
index fb6f8e1..4d15b2b 100644 (file)
@@ -94,6 +94,21 @@ h5close(a)
                 <link linkend="h5isRef">h5isRef</link>
             </member>
         </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isCompound</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isArray</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isVlen">h5isVlen</link>
+            </member>
+        </simplelist>
     </refsection>
     <refsection>
         <title>History</title>
diff --git a/scilab/modules/hdf5/help/en_US/h5isCompound.xml b/scilab/modules/hdf5/help/en_US/h5isCompound.xml
new file mode 100644 (file)
index 0000000..d7ff672
--- /dev/null
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+* 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
+*
+-->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="h5isCompound" xml:lang="en">
+    <refnamediv>
+        <refname>h5isCompound</refname>
+        <refpurpose>Check if the HDF5 object is a compound object</refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>Calling Sequence</title>
+        <synopsis>
+            b = h5isCompound(obj)
+        </synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>obj</term>
+                <listitem>
+                    <para>a H5Object</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>b</term>
+                <listitem>
+                    <para>a boolean</para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>Description</title>
+        <para>Check if an HDF5 object is a compound object.</para>
+    </refsection>
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[
+// Create a SOD file which an HDF5 one
+x = (1:10) + %i*(20:29);
+save(TMPDIR + "/x.sod", "x");
+
+// Open the file
+a = h5open(TMPDIR + "/x.sod", "r");
+
+// Test
+h5isCompound(a)
+
+// Test against root.x.data
+h5isCompound(a.root.x.data)
+
+// We close all
+h5close(a)
+    ]]></programlisting>
+    </refsection>
+    <refsection role="see also">
+        <title>See Also</title>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isFile">h5isFile</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isSet">h5isSet</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isAttr">h5isAttr</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isSpace">h5isSpace</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isType">h5isType</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isRef">h5isRef</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isArray</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isVlen">h5isVlen</link>
+            </member>
+        </simplelist>
+    </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.0</revnumber>
+                <revremark>HDF5 module introduced.</revremark>
+            </revision>
+        </revhistory>
+    </refsection>
+</refentry>
index 25d5f3f..d27c80e 100644 (file)
@@ -94,6 +94,21 @@ h5close(a)
                 <link linkend="h5isRef">h5isRef</link>
             </member>
         </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isCompound</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isArray</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isVlen">h5isVlen</link>
+            </member>
+        </simplelist>
     </refsection>
     <refsection>
         <title>History</title>
index edfbe97..1e165c4 100644 (file)
@@ -94,6 +94,21 @@ h5close(a)
                 <link linkend="h5isRef">h5isRef</link>
             </member>
         </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isCompound</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isArray</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isVlen">h5isVlen</link>
+            </member>
+        </simplelist>
     </refsection>
     <refsection>
         <title>History</title>
index 0e475a7..60b47b9 100644 (file)
@@ -98,6 +98,21 @@ h5close(a)
                 <link linkend="h5isType">h5isType</link>
             </member>
         </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isCompound</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isArray</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isVlen">h5isVlen</link>
+            </member>
+        </simplelist>
     </refsection>
     <refsection>
         <title>History</title>
index cf77731..945c388 100644 (file)
@@ -94,6 +94,21 @@ h5close(a)
                 <link linkend="h5isRef">h5isRef</link>
             </member>
         </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isCompound</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isArray</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isVlen">h5isVlen</link>
+            </member>
+        </simplelist>
     </refsection>
     <refsection>
         <title>History</title>
index 496af01..f466af4 100644 (file)
@@ -94,6 +94,21 @@ h5close(a)
                 <link linkend="h5isRef">h5isRef</link>
             </member>
         </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isCompound</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isArray</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isVlen">h5isVlen</link>
+            </member>
+        </simplelist>
     </refsection>
     <refsection>
         <title>History</title>
index 0d40795..dc17210 100644 (file)
@@ -94,6 +94,21 @@ h5close(a)
                 <link linkend="h5isRef">h5isRef</link>
             </member>
         </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isCompound</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isArray">h5isArray</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isVlen">h5isVlen</link>
+            </member>
+        </simplelist>
     </refsection>
     <refsection>
         <title>History</title>
diff --git a/scilab/modules/hdf5/help/en_US/h5isVlen.xml b/scilab/modules/hdf5/help/en_US/h5isVlen.xml
new file mode 100644 (file)
index 0000000..219e192
--- /dev/null
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+* 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
+*
+-->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="h5isVlen" xml:lang="en">
+    <refnamediv>
+        <refname>h5isVlen</refname>
+        <refpurpose>Check if the HDF5 object is a variable length array</refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>Calling Sequence</title>
+        <synopsis>
+            b = h5isVlen(obj)
+        </synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>obj</term>
+                <listitem>
+                    <para>a H5Object</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>b</term>
+                <listitem>
+                    <para>a boolean</para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>Description</title>
+        <para>Check if an HDF5 object is a variable length array.</para>
+    </refsection>
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[
+// Create a SOD file which an HDF5 one
+x = (1:10) + %i*(20:29);
+save(TMPDIR + "/x.sod", "x");
+
+// Open the file
+a = h5open(TMPDIR + "/x.sod", "r");
+
+// Test
+h5isVlen(a)
+
+// We close all
+h5close(a)
+    ]]></programlisting>
+    </refsection>
+    <refsection role="see also">
+        <title>See Also</title>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isFile">h5isFile</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isSet">h5isSet</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isAttr">h5isAttr</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isSpace">h5isSpace</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isType">h5isType</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isRef">h5isRef</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isCompound">h5isCompound</link>
+            </member>
+        </simplelist>
+        <simplelist type="inline">
+            <member>
+                <link linkend="h5isVlen">h5isArray</link>
+            </member>
+        </simplelist>
+    </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.0</revnumber>
+                <revremark>HDF5 module introduced.</revremark>
+            </revision>
+        </revhistory>
+    </refsection>
+</refentry>
index 367bc9b..280595d 100644 (file)
@@ -51,6 +51,10 @@ HDF5_SCILAB_IMPEXP int sci_h5mv(char *fname, unsigned long fname_len);
 HDF5_SCILAB_IMPEXP int sci_h5get(char *fname, unsigned long fname_len);
 HDF5_SCILAB_IMPEXP int sci_h5label(char *fname, unsigned long fname_len);
 HDF5_SCILAB_IMPEXP int sci_h5exists(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5isCompound(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_percent_H5Object_fieldnames(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5isArray(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5isVlen(char *fname, unsigned long fname_len);
 /*--------------------------------------------------------------------------*/
 #endif /* __GW_HDF5_H__ */
 /*--------------------------------------------------------------------------*/
index 4cd4b59..cc2b625 100644 (file)
@@ -55,7 +55,12 @@ static gw_generic_table Tab[] =
     {sci_h5mv, "h5mv"},
     {sci_h5get, "h5get"},
     {sci_h5label, "h5label"},
-    {sci_h5exists, "h5exists"}
+    {sci_h5exists, "h5exists"},
+    {sci_h5isCompound, "h5isCompound"},
+    {sci_percent_H5Object_fieldnames, "%H5Object_fieldnames"},
+    {sci_percent_H5Object_fieldnames, "%H5Object_fieldnames"},
+    {sci_h5isArray, "h5isArray"},
+    {sci_h5isVlen, "h5isVlen"},
 };
 /*--------------------------------------------------------------------------*/
 int gw_hdf5(void)
index b22c030..8db3310 100644 (file)
@@ -50,14 +50,12 @@ inline static int sci_h5isfoo(const HDF5Scilab::H5ObjectType type, char * fname,
         hobj = HDF5Scilab::getH5Object(addr, pvApiCtx);
         if (!hobj)
         {
-            Scierror(999, _("%s: Invalid H5Object.\n"), fname);
-            return 0;
+            goto finish;
         }
     }
     else
     {
-        Scierror(999, _("%s: Wrong type for input argument #%d: A H5Object expected.\n"), fname, 1);
-        return 0;
+        goto finish;
     }
 
     try
@@ -66,10 +64,11 @@ inline static int sci_h5isfoo(const HDF5Scilab::H5ObjectType type, char * fname,
     }
     catch (const std::exception & e)
     {
-        Scierror(999, _("%s: %s\n"), fname, e.what());
-        return 0;
+
     }
 
+finish:
+
     if (createScalarBoolean(pvApiCtx, nbIn + 1, ok ? 1 : 0))
     {
         Scierror(999, _("%s: Can not create output argument.\n"), fname);
@@ -129,3 +128,18 @@ int sci_h5isList(char * fname, unsigned long fname_len)
     return sci_h5isfoo(HDF5Scilab::H5LIST, fname, fname_len);
 }
 /*--------------------------------------------------------------------------*/
+int sci_h5isCompound(char * fname, unsigned long fname_len)
+{
+    return sci_h5isfoo(HDF5Scilab::H5COMPOUND, fname, fname_len);
+}
+/*--------------------------------------------------------------------------*/
+int sci_h5isArray(char * fname, unsigned long fname_len)
+{
+    return sci_h5isfoo(HDF5Scilab::H5ARRAY, fname, fname_len);
+}
+/*--------------------------------------------------------------------------*/
+int sci_h5isVlen(char * fname, unsigned long fname_len)
+{
+    return sci_h5isfoo(HDF5Scilab::H5VLEN, fname, fname_len);
+}
+/*--------------------------------------------------------------------------*/
index 1ef811c..b34c51a 100644 (file)
@@ -35,7 +35,7 @@ int sci_percent_H5Object_e(char * fname, unsigned long fname_len)
     char * field = 0;
     std::string _field;
     int fieldtype;
-    double  * index = 0;
+    unsigned int * index = 0;
     const int nbIn = nbInputArgument(pvApiCtx);
 
     CheckOutputArgument(pvApiCtx, 1, 1);
@@ -83,7 +83,8 @@ int sci_percent_H5Object_e(char * fname, unsigned long fname_len)
     }
     else
     {
-        index = new double[nbIn - 1];
+        double d;
+        index = new unsigned int[nbIn - 1];
 
         for (unsigned int i = 1; i <= nbIn - 1; i++)
         {
@@ -95,13 +96,13 @@ int sci_percent_H5Object_e(char * fname, unsigned long fname_len)
                 return 0;
             }
 
-            if (getScalarDouble(pvApiCtx, addr, index + i - 1) != 0)
+            if (getScalarDouble(pvApiCtx, addr, &d) != 0)
             {
                 delete[] index;
                 Scierror(999, _("%s: No more memory.\n"), fname);
                 return 0;
             }
-            index[i - 1]--;
+            index[i - 1] = (unsigned int)(d - 1);
         }
     }
 
@@ -146,21 +147,27 @@ int sci_percent_H5Object_e(char * fname, unsigned long fname_len)
         {
             obj->getAccessibleAttribute(_field, nbIn + 1, pvApiCtx);
         }
-        else if (obj->isReference())
-        {
-            H5ReferenceData * ref = reinterpret_cast<H5ReferenceData *>(obj);
-            H5Object & robj = ref->getReferencesObject(nbIn - 1, index);
-            robj.createOnScilabStack(nbIn + 1, pvApiCtx);
-        }
         else
         {
-            if (index)
-            {
-                delete[] index;
-            }
-            Scierror(999, gettext("%s: Invalid field.\n"), fname);
-            return 0;
+            H5Object & robj = obj->getData(nbIn - 1, index);
+            //robj.createOnScilabStack(nbIn + 1, pvApiCtx);
+            robj.toScilab(pvApiCtx, nbIn + 1);
         }
+        /*        else if (obj->isReference())
+                {
+                    H5ReferenceData * ref = reinterpret_cast<H5ReferenceData *>(obj);
+                    H5Object & robj = ref->getReferencesObject(nbIn - 1, index);
+                    robj.createOnScilabStack(nbIn + 1, pvApiCtx);
+                   }
+                else
+                {
+                    if (index)
+                    {
+                        delete[] index;
+                    }
+                    Scierror(999, gettext("%s: Invalid field.\n"), fname);
+                    return 0;
+                   }*/
     }
     catch (std::exception & e)
     {
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_percent_H5Object_fieldnames.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_percent_H5Object_fieldnames.cpp
new file mode 100644 (file)
index 0000000..08eef62
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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 "H5Exception.hxx"
+#include "HDF5Scilab.hxx"
+#include "H5CompoundData.hxx"
+
+extern "C"
+{
+#include "gw_hdf5.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "sciprint.h"
+#include "localization.h"
+}
+
+using namespace org_modules_hdf5;
+
+/*--------------------------------------------------------------------------*/
+int sci_percent_H5Object_fieldnames(char * fname, unsigned long fname_len)
+{
+    H5Object * hobj = 0;
+    int id;
+    SciErr err;
+    int * addr = 0;
+    const int nbIn = nbInputArgument(pvApiCtx);
+
+    CheckInputArgument(pvApiCtx, 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;
+    }
+
+    hobj = HDF5Scilab::getH5Object(addr, pvApiCtx);
+    if (!hobj)
+    {
+        Scierror(999, _("%s: Invalid H5Object.\n"), fname);
+        return 0;
+    }
+
+    if (!hobj->isCompound())
+    {
+        Scierror(999, _("%s: Not an H5 Compound object.\n"), fname);
+        return 0;
+    }
+
+    try
+    {
+        reinterpret_cast<H5CompoundData *>(hobj)->getFieldNames(nbIn + 1, pvApiCtx);
+    }
+    catch (const H5Exception & e)
+    {
+        Scierror(999, _("%s: %s\n"), fname, e.what());
+        return 0;
+    }
+
+    AssignOutputVariable(pvApiCtx, 1) = nbIn + 1;
+    ReturnArguments(pvApiCtx);
+
+    return 0;
+}
index d671cf5..403e22d 100644 (file)
@@ -64,4 +64,8 @@
     <PRIMITIVE gatewayId="62" primitiveId="33" primitiveName="h5get" />
     <PRIMITIVE gatewayId="62" primitiveId="34" primitiveName="h5label" />
     <PRIMITIVE gatewayId="62" primitiveId="35" primitiveName="h5exists" />
+    <PRIMITIVE gatewayId="62" primitiveId="36" primitiveName="h5isCompound" />
+    <PRIMITIVE gatewayId="62" primitiveId="37" primitiveName="%H5Object_fieldnames" />
+    <PRIMITIVE gatewayId="62" primitiveId="38" primitiveName="h5isArray" />
+    <PRIMITIVE gatewayId="62" primitiveId="39" primitiveName="h5isVlen" />
 </GATEWAY>
diff --git a/scilab/modules/hdf5/src/cpp/H5ArrayData.cpp b/scilab/modules/hdf5/src/cpp/H5ArrayData.cpp
new file mode 100644 (file)
index 0000000..67d7562
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * 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 "H5ArrayData.hxx"
+#include "H5DataFactory.hxx"
+
+namespace org_modules_hdf5
+{
+
+H5ArrayData::H5ArrayData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, hid_t arrayType, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData<char>(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner), cumprod(H5Object::getCumProd(_ndims, dims))
+{
+    type = H5Tget_super(arrayType);
+    baseSize = H5Tget_size(type);
+    andims = H5Tget_array_ndims(arrayType);
+    adims = new hsize_t[andims];
+    H5Tget_array_dims(arrayType, adims);
+    atotalSize = 1;
+
+    if (H5Tget_class(type) == H5T_STRING && !H5Tis_variable_str(type))
+    {
+        // We have a C-string so it is null terminated
+        baseSize++;
+    }
+
+    for (unsigned int i = 0; i < andims; i++)
+    {
+        atotalSize *= adims[i];
+    }
+
+}
+
+H5ArrayData::~H5ArrayData()
+{
+    delete[] cumprod;
+    delete[] adims;
+    H5Tclose(type);
+}
+
+bool H5ArrayData::isArray() const
+{
+    return true;
+}
+
+H5Object & H5ArrayData::getData(const unsigned int size, const unsigned int * index) const
+{
+    unsigned int pos = 0;
+    hsize_t * _dims = 0;
+
+    for (unsigned int i = 0; i < size; i++)
+    {
+        pos += cumprod[i] * index[i];
+    }
+
+    if (pos >= totalSize)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Invalid index."));
+    }
+
+    return H5DataFactory::getObjectData(*const_cast<H5ArrayData *>(this), atotalSize, baseSize, type, andims, adims, static_cast<char *>(data) + offset + pos * (stride ? stride : dataSize), 0, 0, false);
+}
+
+std::string H5ArrayData::toString(const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    std::string indentString = H5Object::getIndentString(indentLevel + 1);
+
+    os << H5Object::getIndentString(indentLevel) << "HDF5 Array data" << std::endl
+       << indentString << _("Dimensions") << ": [";
+
+    if (ndims == 0)
+    {
+        os << "1 x 1]";
+    }
+    else if (ndims == 1)
+    {
+        os << "1 x " << dims[0] << "]";
+    }
+    else
+    {
+        for (unsigned int i = 0; i < ndims - 1; i++)
+        {
+            os << dims[i] << " x ";
+        }
+        os << dims[ndims - 1] << "]" << std::endl;
+    }
+
+    return os.str();
+}
+
+std::string H5ArrayData::dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+{
+    return H5DataConverter::dump(alreadyVisited, indentLevel, ndims, dims, *this, false);
+}
+
+void H5ArrayData::printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const
+{
+    os << "[ ";
+    H5Data & hdata = H5DataFactory::getObjectData(*const_cast<H5ArrayData *>(this), atotalSize, baseSize, type, andims, adims, static_cast<char *>(data) + offset + pos * (stride ? stride : dataSize), 0, 0, false);
+
+    for (unsigned int i = 0; i < atotalSize - 1; i++)
+    {
+        hdata.printData(os, i, indentLevel + 1);
+        os << ", ";
+    }
+    hdata.printData(os, atotalSize - 1, indentLevel + 1);
+    os << " ]";
+
+    delete &hdata;
+}
+
+void H5ArrayData::toScilab(void * pvApiCtx, const int lhsPosition, int * parentList, const int listPosition) const
+{
+    H5Object::toScilab(pvApiCtx, lhsPosition, parentList, listPosition);
+}
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5ArrayData.hxx b/scilab/modules/hdf5/src/cpp/H5ArrayData.hxx
new file mode 100644 (file)
index 0000000..c15ba1e
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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 __H5ARRAYDATA_HXX__
+#define __H5ARRAYDATA_HXX__
+
+#include "H5BasicData.hxx"
+
+namespace org_modules_hdf5
+{
+
+class H5ArrayData : public H5BasicData<char>
+{
+
+    const hsize_t * cumprod;
+    hid_t type;
+    hsize_t atotalSize;
+    hsize_t andims;
+    hsize_t baseSize;
+    hsize_t * adims;
+
+public:
+
+    H5ArrayData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, hid_t arrayType, const hsize_t stride, const size_t offset, const bool _dataOwner);
+
+    virtual ~H5ArrayData();
+
+    virtual H5Object & getData(const unsigned int size, const unsigned int * index) const;
+
+    virtual bool isArray() const;
+
+    virtual std::string toString(const unsigned int indentLevel) const;
+
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const;
+
+    virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const;
+
+    virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const;
+
+    virtual bool mustDelete() const
+    {
+        return false;
+    }
+};
+}
+
+#endif // __H5ARRAYDATA_HXX__
index fef0e88..d0c3659 100644 (file)
@@ -108,17 +108,38 @@ std::string H5Attribute::dump(std::map<haddr_t, std::string> & alreadyVisited, c
     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();
+    H5Data * data = 0;
+
+    try
+    {
+       data = &const_cast<H5Attribute *>(this)->getData();
+    }
+    catch (const H5Exception & e)
+    {
+
+    }
 
     os << H5Object::getIndentString(indentLevel) << "ATTRIBUTE \"" << getName() << "\" {" << std::endl
        << type.dump(alreadyVisited, indentLevel + 1)
-       << space.dump(alreadyVisited, indentLevel + 1)
-       << data.dump(alreadyVisited, indentLevel + 1)
-       << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+       << space.dump(alreadyVisited, indentLevel + 1);
+    
+    if (data)
+    {
+       os << data->dump(alreadyVisited, indentLevel + 1);
+    }
+    else
+    {
+       os << H5Object::getIndentString(indentLevel + 1) << _("Error in retrieving data.") << std::endl;
+    }
+
+    os << H5Object::getIndentString(indentLevel) << "}" << std::endl;
 
     delete &type;
     delete &space;
-    delete &data;
+    if (data)
+    {
+       delete data;
+    }
 
     return os.str();
 }
index 32b43f0..b11bf3f 100644 (file)
 namespace org_modules_hdf5
 {
 
-H5AttributesList::H5AttributesList(H5Object & _parent) : H5ListObject(_parent) { }
+H5AttributesList::H5AttributesList(H5Object & _parent) : H5ListObject<H5Attribute>(_parent) { }
 
-H5AttributesList::H5AttributesList(H5Object & _parent, const unsigned int _size, const unsigned int * _index) : H5ListObject(_parent, _size, _index) { }
+H5AttributesList::H5AttributesList(H5Object & _parent, const unsigned int _size, const unsigned int * _index) : H5ListObject<H5Attribute>(_parent, _size, _index) { }
 
 H5AttributesList::~H5AttributesList() { }
 
 const unsigned int H5AttributesList::getSize() const
 {
-    if (H5ListObject::indexList)
+    if (H5ListObject<H5Attribute>::indexList)
     {
-        return H5ListObject::indexSize;
+        return H5ListObject<H5Attribute>::indexSize;
     }
     else
     {
@@ -73,9 +73,9 @@ H5Attribute & H5AttributesList::getObject(const int pos, const bool checkPos)
         }
     }
 
-    if (H5ListObject::indexList)
+    if (H5ListObject<H5Attribute>::indexList)
     {
-        _pos = H5ListObject::indexList[pos];
+        _pos = H5ListObject<H5Attribute>::indexList[pos];
     }
 
     attr = H5Aopen_by_idx(parent.getH5Id(), ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)_pos, H5P_DEFAULT, H5P_DEFAULT);
index 048e52c..7860cb4 100644 (file)
@@ -77,9 +77,9 @@ protected:
 
 public:
 
-    H5BasicData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, T * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5Data(_parent, _totalSize, _dataSize, _ndims, _dims, _arank, _adims, static_cast<void *>(_data), _stride, _offset, _dataOwner), transformedData(0)
+    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, const size_t _offset, const bool _dataOwner) : H5Data(_parent, _totalSize, _dataSize, _ndims, _dims, static_cast<void *>(_data), _stride, _offset, _dataOwner), transformedData(0)
     {
-
+        //std::cout << totalSize << ", " << stride << ", " << offset << std::endl;
     }
 
     virtual ~H5BasicData()
@@ -92,27 +92,14 @@ public:
 
     virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const
     {
-        if (adims)
-        {
-            os << "[ ";
-            const hsize_t _pos = pos * dataSize;
-            for (unsigned int i = 0; i < atotalSize - 1; i++)
-            {
-                os << static_cast<T *>(getData())[_pos + i] << ", ";
-            }
-            os << static_cast<T *>(getData())[_pos + atotalSize - 1] << " ]";
-        }
-        else
-        {
-            os << static_cast<T *>(getData())[pos];
-        }
+        os << static_cast<T *>(getData())[pos];
     }
 
     virtual void copyData(T * dest) const
     {
         if (dest)
         {
-            if (stride == -1)
+            if (stride == 0)
             {
                 memcpy(static_cast<void *>(dest), data, totalSize * dataSize);
             }
@@ -149,9 +136,9 @@ public:
         }
     }
 
-    virtual void * getData() const
+    inline virtual void * getData() const
     {
-        if (stride == -1)
+        if (stride == 0)
         {
             return data;
         }
@@ -176,15 +163,6 @@ public:
         hsize_t _totalSize = totalSize;
         hsize_t * _dims = const_cast<hsize_t *>(dims);
 
-        if (adims)
-        {
-            _ndims += arank;
-            _totalSize *= atotalSize;
-            _dims = new hsize_t[_ndims];
-            memcpy(_dims, dims, sizeof(hsize_t) * ndims);
-            memcpy(_dims + ndims, adims, sizeof(hsize_t) * arank);
-        }
-
         if (_ndims == 0)
         {
             create(pvApiCtx, lhsPosition, 1, 1, static_cast<T *>(getData()), parentList, listPosition);
index d55162b..5f6a929 100644 (file)
@@ -23,7 +23,7 @@ class H5Bitfield1Data : public H5BasicData<unsigned char>
 
 public:
 
-    H5Bitfield1Data(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, unsigned char * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _arank, _adims, _data, _stride, _offset, _dataOwner)
+    H5Bitfield1Data(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, unsigned char * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData<unsigned char>(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner)
     {
 
     }
@@ -44,7 +44,7 @@ class H5Bitfield2Data : public H5BasicData<unsigned short>
 
 public:
 
-    H5Bitfield2Data(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, unsigned short * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _arank, _adims, _data, _stride, _offset, _dataOwner)
+    H5Bitfield2Data(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, unsigned short * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData<unsigned short>(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner)
     {
 
     }
@@ -66,7 +66,7 @@ class H5Bitfield4Data : public H5BasicData<unsigned int>
 
 public:
 
-    H5Bitfield4Data(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, unsigned int * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _arank, _adims, _data, _stride, _offset, _dataOwner)
+    H5Bitfield4Data(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, unsigned int * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData<unsigned int>(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner)
     {
 
     }
@@ -90,7 +90,7 @@ class H5Bitfield8Data : public H5BasicData<unsigned long>
 
 public:
 
-    H5Bitfield8Data(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, unsigned long * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _arank, _adims, _data, _stride, _offset, _dataOwner)
+    H5Bitfield8Data(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, unsigned long * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData<unsigned long>(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner)
     {
 
     }
index faede5b..27b1b45 100644 (file)
@@ -23,7 +23,7 @@ class H5CharData : public H5BasicData<char>
 
 public:
 
-    H5CharData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, char * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _arank, _adims, _data, _stride, _offset, _dataOwner)
+    H5CharData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData<char>(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner)
     {
 
     }
@@ -35,20 +35,7 @@ public:
 
     virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const
     {
-        if (adims)
-        {
-            os << "[ ";
-            const hsize_t _pos = pos * dataSize;
-            for (unsigned int i = 0; i < atotalSize - 1; i++)
-            {
-                os << (int)static_cast<char *>(getData())[_pos + i] << ", ";
-            }
-            os << (int)static_cast<char *>(getData())[_pos + atotalSize - 1] << " ]";
-        }
-        else
-        {
-            os << (int)static_cast<char *>(getData())[pos];
-        }
+        os << (int)static_cast<char *>(getData())[pos];
     }
 };
 }
diff --git a/scilab/modules/hdf5/src/cpp/H5CompoundData.cpp b/scilab/modules/hdf5/src/cpp/H5CompoundData.cpp
new file mode 100644 (file)
index 0000000..19b2bc4
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * 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 "H5CompoundData.hxx"
+#include "H5DataFactory.hxx"
+
+namespace org_modules_hdf5
+{
+
+H5CompoundData::H5CompoundData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, hid_t compoundType, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData<char>(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner), type(compoundType), cumprod(H5Object::getCumProd(_ndims, dims))
+{
+    nfields = (unsigned int)H5Tget_nmembers(compoundType);
+    infos = new std::map<std::string, FieldInfo *>();
+    fieldinfos = new FieldInfo *[nfields];
+    for (unsigned int i = 0; i < nfields; i++)
+    {
+        hid_t mtype = H5Tget_member_type(compoundType, i);
+        hsize_t size = H5Tget_size(mtype);
+        char * mname = H5Tget_member_name(compoundType, i);
+        size_t offs = H5Tget_member_offset(compoundType, i);
+        FieldInfo * info = 0;
+        if (H5Tget_class(type) == H5T_STRING && !H5Tis_variable_str(type))
+        {
+            // We have a C-string so it is null terminated
+            size++;
+        }
+
+        info = new FieldInfo(mtype, size, offs, std::string(mname));
+        (*infos)[std::string(mname)] = info;
+        fieldinfos[i] = info;
+        free(mname);
+    }
+}
+
+H5CompoundData::~H5CompoundData()
+{
+    infos->erase(infos->begin(), infos->end());
+    delete infos;
+    delete[] cumprod;
+    H5Tclose(type);
+}
+
+void H5CompoundData::toScilab(void * pvApiCtx, const int lhsPosition, int * parentList, const int listPosition) const
+{
+    H5Object::toScilab(pvApiCtx, lhsPosition, parentList, listPosition);
+}
+
+bool H5CompoundData::isCompound() const
+{
+    return true;
+}
+
+void H5CompoundData::getAccessibleAttribute(const std::string & _name, const int pos, void * pvApiCtx) const
+{
+    H5Data & data = getData(_name);
+    data.toScilab(pvApiCtx, pos);
+
+    if (data.mustDelete())
+    {
+        delete &data;
+    }
+}
+
+H5Data & H5CompoundData::getData(const std::string fieldname) const
+{
+    std::map<std::string, FieldInfo *>::const_iterator it = infos->find(fieldname);
+
+    if (it != infos->end())
+    {
+        return H5DataFactory::getObjectData(*const_cast<H5CompoundData *>(this), totalSize, it->second->size, it->second->type, ndims, dims, data, stride ? stride : dataSize, offset + it->second->offset, false);
+    }
+
+    throw H5Exception(__LINE__, __FILE__, _("Invalid field name: %s"), fieldname.c_str());
+}
+
+H5Object & H5CompoundData::getData(const unsigned int size, const unsigned int * index) const
+{
+    unsigned int pos = 0;
+    unsigned int cumprod = 1;
+    hsize_t * _dims = 0;
+
+    for (unsigned int i = 0; i < size; i++)
+    {
+        pos += cumprod * index[i];
+    }
+
+    if (pos >= totalSize)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Invalid index."));
+    }
+
+    _dims = new hsize_t[1];
+    _dims[0] = 1;
+
+    return *new H5CompoundData(*const_cast<H5CompoundData *>(this), 1, dataSize, 1, _dims, static_cast<char *>(data) + offset + pos * (dataSize + stride), type, 0, 0, false);
+}
+
+void H5CompoundData::getFieldNames(const int position, void * vApiCtx)
+{
+    std::vector<std::string> names;
+    names.reserve(nfields);
+
+    for (unsigned int i = 0; i < nfields; i++)
+    {
+        names.push_back(fieldinfos[i]->name);
+    }
+    H5BasicData<char>::putStringVectorOnStack(names, names.size(), 1, position, pvApiCtx);
+}
+
+std::string H5CompoundData::toString(const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    std::string indentString = H5Object::getIndentString(indentLevel + 1);
+
+    os << H5Object::getIndentString(indentLevel) << "HDF5 Compound data" << std::endl
+       << indentString << _("Dimensions") << ": [";
+
+    if (ndims == 0)
+    {
+        os << "1 x 1]";
+    }
+    else if (ndims == 1)
+    {
+        os << "1 x " << dims[0] << "]";
+    }
+    else
+    {
+        for (unsigned int i = 0; i < ndims - 1; i++)
+        {
+            os << dims[i] << " x ";
+        }
+        os << dims[ndims - 1] << "]" << std::endl;
+    }
+
+    os << indentString << _("Fields Names") << ": [";
+    for (unsigned int i = 0; i < nfields - 1; i++)
+    {
+        os << fieldinfos[i]->name << ", ";
+    }
+    os << fieldinfos[nfields - 1]->name << "]";
+
+    return os.str();
+}
+
+std::string H5CompoundData::dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+{
+    return H5DataConverter::dump(alreadyVisited, indentLevel, ndims, dims, *this, false);
+}
+
+void H5CompoundData::printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const
+{
+    os << "{" << std::endl;
+    std::string indent = H5Object::getIndentString(indentLevel + 2);
+
+    for (unsigned int i = 0; i < nfields; i++)
+    {
+        H5Data & hdata = H5DataFactory::getObjectData(*const_cast<H5CompoundData *>(this), totalSize, fieldinfos[i]->size, fieldinfos[i]->type, ndims, dims, data, stride ? stride : dataSize, offset + fieldinfos[i]->offset, false);
+        os << indent;
+        hdata.printData(os, pos, indentLevel + 2);
+
+        if (i != nfields - 1)
+        {
+            os << ", " << std::endl;
+        }
+
+        delete &hdata;
+    }
+
+    os << std::endl << H5Object::getIndentString(indentLevel + 1) << "}";
+}
+}
index d690c6c..07d3c6e 100644 (file)
@@ -13,7 +13,6 @@
 #ifndef __H5COMPOUNDDATA_HXX__
 #define __H5COMPOUNDDATA_HXX__
 
-#include "H5Data.hxx"
 #include "H5BasicData.hxx"
 
 namespace org_modules_hdf5
@@ -21,109 +20,64 @@ 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 hsize_t _arank, const hsize_t * _adims, const unsigned int _nfields, std::string * _fieldsname, H5Data ** _fieldsvalue, char * _data, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _arank, _adims, _data, -1, 0, _dataOwner), nfields(_nfields), fieldsname(_fieldsname), fieldsvalue(_fieldsvalue)
-    {
+    H5CompoundData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, hid_t compoundType, const hsize_t stride, const size_t offset, const bool _dataOwner);
 
-    }
+    virtual ~H5CompoundData();
 
-    virtual ~H5CompoundData()
-    {
-        delete[] fieldsname;
-        for (unsigned int i = 0; i < nfields; i++)
-        {
-            delete fieldsvalue[i];
-        }
-        delete[] fieldsvalue;
-    }
+    virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const;
 
-    H5Data & getData(const std::string fieldname) const
-    {
-        for (unsigned int i = 0; i < nfields; i++)
-        {
-            if (fieldname == fieldsname[i])
-            {
-                return *fieldsvalue[i];
-            }
-        }
+    virtual void getAccessibleAttribute(const std::string & _name, const int pos, void * pvApiCtx) const;
 
-        throw H5Exception(__LINE__, __FILE__, _("Invalid field name: %s"), fieldname.c_str());
-    }
+    virtual H5Data & getData(const std::string fieldname) const;
 
-    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
-    {
-        return H5DataConverter::dump(alreadyVisited, indentLevel, ndims, dims, *this, false);
-    }
+    virtual H5Object & getData(const unsigned int size, const unsigned int * index) const;
+
+    virtual bool isCompound() const;
+
+    virtual std::string toString(const unsigned int indentLevel) const;
+
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const;
+
+    virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const;
 
-    virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const
+    virtual void getFieldNames(const int position, void * pvApiCtx);
+
+    virtual bool mustDelete() const
     {
-        os << "{" << std::endl;
-        std::string indent = H5Object::getIndentString(indentLevel + 2);
-        for (unsigned int i = 0; i < nfields - 1; i++)
-        {
-            os << indent;
-            fieldsvalue[i]->printData(os, pos, indentLevel + 2);
-            os << ", " << std::endl;
-        }
-        os << indent;
-        fieldsvalue[nfields - 1]->printData(os, pos, indentLevel + 2);
-        os << std::endl << H5Object::getIndentString(indentLevel + 1) << "}";
+        return false;
     }
 
-    virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const
+protected:
+    class FieldInfo
     {
-        // TODO: gerer le cas ndims=0 (cas SCALAR)
 
-        static int structdims[2] = { 1, 1 };
-        const char ** _fieldsname = new const char *[nfields + 2];
-        SciErr err;
-        int * scilabStruct = 0;
+    public:
 
-        _fieldsname[0] = "st";
-        _fieldsname[1] = "dims";
-        for (int i = 0; i < nfields; i++)
-        {
-            _fieldsname[i + 2] = fieldsname[i].c_str();
-        }
+        const hid_t type;
+        const hsize_t size;
+        const size_t offset;
+        const std::string name;
 
-        if (parentList)
-        {
-            err = createMListInList(pvApiCtx, lhsPosition, parentList, listPosition, nfields + 1, &scilabStruct);
-        }
-        else
-        {
-            err = createMList(pvApiCtx, lhsPosition, nfields + 2, &scilabStruct);
-        }
+        FieldInfo(const hid_t _type, const hsize_t _size, const size_t _offset, const std::string _name) : type(_type), size(_size), offset(_offset), name(_name) { }
 
-        if (err.iErr)
+        ~FieldInfo()
         {
-            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"));
+            if (type)
+            {
+                H5Tclose(type);
+            }
         }
+    };
 
-        err = createMatrixOfInteger32InList(pvApiCtx, lhsPosition, scilabStruct, 2, 1, 2, structdims);
-        if (err.iErr)
-        {
-            throw H5Exception(__LINE__, __FILE__, _("Cannot create a struct on the stack"));
-        }
+private:
 
-        for (int i = 0; i < nfields; i++)
-        {
-            fieldsvalue[i]->toScilab(pvApiCtx, lhsPosition, scilabStruct, i + 3);
-        }
-    }
+    const hsize_t * cumprod;
+    unsigned int nfields;
+    std::map<std::string, FieldInfo *> * infos;
+    FieldInfo ** fieldinfos;
+    const hid_t type;
 };
 }
 
index 373b390..6097c81 100644 (file)
@@ -28,24 +28,15 @@ protected:
     const hsize_t dataSize;
     const hsize_t ndims;
     const hsize_t * dims;
-    const hsize_t arank;
-    const hsize_t * adims;
-    hsize_t atotalSize;
     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, const hsize_t _arank, const hsize_t * _adims, void * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5Object(_parent), totalSize(_totalSize), dataSize(_dataSize), ndims(_ndims), dims(_dims), arank(_arank), adims(_adims), data(_data), stride(_stride), offset(_offset), dataOwner(_dataOwner), atotalSize(1)
+    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, const size_t _offset, const bool _dataOwner) : H5Object(_parent), totalSize(_totalSize), dataSize(_dataSize), ndims(_ndims), dims(_dims), data(_data), stride(_stride), offset(_offset), dataOwner(_dataOwner)
     {
-        if (adims)
-        {
-            for (unsigned int i = 0; i < arank; i++)
-            {
-                atotalSize *= adims[i];
-            }
-        }
+
     }
 
     virtual ~H5Data()
@@ -54,22 +45,16 @@ public:
         {
             delete[] dims;
             delete[] static_cast<char *>(data);
-            if (adims)
-            {
-                delete[] adims;
-            }
         }
     }
 
-    virtual void * getData() const
+    inline virtual void * getData() const
     {
         return data;
     }
 
     virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const {  }
 
-    virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const = 0;
-
 protected:
 
     void createEmpty(void * pvApiCtx, const int position, int * parentList = 0, const int listPosition = 0) const
index 4fd242c..3deb128 100644 (file)
@@ -38,6 +38,9 @@ public:
         std::string indent = H5Object::getIndentString(indentLevel);
         unsigned int pos = 0;
 
+        os.setf(std::ios::fixed, std::ios::floatfield);
+        os.precision(1);
+
         os << indent << "DATA {" << std::endl;
         printData(indentLevel, indent + "(", os, ndims, dims, &pos, obj, line);
         os << indent << "}" << std::endl;
index 537afec..28dca85 100644 (file)
@@ -19,8 +19,6 @@ H5Data & H5DataFactory::getData(H5Object & parent, const hid_t obj, H5Dataspace
 {
     hsize_t ndims;
     hsize_t * dims = 0;
-    hsize_t arank = 0;
-    hsize_t * adims = 0;
     hsize_t totalSize;
     hsize_t dataSize;
     void * data = 0;
@@ -34,8 +32,8 @@ H5Data & H5DataFactory::getData(H5Object & parent, const hid_t obj, H5Dataspace
 
     try
     {
-        getNativeData(obj, spaceId, selectdims, type, &totalSize, &dataSize, &ndims, &dims, &arank, &adims, &data, isAttribute);
-        H5Data & ret = getObjectData(parent, totalSize, dataSize, nativeType, ndims, dims, arank, adims, data, -1, 0, true);
+        getNativeData(obj, spaceId, selectdims, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+        H5Data & ret = getObjectData(parent, totalSize, dataSize, nativeType, ndims, dims, data, 0, 0, true);
         H5Tclose(type);
         H5Tclose(nativeType);
 
@@ -49,10 +47,7 @@ H5Data & H5DataFactory::getData(H5Object & parent, const hid_t obj, H5Dataspace
         {
             delete[] dims;
         }
-        if (adims)
-        {
-            delete[] adims;
-        }
+
         if (data)
         {
             delete[] static_cast<char *>(data);
@@ -61,55 +56,55 @@ H5Data & H5DataFactory::getData(H5Object & parent, const hid_t obj, H5Dataspace
     }
 }
 
-H5Data & H5DataFactory::getObjectData(H5Object & parent, const hsize_t totalSize, const hsize_t dataSize, const hid_t type, hsize_t ndims, hsize_t * dims, const hsize_t arank, const hsize_t * adims, void * data, const hsize_t stride, const size_t offset, const bool dataOwner)
+H5Data & H5DataFactory::getObjectData(H5Object & parent, const hsize_t totalSize, const hsize_t dataSize, const hid_t type, const hsize_t ndims, const hsize_t * dims, void * data, const hsize_t stride, const size_t offset, const bool dataOwner)
 {
     switch (H5Tget_class(type))
     {
         case H5T_INTEGER:
             if (H5Tequal(type, H5T_NATIVE_SCHAR))
             {
-                return *new H5CharData(parent, totalSize, dataSize, ndims, dims, arank, adims, (char *)data, stride, offset, dataOwner);
+                return *new H5CharData(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, dataOwner);
             }
             else if (H5Tequal(type, H5T_NATIVE_UCHAR))
             {
-                return *new H5UnsignedCharData(parent, totalSize, dataSize, ndims, dims, arank, adims, (unsigned char *)data, stride, offset, dataOwner);
+                return *new H5UnsignedCharData(parent, totalSize, dataSize, ndims, dims, (unsigned char *)data, stride, offset, dataOwner);
             }
             else if (H5Tequal(type, H5T_NATIVE_SHORT))
             {
-                return *new H5BasicData<short>(parent, totalSize, dataSize, ndims, dims, arank, adims, (short *)data, stride, offset, dataOwner);
+                return *new H5BasicData<short>(parent, totalSize, dataSize, ndims, dims, (short *)data, stride, offset, dataOwner);
             }
             else if (H5Tequal(type, H5T_NATIVE_USHORT))
             {
-                return *new H5BasicData<unsigned short>(parent, totalSize, dataSize, ndims, dims, arank, adims, (unsigned short *)data, stride, offset, dataOwner);
+                return *new H5BasicData<unsigned short>(parent, totalSize, dataSize, ndims, dims, (unsigned short *)data, stride, offset, dataOwner);
             }
             else if (H5Tequal(type, H5T_NATIVE_INT))
             {
-                return *new H5BasicData<int>(parent, totalSize, dataSize, ndims, dims, arank, adims, (int *)data, stride, offset, dataOwner);
+                return *new H5BasicData<int>(parent, totalSize, dataSize, ndims, dims, (int *)data, stride, offset, dataOwner);
             }
             else if (H5Tequal(type, H5T_NATIVE_UINT))
             {
-                return *new H5BasicData<unsigned int>(parent, totalSize, dataSize, ndims, dims, arank, adims, (unsigned int *)data, stride, offset, dataOwner);
+                return *new H5BasicData<unsigned int>(parent, totalSize, dataSize, ndims, dims, (unsigned int *)data, stride, offset, dataOwner);
             }
 
 #ifdef __SCILAB_INT64__
 
             else if (H5Tequal(type, H5T_NATIVE_LONG))
             {
-                return *new H5BasicData<long long>(parent, totalSize, dataSize, ndims, dims, arank, adims, (long long *)data, stride, offset, dataOwner);
+                return *new H5BasicData<long long>(parent, totalSize, dataSize, ndims, dims, (long long *)data, stride, offset, dataOwner);
             }
             else if (H5Tequal(type, H5T_NATIVE_ULONG))
             {
-                return *new H5BasicData<unsigned long long>(parent, totalSize, dataSize, ndims, dims, arank, adims, (unsigned long long *)data, stride, offset, dataOwner);
+                return *new H5BasicData<unsigned long long>(parent, totalSize, dataSize, ndims, dims, (unsigned long long *)data, stride, offset, dataOwner);
             }
 #else
 
             else if (H5Tequal(type, H5T_NATIVE_LONG))
             {
-                return *new H5TransformedData<long long, int>(parent, totalSize, dataSize, ndims, dims, arank, adims, (long long *)data, stride, offset, dataOwner);
+                return *new H5TransformedData<long long, int>(parent, totalSize, dataSize, ndims, dims, (long long *)data, stride, offset, dataOwner);
             }
             else if (H5Tequal(type, H5T_NATIVE_ULONG))
             {
-                return *new H5TransformedData<unsigned long long, unsigned int>(parent, totalSize, dataSize, ndims, dims, arank, adims, (unsigned long long *)data, stride, offset, dataOwner);
+                return *new H5TransformedData<unsigned long long, unsigned int>(parent, totalSize, dataSize, ndims, dims, (unsigned long long *)data, stride, offset, dataOwner);
             }
 
 #endif // __SCILAB_INT64__
@@ -122,11 +117,11 @@ H5Data & H5DataFactory::getObjectData(H5Object & parent, const hsize_t totalSize
         case H5T_FLOAT:
             if (H5Tequal(type, H5T_NATIVE_FLOAT))
             {
-                return *new H5TransformedData<float, double>(parent, totalSize, dataSize, ndims, dims, arank, adims, (float *)data, stride, offset, dataOwner);
+                return *new H5TransformedData<float, double>(parent, totalSize, dataSize, ndims, dims, (float *)data, stride, offset, dataOwner);
             }
             else if (H5Tequal(type, H5T_NATIVE_DOUBLE))
             {
-                return *new H5BasicData<double>(parent, totalSize, dataSize, ndims, dims, arank, adims, (double *)data, stride, offset, dataOwner);
+                return *new H5BasicData<double>(parent, totalSize, dataSize, ndims, dims, (double *)data, stride, offset, dataOwner);
             }
             else
             {
@@ -134,25 +129,25 @@ H5Data & H5DataFactory::getObjectData(H5Object & parent, const hsize_t totalSize
             }
             break;
         case H5T_TIME:
-            return *new H5TimeData(parent, totalSize, dataSize, ndims, dims, arank, adims, (char *)data, stride, offset, dataOwner);
+            return *new H5TimeData(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, dataOwner);
         case H5T_STRING:
             if (H5Tis_variable_str(type))
             {
-                return *new H5StringData(parent, totalSize, dataSize, ndims, dims, arank, adims, (char **)data, stride, offset, dataOwner);
+                return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char **)data, stride, offset, dataOwner);
             }
             else
             {
-                return *new H5StringData(parent, totalSize, dataSize, ndims, dims, arank, adims, (char *)data, stride, offset, dataOwner);
+                return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, dataOwner);
             }
         case H5T_BITFIELD:
             switch (dataSize)
             {
                 case 1:
-                    return *new H5Bitfield1Data(parent, totalSize, dataSize, ndims, dims, arank, adims, static_cast<unsigned char *>(data), stride, offset, dataOwner);
+                    return *new H5Bitfield1Data(parent, totalSize, dataSize, ndims, dims, static_cast<unsigned char *>(data), stride, offset, dataOwner);
                 case 2:
-                    return *new H5Bitfield2Data(parent, totalSize, dataSize, ndims, dims, arank, adims, static_cast<unsigned short *>(data), stride, offset, dataOwner);
+                    return *new H5Bitfield2Data(parent, totalSize, dataSize, ndims, dims, static_cast<unsigned short *>(data), stride, offset, dataOwner);
                 case 4:
-                    return *new H5Bitfield4Data(parent, totalSize, dataSize, ndims, dims, arank, adims, static_cast<unsigned int *>(data), stride, offset, dataOwner);
+                    return *new H5Bitfield4Data(parent, totalSize, dataSize, ndims, dims, static_cast<unsigned int *>(data), stride, offset, dataOwner);
                 case 8:
                     //return *new H5BitfieldData<unsigned long long>(parent, totalSize, dataSize, ndims, dims, static_cast<unsigned long long *>(data), stride, offset, false);
                 default:
@@ -160,29 +155,12 @@ H5Data & H5DataFactory::getObjectData(H5Object & parent, const hsize_t totalSize
             }
 
         case H5T_OPAQUE:
-            return *new H5OpaqueData(parent, totalSize, dataSize, ndims, dims, arank, adims, (unsigned char *)data, stride, offset, dataOwner);
+            return *new H5OpaqueData(parent, totalSize, dataSize, ndims, dims, (unsigned char *)data, stride, offset, dataOwner);
         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] = &getObjectData(parent, totalSize, dataSize, mtype, ndims, dims, arank, adims, data, stride, offset + offs, false);
-            }
-
-            return *new H5CompoundData(parent, totalSize, dataSize, ndims, dims, arank, adims, nmembers, names, fields, (char *)data, dataOwner);
-        }
+            return *new H5CompoundData(parent, totalSize, dataSize, ndims, dims, (char *)data, H5Tcopy(type), stride, offset, dataOwner);
         case H5T_REFERENCE:
             // TODO: virer le false
-            return *new H5ReferenceData(parent, false, totalSize, dataSize, ndims, dims, arank, adims, (char *)data, stride, offset, dataOwner);
+            return *new H5ReferenceData(parent, H5Tequal(type, H5T_STD_REF_DSETREG) ? H5R_DATASET_REGION : H5R_OBJECT, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, dataOwner);
         case H5T_ENUM:
         {
             int nmembers = H5Tget_nmembers(type);
@@ -195,25 +173,12 @@ H5Data & H5DataFactory::getObjectData(H5Object & parent, const hsize_t totalSize
                 free(mname);
             }
 
-            return *new H5EnumData(parent, totalSize, dataSize, ndims, dims, arank, adims, (unsigned int *)data, nmembers, names, stride, offset, dataOwner);
+            return *new H5EnumData(parent, totalSize, dataSize, ndims, dims, (unsigned int *)data, nmembers, names, stride, offset, dataOwner);
         }
         case H5T_VLEN:
-            //return *new H5VlenData(parent, totalSize, dataSize, ndims, dims, data, offset);
+            return *new H5VlenData(parent, totalSize, dataSize, ndims, dims, static_cast<char *>(data), type, stride, offset, dataOwner);
         case H5T_ARRAY:
-        {
-            hid_t super = H5Tget_super(type);
-            try
-            {
-                H5Data & ret = getObjectData(parent, totalSize, dataSize, super, ndims, dims, arank, adims, data, stride, offset, dataOwner);
-                H5Tclose(super);
-                return ret;
-            }
-            catch (const H5Exception & e)
-            {
-                H5Tclose(super);
-                throw;
-            }
-        }
+            return *new H5ArrayData(parent, totalSize, dataSize, ndims, dims, static_cast<char *>(data), type, stride, offset, dataOwner);
         default:
             throw H5Exception(__LINE__, __FILE__, _("Cannot get data from an unknown data type."));
     }
@@ -221,7 +186,7 @@ H5Data & H5DataFactory::getObjectData(H5Object & parent, const hsize_t totalSize
     throw H5Exception(__LINE__, __FILE__, _("Cannot get data from an unknown data type."));
 }
 
-void H5DataFactory::getNativeData(const hid_t obj, const hid_t space, hsize_t * selectdims, const hid_t type, hsize_t * totalSize, hsize_t * dataSize, hsize_t * ndims, hsize_t ** dims, hsize_t * arank, hsize_t ** adims, void ** data, const bool isAttribute)
+void H5DataFactory::getNativeData(const hid_t obj, const hid_t space, hsize_t * selectdims, 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);
     hid_t _space = space < 0 ? (isAttribute ? H5Aget_space(obj) : H5Dget_space(obj)) : space;
@@ -241,13 +206,6 @@ void H5DataFactory::getNativeData(const hid_t obj, const hid_t space, hsize_t *
         isString = true;
     }
 
-    if (H5Tget_class(nativeType) == H5T_ARRAY)
-    {
-        *arank = H5Tget_array_ndims(nativeType);
-        *adims = new hsize_t[*arank];
-        H5Tget_array_dims(nativeType, *adims);
-    }
-
     *dataSize = size;
     *ndims = H5Sget_simple_extent_dims(_space, 0, 0);
     *dims = new hsize_t[*ndims];
@@ -298,14 +256,29 @@ void H5DataFactory::getNativeData(const hid_t obj, const hid_t space, hsize_t *
         throw H5Exception(__LINE__, __FILE__, _("Memory to allocate is too big"));
     }
 
-    if (isString)
+    try
     {
-        *data = static_cast<void *>(new char[(size_t)size]());
+       if (isString)
+       {
+           *data = static_cast<void *>(new char[(size_t)size]());
+       }
+       else
+       {
+           // No need to initialize the array
+           *data = static_cast<void *>(new char[(size_t)size]);
+       }
     }
-    else
+    catch (const std::bad_alloc & e)
     {
-        // No need to initialize the array
-        *data = static_cast<void *>(new char[(size_t)size]);
+       H5Tclose(nativeType);
+        if (space < 0)
+        {
+            H5Sclose(_space);
+        }
+       *data = 0;
+       delete[] *dims;
+       *dims = 0;
+        throw H5Exception(__LINE__, __FILE__, _("Cannot allocate memory to get the data"));
     }
 
     if (!*data)
@@ -316,6 +289,7 @@ void H5DataFactory::getNativeData(const hid_t obj, const hid_t space, hsize_t *
             H5Sclose(_space);
         }
         delete[] *dims;
+       *dims = 0;
         throw H5Exception(__LINE__, __FILE__, _("Cannot allocate memory to get the data"));
     }
 
@@ -345,7 +319,9 @@ void H5DataFactory::getNativeData(const hid_t obj, const hid_t space, hsize_t *
             H5Sclose(_space);
         }
         delete[] static_cast<char *>(*data);
+       *data = 0;
         delete[] *dims;
+       *dims = 0;
         throw H5Exception(__LINE__, __FILE__, _("Cannot retrieve the data from the attribute"));
     }
 
index 0229de4..a2da5cb 100644 (file)
 #include "H5BitfieldData.hxx"
 #include "H5ReferenceData.hxx"
 #include "H5CompoundData.hxx"
+#include "H5ArrayData.hxx"
 #include "H5OpaqueData.hxx"
 #include "H5TransformedData.hxx"
 #include "H5EnumData.hxx"
-//#include "H5VlenData.hxx"
+#include "H5VlenData.hxx"
 #include "H5CharData.hxx"
 #include "H5UnsignedCharData.hxx"
 
@@ -38,11 +39,11 @@ public:
 
     static H5Data & getData(H5Object & parent, const hid_t obj, H5Dataspace * space, hsize_t * selectdims, const bool isAttribute);
 
-private:
+    static H5Data & getObjectData(H5Object & parent, const hsize_t totalSize, const hsize_t dataSize, const hid_t type, const hsize_t ndims, const hsize_t * dims, void * data, const hsize_t stride, const size_t offset, const bool dataOwner);
 
-    static H5Data & getObjectData(H5Object & parent, const hsize_t totalSize, const hsize_t dataSize, const hid_t type, hsize_t ndims, hsize_t * dims, const hsize_t arank, const hsize_t * adims, void * data, const hsize_t stride, const size_t offset, const bool dataOwner);
+private:
 
-    static void getNativeData(const hid_t obj, const hid_t space, hsize_t * selectdims, const hid_t type, hsize_t * totalSize, hsize_t * dataSize, hsize_t * ndims, hsize_t ** dims, hsize_t * arank, hsize_t ** adims, void ** data, const bool isAttribute);
+    static void getNativeData(const hid_t obj, const hid_t space, hsize_t * selectdims, const hid_t type, hsize_t * totalSize, hsize_t * dataSize, hsize_t * ndims, hsize_t ** dims, void ** data, const bool isAttribute);
 };
 }
 
index e3725e9..70baec2 100644 (file)
@@ -138,7 +138,7 @@ void H5Dataset::getAccessibleAttribute(const std::string & _name, const int pos,
         const H5Data & data = const_cast<H5Dataset *>(this)->getData();
         data.toScilab(pvApiCtx, pos);
 
-        if (!data.isReference())
+        if (data.mustDelete())
         {
             delete &data;
         }
@@ -211,20 +211,42 @@ std::string H5Dataset::dump(std::map<haddr_t, std::string> & alreadyVisited, con
     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();
     const H5Dataset::H5Layout & layout = const_cast<H5Dataset *>(this)->getLayout();
 
+    H5Data * data = 0;
+
+    try
+    {
+       data = &const_cast<H5Dataset *>(this)->getData();
+    }
+    catch (const H5Exception & e)
+    {
+
+    }
+
     os << H5Object::getIndentString(indentLevel) << "DATASET \"" << getName() << "\" {" << std::endl
        << type.dump(alreadyVisited, indentLevel + 1)
        << space.dump(alreadyVisited, indentLevel + 1)
-       << layout.dump(alreadyVisited, indentLevel + 1)
-       << data.dump(alreadyVisited, indentLevel + 1)
-       << attrs.dump(alreadyVisited, indentLevel + 1)
+       << layout.dump(alreadyVisited, indentLevel + 1);
+    
+    if (data)
+    {
+       os << data->dump(alreadyVisited, indentLevel + 1);
+    }
+    else
+    {
+       os << H5Object::getIndentString(indentLevel + 1) << _("Error in retrieving data.") << std::endl;
+    }
+
+    os << attrs.dump(alreadyVisited, indentLevel + 1)
        << H5Object::getIndentString(indentLevel) << "}" << std::endl;
 
     delete &type;
     delete &space;
-    delete &data;
+    if (data)
+    {
+       delete data;
+    }
     delete &attrs;
     delete &layout;
 
index 089ffc8..c9c4183 100644 (file)
@@ -16,7 +16,7 @@
 namespace org_modules_hdf5
 {
 
-H5DatasetsList::H5DatasetsList(H5Group & _parent) : H5NamedObjectsList(_parent, H5G_DATASET, "H5 Dataset")
+H5DatasetsList::H5DatasetsList(H5Group & _parent) : H5NamedObjectsList<H5Dataset>(_parent, H5G_DATASET, "H5 Dataset")
 {
 
 }
index 106ca1f..344fde5 100644 (file)
@@ -26,7 +26,7 @@ class H5EnumData : public H5BasicData<unsigned int>
 
 public:
 
-    H5EnumData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, unsigned int * _data, const int _nmembers, const std::string * _names, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _arank, _adims, _data, _stride, _offset, _dataOwner), nmembers(_nmembers), names(_names)
+    H5EnumData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, unsigned int * _data, const int _nmembers, const std::string * _names, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData<unsigned int>(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner), nmembers(_nmembers), names(_names)
     {
 
     }
index 4e54ad2..d2a8279 100644 (file)
@@ -14,7 +14,8 @@
 
 namespace org_modules_hdf5
 {
-H5GroupsList::H5GroupsList(H5Object & _parent) : H5ListObject(_parent) { }
+
+H5GroupsList::H5GroupsList(H5Object & _parent) : H5ListObject<H5Group>(_parent) { }
 
 H5GroupsList::~H5GroupsList() { }
 
index 67c5ec0..65ec66e 100644 (file)
@@ -24,7 +24,7 @@ class H5GroupsList : public H5NamedObjectsList<H5Group>
 
 public :
 
-    H5GroupsList(H5Group & _parent) : H5NamedObjectsList(_parent, H5O_TYPE_GROUP, -1, "H5 Group") { }
+    H5GroupsList(H5Group & _parent) : H5NamedObjectsList<H5Group>(_parent, H5O_TYPE_GROUP, -1, "H5 Group") { }
 
     ~H5GroupsList()
     {
index f39b450..fb8a415 100644 (file)
@@ -14,7 +14,7 @@
 
 namespace org_modules_hdf5
 {
-H5LinksList::H5LinksList(H5Object & _parent) : H5ListObject(_parent) { }
+H5LinksList::H5LinksList(H5Object & _parent) : H5ListObject<H5Object>(_parent) { }
 
 H5LinksList::~H5LinksList() { }
 
index dce37f3..46a9b0f 100644 (file)
@@ -123,6 +123,26 @@ public :
         return false;
     }
 
+    virtual bool isCompound() const
+    {
+        return false;
+    }
+
+    virtual bool isArray() const
+    {
+        return false;
+    }
+
+    virtual bool isVlen() const
+    {
+        return false;
+    }
+
+    virtual bool mustDelete() const
+    {
+        return true;
+    }
+
     virtual haddr_t getAddr() const
     {
         return getInfo().addr;
@@ -133,6 +153,31 @@ public :
         return name;
     }
 
+    virtual H5Object & getData(const unsigned int size, const unsigned int * index) const
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot retrieve numeric index."));
+    }
+
+    virtual H5Object & getData(const unsigned int size, const double * index) const
+    {
+        unsigned int * _index = new unsigned int[size];
+        for (unsigned int i = 0; i < size; i++)
+        {
+            _index[i] = (unsigned int)(index[i] - 1);
+        }
+
+        try
+        {
+            return getData(size, _index);
+        }
+        catch (const H5Exception & e)
+        {
+            delete[] _index;
+            throw;
+        }
+    }
+
+
     virtual const std::string getBaseName() const
     {
         std::string::size_type pos = name.find_last_of('/');
@@ -210,6 +255,19 @@ public :
     virtual void getNames(const H5Object & obj, std::vector<std::string> & names, FilterType type) const;
     virtual void createOnScilabStack(int pos, void * pvApiCtx) const;
     virtual void createInScilabList(int * list, int stackPos, int pos, void * pvApiCtx) const;
+
+    virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const
+    {
+        if (parentList)
+        {
+            createInScilabList(parentList, lhsPosition, listPosition, pvApiCtx);
+        }
+        else
+        {
+            createOnScilabStack(lhsPosition, pvApiCtx);
+        }
+    }
+
     bool isRoot() const
     {
         return this == &root;
@@ -250,6 +308,18 @@ public :
     static H5Object & getObject(H5Object & parent, const std::string & name, const bool isAttr);
     static void getLinksInfo(const H5Object & obj, std::vector<std::string> & linksName, std::vector<std::string> & types, std::vector<std::string> & linksType);
 
+    inline static hsize_t * getCumProd(const hsize_t ndims, const hsize_t * dims)
+    {
+        hsize_t * ret = new hsize_t[ndims];
+        ret[0] = 1;
+        for (unsigned int i = 1; i < ndims; i++)
+        {
+            ret[i] *= ret[i - 1];
+        }
+
+        return ret;
+    }
+
     inline static bool isEmptyPath(const std::string & path)
     {
         return path.empty() || path == ".";
index 31fde8e..5ec2659 100644 (file)
@@ -23,7 +23,7 @@ class H5OpaqueData : public H5BasicData<unsigned char>
 
 public:
 
-    H5OpaqueData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, unsigned char * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _arank, _adims, _data, _stride, _offset, _dataOwner)
+    H5OpaqueData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, unsigned char * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData<unsigned char>(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner)
     {
 
     }
index c9ebc48..3de9173 100644 (file)
 namespace org_modules_hdf5
 {
 
-H5ReferenceData::H5ReferenceData(H5Object & _parent, const bool _datasetReference, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, char * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _arank, _adims, _data, _stride, _offset, _dataOwner), datasetReference(_datasetReference)
+H5ReferenceData::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, const size_t _offset, const bool _dataOwner) : H5BasicData<char>(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner), datasetReference(_datasetReference), cumprod(H5Object::getCumProd(_ndims, dims))
 {
 
 }
 
 H5ReferenceData::~H5ReferenceData()
 {
-
+    delete[] cumprod;
 }
 
 const char ** H5ReferenceData::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];
@@ -49,29 +48,7 @@ const char ** H5ReferenceData::getReferencesName() const
     return names;
 }
 
-H5Object & H5ReferenceData::getReferencesObject(const unsigned int size, const double * index) const
-{
-    H5Object * obj = 0;
-    unsigned int * iindex = new unsigned int[size];
-    for (unsigned int i = 0; i < size; i++)
-    {
-        iindex[i] = (unsigned int)(index[i]);
-    }
-
-    try
-    {
-        obj = &getReferencesObject(size, iindex);
-        delete[] iindex;
-        return *obj;
-    }
-    catch (const H5Exception & e)
-    {
-        delete[] iindex;
-        throw;
-    }
-}
-
-H5Object & H5ReferenceData::getReferencesObject(const unsigned int size, const unsigned int * index) const
+H5Object & H5ReferenceData::getData(const unsigned int size, const unsigned int * index) const
 {
     char * cdata = static_cast<char *>(data) + offset;
     void ** ref = 0;
@@ -88,7 +65,6 @@ H5Object & H5ReferenceData::getReferencesObject(const unsigned int size, const u
     for (unsigned int i = 0; i < size; i++)
     {
         pos += cumprod * index[i];
-        cumprod *= dims[i];
     }
 
     if (pos >= totalSize)
@@ -96,8 +72,10 @@ H5Object & H5ReferenceData::getReferencesObject(const unsigned int size, const u
         throw H5Exception(__LINE__, __FILE__, _("Invalid index."));
     }
 
+    cdata += pos * (stride ? stride : dataSize);
+
     file = getFile().getH5Id();
-    ref = &(((void **)cdata)[pos]);
+    ref = &(((void **)cdata)[0]);
     obj = H5Rdereference(file, datasetReference ? H5R_DATASET_REGION : H5R_OBJECT, ref);
     if (obj < 0)
     {
@@ -192,48 +170,126 @@ std::string H5ReferenceData::dump(std::map<haddr_t, std::string> & alreadyVisite
 
 void H5ReferenceData::printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const
 {
-    char * cdata = static_cast<char *>(data) + offset;
-    void ** ref = &(((void **)cdata)[pos]);
+    char * cdata = static_cast<char *>(data) + offset + pos * (stride ? stride : dataSize);
+    void ** ref = &(((void **)cdata)[0]);
     hid_t file = getFile().getH5Id();
     hid_t obj = H5Rdereference(file, datasetReference ? H5R_DATASET_REGION : H5R_OBJECT, ref);
+    if (obj < 0)
+    {
+        os << "NULL";
+        return;
+    }
+
     ssize_t size = H5Rget_name(file, datasetReference ? H5R_DATASET_REGION : H5R_OBJECT, ref, 0, 0);
-    char * name = new char[size + 1];
+    char * name = 0;
     H5O_info_t info;
 
-    H5Rget_name(file, datasetReference ? H5R_DATASET_REGION : H5R_OBJECT, ref, name, size + 1);
-    H5Oget_info(obj, &info);
-    H5Oclose(obj);
-
-    switch (info.type)
+    if (size != -1)
     {
-        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:
-            delete[] name;
-            throw H5Exception(__LINE__, __FILE__, _("Unknown HDF5 object"));
-    }
+        name = new char[size + 1];
+        H5Rget_name(file, datasetReference ? H5R_DATASET_REGION : H5R_OBJECT, ref, name, size + 1);
 
-    os << (haddr_t)(*ref) << " " << name;
-    delete[] name;
-}
+        if (datasetReference == H5R_OBJECT)
+        {
+            H5Oget_info(obj, &info);
+            H5Oclose(obj);
 
-void H5ReferenceData::toScilab(void * pvApiCtx, const int lhsPosition, int * parentList, const int listPosition) const
-{
-    if (parentList)
-    {
-        createInScilabList(parentList, lhsPosition, listPosition, pvApiCtx);
-    }
-    else
-    {
-        createOnScilabStack(lhsPosition, pvApiCtx);
+            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:
+                    if (size != -1)
+                    {
+                        delete[] name;
+                    }
+                    throw H5Exception(__LINE__, __FILE__, _("Unknown HDF5 object"));
+            }
+
+            os << (haddr_t)(*ref) << " " << name;
+        }
+        else
+        {
+            hid_t space = H5Rget_region(file, H5R_DATASET_REGION, ref);
+            hssize_t npoints = H5Sget_select_elem_npoints(space);
+            hsize_t ndims = H5Sget_simple_extent_dims(space, 0, 0);
+            H5Oclose(obj);
+
+            os << "DATASET " << name << " {";
+
+            if (npoints >= 0)
+            {
+                const hsize_t N = ndims * npoints;
+                hsize_t * buf = new hsize_t[N];
+                herr_t err =  H5Sget_select_elem_pointlist(space, 0, npoints, buf);
+                for (hssize_t i = 0; i < N; i += ndims)
+                {
+                    os << "(";
+                    for (unsigned int j = 0; j < ndims - 1; j++)
+                    {
+                        os << buf[i + j] << ",";
+                    }
+                    os << buf[i + ndims - 1] << ")";
+
+                    if (i != N - ndims)
+                    {
+                        os << ", ";
+                    }
+                    else
+                    {
+                        os << "}";
+                    }
+                }
+                delete[] buf;
+            }
+            else
+            {
+                hssize_t nblocks = H5Sget_select_hyper_nblocks(space);
+                if (nblocks >= 0)
+                {
+                    const hsize_t N = 2 * ndims * nblocks;
+                    hsize_t * buf = new hsize_t[N];
+                    herr_t err = H5Sget_select_hyper_blocklist(space, 0, nblocks, buf);
+                    for (hssize_t i = 0; i < N; i += 2 * ndims)
+                    {
+                        os << "(";
+                        for (unsigned int j = 0; j < ndims - 1; j++)
+                        {
+                            os << buf[i + j] << ",";
+                        }
+                        os << buf[i + ndims - 1] << ")-(";
+                        for (unsigned int j = 0; j < ndims - 1; j++)
+                        {
+                            os << buf[i + ndims + j] << ",";
+                        }
+                        os << buf[i + 2 * ndims - 1] << ")";
+
+                        if (i != N - 2 * ndims)
+                        {
+                            os << ", ";
+                        }
+                        else
+                        {
+                            os << "}";
+                        }
+                    }
+
+                    delete[] buf;
+                }
+            }
+
+            H5Sclose(space);
+        }
+
+        delete[] name;
     }
 }
 }
index f44c0e0..c6c62d9 100644 (file)
@@ -26,10 +26,11 @@ class H5ReferenceData : public H5BasicData<char>
 {
 
     const bool datasetReference;
+    const hsize_t * cumprod;
 
 public:
 
-    H5ReferenceData(H5Object & _parent, const bool _datasetReference, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, char * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner);
+    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, const size_t _offset, const bool _dataOwner);
     virtual ~H5ReferenceData();
 
     bool isReference() const
@@ -40,9 +41,7 @@ public:
 
     H5Object ** getReferencesObject() const;
 
-    H5Object & getReferencesObject(const unsigned int size, const unsigned int * index) const;
-
-    H5Object & getReferencesObject(const unsigned int size, const double * index) const;
+    virtual H5Object & getData(const unsigned int size, const unsigned int * index) const;
 
     virtual std::string toString(const unsigned int indentLevel) const;
 
@@ -50,7 +49,10 @@ public:
 
     virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const;
 
-    virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const;
+    virtual bool mustDelete() const
+    {
+        return false;
+    }
 
     static void deleteReferencesObjects(H5Object ** objs, const unsigned int size);
 };
index 0da9667..0946cec 100644 (file)
@@ -25,7 +25,7 @@ class H5SoftLinksList : public H5NamedObjectsList<H5SoftLink>
 
 public :
 
-    H5SoftLinksList(H5Group & _parent) : H5NamedObjectsList(_parent, H5O_TYPE_GROUP, H5L_TYPE_SOFT, "H5 Soft Link") { }
+    H5SoftLinksList(H5Group & _parent) : H5NamedObjectsList<H5SoftLink>(_parent, H5O_TYPE_GROUP, H5L_TYPE_SOFT, "H5 Soft Link") { }
 
     ~H5SoftLinksList()
     {
index cdf99d8..cf48c84 100644 (file)
 namespace org_modules_hdf5
 {
 
-H5StringData::H5StringData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _stringSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, char * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5Data(_parent, _totalSize, _stringSize, _ndims, _dims, _arank, _adims, _data, _stride == -1 ? _stringSize : _stride, _offset, _dataOwner)
+H5StringData::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, const size_t _offset, const bool _dataOwner) : H5Data(_parent, _totalSize, _stringSize, _ndims, _dims, _data, _stride == 0 ? _stringSize : _stride, _offset, _dataOwner)
 {
     char * __data = static_cast<char *>(_data);
     transformedData = new char*[totalSize];
 
-    if (stride == -1)
+    if (stride == 0)
     {
         *transformedData = __data;
         for (unsigned int i = 1; i < (unsigned int)totalSize; i++)
@@ -38,7 +38,7 @@ H5StringData::H5StringData(H5Object & _parent, const hsize_t _totalSize, const h
     }
 }
 
-H5StringData::H5StringData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _stringSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, char ** _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5Data(_parent, _totalSize, _stringSize, _ndims, _dims, _arank, _adims, _data, _stride == -1 ? _stringSize : _stride, _offset, _dataOwner), transformedData(0)
+H5StringData::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, const size_t _offset, const bool _dataOwner) : H5Data(_parent, _totalSize, _stringSize, _ndims, _dims, _data, _stride == 0 ? _stringSize : _stride, _offset, _dataOwner), transformedData(0)
 {
 
 }
index 5b14932..0d8ded1 100644 (file)
@@ -27,9 +27,9 @@ protected:
 
 public:
 
-    H5StringData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _stringSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, char * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner);
+    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, const size_t _offset, const bool _dataOwner);
 
-    H5StringData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _stringSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, char ** _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner);
+    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, const size_t _offset, const bool _dataOwner);
 
     virtual ~H5StringData();
 
index 99940f0..e9f7bb6 100644 (file)
@@ -23,9 +23,8 @@ 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, const hsize_t _arank, const hsize_t * _adims, char * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _arank, _adims, _data, _stride, _offset, _dataOwner)
+    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, const size_t _offset, const bool _dataOwner) : H5BasicData<char>(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner)
     {
-        //dims[ndims - 1] = dataSize;
     }
 
     virtual ~H5TimeData()
index 96685a7..bdb2280 100644 (file)
@@ -28,11 +28,11 @@ protected:
 
 public:
 
-    H5TransformedData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, T * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5Data(_parent, _totalSize, _dataSize, _ndims, _dims, _arank, _adims, _data, _stride, _offset, _dataOwner)
+    H5TransformedData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, T * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5Data(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner)
     {
         transformedData = new U[totalSize];
 
-        if (stride == -1)
+        if (stride == 0)
         {
             for (unsigned int i = 0; i < (unsigned int)totalSize; i++)
             {
index d0018ab..40d845b 100644 (file)
@@ -728,6 +728,63 @@ std::string H5Type::getNameFromType(hid_t type)
     }
 }
 
+void H5Type::printComplexNameFromType(std::ostringstream & os, const unsigned int indentLevel, const hid_t type)
+{
+    std::string indent = H5Object::getIndentString(indentLevel);
+    if (H5Tget_class(type) == H5T_COMPOUND)
+    {
+        unsigned int nmembers = H5Tget_nmembers(type);
+
+        os << indent << "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 << indent;
+            H5Type::printComplexNameFromType(os, indentLevel + 1, mtype);
+            os << " \"" << mname << "\";" << std::endl;
+            os << std::endl;
+
+            free(mname);
+        }
+
+        os << indent << "}";
+    }
+    else if (H5Tget_class(type) == H5T_ARRAY)
+    {
+        hid_t super = H5Tget_super(type);
+        unsigned int ndims = H5Tget_array_ndims(type);
+        hsize_t * dims = new hsize_t[ndims];
+        H5Tget_array_dims(type, dims);
+
+        os << indent << "H5T_ARRAY { ";
+
+        for (unsigned int i = 0; i < ndims; i++)
+        {
+            os << "[" << (unsigned int)dims[i] << "]";
+        }
+
+        os << " ";
+        H5Type::printComplexNameFromType(os, indentLevel + 1, super);
+        os <<  " }";
+        H5Tclose(super);
+    }
+    else if (H5Tget_class(type) == H5T_VLEN)
+    {
+        hid_t super = H5Tget_super(type);
+        os << indent << "H5T_VLEN { ";
+        H5Type::printComplexNameFromType(os, indentLevel + 1, super);
+        os << " }";
+        H5Tclose(super);
+    }
+    else
+    {
+        os << getNameFromType(type);
+    }
+}
+
 void H5Type::getAccessibleAttribute(const std::string & _name, const int pos, void * pvApiCtx) const
 {
     SciErr err;
@@ -1507,8 +1564,9 @@ std::string H5Type::dump(std::map<haddr_t, std::string> & alreadyVisited, const
                 char * mname = H5Tget_member_name(type, i);
                 hid_t mtype = H5Tget_member_type(type, i);
 
-                os << indent << H5Type(*const_cast<H5Type *>(this), mtype).getTypeName()
-                   << " " << "\"" << mname << "\";" << std::endl;
+                os << indent;
+                H5Type::printComplexNameFromType(os, indentLevel + 1, mtype);
+                os << " \"" << mname << "\";" << std::endl;
 
                 free(mname);
             }
@@ -1597,9 +1655,12 @@ std::string H5Type::dump(std::map<haddr_t, std::string> & alreadyVisited, const
             os << H5Object::getIndentString(indentLevel) << "}";
             break;
         case H5T_VLEN:
-            os << "H5T_VLEN { " << std::endl
-               << H5Type(*const_cast<H5Type *>(this), H5Tget_super(type)).dump(alreadyVisited, indentLevel + 1)
-               << H5Object::getIndentString(indentLevel) << "}";
+            super = H5Tget_super(type);
+            os << "H5T_VLEN { ";
+
+            H5Type::printComplexNameFromType(os, indentLevel + 1, super);
+
+            os << " }";
             break;
         case H5T_ARRAY:
             super = H5Tget_super(type);
@@ -1614,7 +1675,9 @@ std::string H5Type::dump(std::map<haddr_t, std::string> & alreadyVisited, const
                 os << "[" << (unsigned int)dims[i] << "]";
             }
 
-            os << " " << getNameFromType(super) << " }";
+            os << " ";
+            H5Type::printComplexNameFromType(os, indentLevel + 1, super);
+            os << " }";
 
             H5Tclose(super);
             delete[] dims;
index 14e4014..173fe39 100644 (file)
@@ -58,6 +58,7 @@ public:
     virtual std::string ls() const;
 
     static std::string getNameFromType(hid_t type);
+    static void printComplexNameFromType(std::ostringstream & os, const unsigned int indentLevel, const hid_t type);
 
     inline static hid_t getBaseType(double * data)
     {
index e79f308..0e61a51 100644 (file)
@@ -26,7 +26,7 @@ class H5TypesList : public H5NamedObjectsList<H5Type>
 
 public :
 
-    H5TypesList(H5Group & _parent) : H5NamedObjectsList(_parent, H5O_TYPE_NAMED_DATATYPE, -1, "H5 Type") { }
+    H5TypesList(H5Group & _parent) : H5NamedObjectsList<H5Type>(_parent, H5O_TYPE_NAMED_DATATYPE, -1, "H5 Type") { }
 
     ~H5TypesList()
     {
index aa2c710..9068191 100644 (file)
@@ -23,7 +23,7 @@ class H5UnsignedCharData : public H5BasicData<unsigned char>
 
 public:
 
-    H5UnsignedCharData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const hsize_t _arank, const hsize_t * _adims, unsigned char * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _arank, _adims, _data, _stride, _offset, _dataOwner)
+    H5UnsignedCharData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, unsigned char * _data, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData<unsigned char>(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner)
     {
 
     }
@@ -35,20 +35,7 @@ public:
 
     virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const
     {
-        if (adims)
-        {
-            os << "[ ";
-            const hsize_t _pos = pos * dataSize;
-            for (unsigned int i = 0; i < atotalSize - 1; i++)
-            {
-                os << (int)static_cast<unsigned char *>(getData())[_pos + i] << ", ";
-            }
-            os << (int)static_cast<unsigned char *>(getData())[_pos + atotalSize - 1] << " ]";
-        }
-        else
-        {
-            os << (int)static_cast<unsigned char *>(getData())[pos];
-        }
+        os << (int)static_cast<unsigned char *>(getData())[pos];
     }
 };
 }
diff --git a/scilab/modules/hdf5/src/cpp/H5VlenData.cpp b/scilab/modules/hdf5/src/cpp/H5VlenData.cpp
new file mode 100644 (file)
index 0000000..ad97470
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * 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 "H5VlenData.hxx"
+#include "H5DataFactory.hxx"
+
+namespace org_modules_hdf5
+{
+
+H5VlenData::H5VlenData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, hid_t vlenType, const hsize_t _stride, const size_t _offset, const bool _dataOwner) : H5BasicData<char>(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner), cumprod(H5Object::getCumProd(_ndims, dims))
+{
+    type = H5Tget_super(vlenType);
+    baseSize = H5Tget_size(type);
+    if (H5Tget_class(type) == H5T_STRING && !H5Tis_variable_str(type))
+    {
+        // We have a C-string so it is null terminated
+        baseSize++;
+    }
+}
+
+H5VlenData::~H5VlenData()
+{
+    delete[] cumprod;
+    H5Tclose(type);
+}
+
+bool H5VlenData::isVlen() const
+{
+    return true;
+}
+
+H5Object & H5VlenData::getData(const unsigned int size, const unsigned int * index) const
+{
+    unsigned int pos = 0;
+    hsize_t * _dims;
+    hvl_t * x = 0;
+
+    for (unsigned int i = 0; i < size; i++)
+    {
+        pos += cumprod[i] * index[i];
+    }
+
+    if (pos >= totalSize)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Invalid index."));
+    }
+
+    x = reinterpret_cast<hvl_t *>(static_cast<char *>(data) + offset + pos * (stride ? stride : dataSize));
+    _dims = new hsize_t[1];
+    *_dims = (hsize_t)x->len;
+
+    return H5DataFactory::getObjectData(*const_cast<H5VlenData *>(this), *_dims, baseSize, type, 1, _dims, x->p, 0, 0, false);
+}
+
+std::string H5VlenData::toString(const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    std::string indentString = H5Object::getIndentString(indentLevel + 1);
+
+    os << H5Object::getIndentString(indentLevel) << "HDF5 Variable length data" << std::endl
+       << indentString << _("Dimensions") << ": [";
+
+    if (ndims == 0)
+    {
+        os << "1 x 1]";
+    }
+    else if (ndims == 1)
+    {
+        os << "1 x " << dims[0] << "]";
+    }
+    else
+    {
+        for (unsigned int i = 0; i < ndims - 1; i++)
+        {
+            os << dims[i] << " x ";
+        }
+        os << dims[ndims - 1] << "]" << std::endl;
+    }
+
+    return os.str();
+}
+
+std::string H5VlenData::dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+{
+    return H5DataConverter::dump(alreadyVisited, indentLevel, ndims, dims, *this, false);
+}
+
+void H5VlenData::printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const
+{
+    hvl_t * x = reinterpret_cast<hvl_t *>(static_cast<char *>(data) + offset + pos * (stride ? stride : dataSize));
+
+    if (!x || !x->p)
+    {
+        os << "()";
+        return;
+    }
+
+    hsize_t * _dims = new hsize_t[1];
+
+    *_dims = (hsize_t)x->len;
+    H5Data & hdata = H5DataFactory::getObjectData(*const_cast<H5VlenData *>(this), *_dims, baseSize, type, 1, _dims, x->p, 0, 0, false);
+
+    os << "(";
+    for (unsigned int i = 0; i < *_dims - 1; i++)
+    {
+        hdata.printData(os, i, indentLevel + 1);
+        os << ", ";
+    }
+    hdata.printData(os, *_dims - 1, indentLevel + 1);
+    os << ")";
+
+    delete &hdata;
+}
+
+void H5VlenData::toScilab(void * pvApiCtx, const int lhsPosition, int * parentList, const int listPosition) const
+{
+    H5Object::toScilab(pvApiCtx, lhsPosition, parentList, listPosition);
+}
+}
index 8f3b47d..073a4cb 100644 (file)
 #ifndef __H5VLENDATA_HXX__
 #define __H5VLENDATA_HXX__
 
-#include "H5Data.hxx"
+#include "H5BasicData.hxx"
 
 namespace org_modules_hdf5
 {
 
-template <typename T>
-class H5VlenData : public H5Data
+class H5VlenData : public H5BasicData<char>
 {
 
+    const hsize_t * cumprod;
+    hid_t type;
+    hsize_t baseSize;
+
 public:
 
-    H5VlenData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, hvl_t * _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)
-    {
+    H5VlenData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, hid_t vlenType, const hsize_t stride, const size_t offset, const bool _dataOwner);
 
-    }
+    virtual ~H5VlenData();
 
-    virtual ~H5VlenData()
-    {
-        for (unsigned int i = 0; i < totalSize; i++)
-        {
-            free(data[i].p);
-        }
-    }
+    virtual H5Object & getData(const unsigned int size, const unsigned int * index) const;
 
-    virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const
-    {
-        const hvl_t & x = *static_cast<hvl_t *>(getData())[pos];
-
-        os << "(";
-        for (unsigned int i = 0; i < x.len - 1; i++)
-        {
-            os << static_cast<T *>(x.p)[i] << ", ";
-        }
-        os << static_cast<T *>(x.p)[x.len - 1] << ")";
-    }
+    virtual bool isVlen() const;
 
-    virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const
-    {
-        SciErr err;
-        unsigned char * newData = 0;
-
-        if (ndims == 0)
-        {
-            alloc(pvApiCtx, lhsPosition, 1, dataSize, parentList, listPosition, &newData);
-            copyData(newData);
-        }
-        else if (ndims == 1)
-        {
-            alloc(pvApiCtx, lhsPosition, *dims, dataSize, parentList, listPosition, &newData);
-            copyData(newData);
-        }
-        else
-        {
-            int * list = getHypermatrix(pvApiCtx, lhsPosition, parentList, listPosition);
-            hsize_t * _dims = new hsize_t[ndims + 1];
-            memcpy(_dims, dims, ndims * sizeof(hsize_t));
-            _dims[ndims] = (hsize_t)dataSize;
-
-            try
-            {
-                alloc(pvApiCtx, lhsPosition, 1, totalSize * dataSize, list, 3, &newData);
-                H5DataConverter::C2FHypermatrix(ndims + 1, _dims, totalSize * dataSize, static_cast<unsigned char *>(getData()), newData);
-            }
-            catch (const H5Exception & e)
-            {
-                delete[] _dims;
-                throw;
-            }
-
-            delete[] _dims;
-        }
-    }
+    virtual std::string toString(const unsigned int indentLevel) const;
 
-    class VlenInfo
-    {
-        const hid_t space;
-        const hid_t type;
-        const bool isString;
-
-    public:
-        VlenInfo(const hid_t _space, const hid_t _type, const bool _isString) : space(_space), type(_type), isString(_isString) { }
-
-        virtual ~VlenInfo()
-        {
-            if (space)
-            {
-                H5Sclose(space);
-            }
-            if (type)
-            {
-                H5Tclose(type);
-            }
-        }
-
-        hid_t getSpace() const
-        {
-            return space;
-        }
-        hid_t getType() const
-        {
-            return type;
-        }
-        bool isString() const
-        {
-            return isString;
-        }
-    };
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const;
+
+    virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const;
 
+    virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const;
+
+    virtual bool mustDelete() const
+    {
+        return false;
+    }
 };
 }
 
index 1b35cc4..d33b5d2 100644 (file)
@@ -198,7 +198,7 @@ void HDF5Scilab::readData(H5Object & obj, const std::string & name, const unsign
                 throw;
             }
 
-            if (!data->isReference())
+            if (data->mustDelete())
             {
                 delete data;
             }
@@ -762,6 +762,12 @@ bool HDF5Scilab::checkType(const H5Object & obj, const H5ObjectType type)
             return obj.isReference();
         case H5LIST:
             return obj.isList();
+        case H5COMPOUND:
+            return obj.isCompound();
+        case H5ARRAY:
+            return obj.isArray();
+        case H5VLEN:
+            return obj.isVlen();
         default:
             return false;
     }
index 33d89b3..9972468 100644 (file)
@@ -50,7 +50,10 @@ public:
         H5SPACE,
         H5TYPE,
         H5REFERENCE,
-        H5LIST
+        H5LIST,
+        H5COMPOUND,
+        H5ARRAY,
+        H5VLEN
     };
 
     static int getH5ObjectId(int * mlist, void * pvApiCtx);