Skip to content

Commit

Permalink
Merge pull request #72 from RBelokurov/master
Browse files Browse the repository at this point in the history
Some overloads for issue 63. Overloads makes ambiguities which had to…
  • Loading branch information
gheber committed Jul 21, 2016
2 parents acd10c6 + fe5645f commit b4d327a
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 5 deletions.
21 changes: 21 additions & 0 deletions HDF5/H5Apublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,27 @@ public extern static ssize_t get_name_by_idx
(hid_t loc_id, string obj_name,
H5.index_t idx_type, H5.iter_order_t order, hsize_t n,
StringBuilder name, size_t size, hid_t lapl_id = H5P.DEFAULT);


/// <summary>
/// Gets an attribute name, by attribute index position.
/// See https://www.hdfgroup.org/HDF5/doc/RM/RM_H5A.html#Annot-GetNameByIdx
/// </summary>
/// <param name="loc_id">Location of object to which attribute is
/// attached</param>
/// <param name="obj_name">Name of object to which attribute is
/// attached, relative to location</param>
/// <param name="idx_type">Type of index</param>
/// <param name="order">Index traversal order</param>
/// <param name="n">Attribute’s position in index</param>
/// <param name="name">Attribute name</param>
/// <param name="size">Size, in bytes, of attribute name</param>
/// <param name="lapl_id">Link access property list</param>
/// <returns>Returns attribute name size, in bytes, if successful;
/// otherwise returns a negative value.</returns>
/// <remarks>ASCII strings ONLY!</remarks>
[DllImport(Constants.DLLFileName, EntryPoint = "H5Aget_name_by_idx", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public extern static ssize_t get_name_by_idx(hid_t loc_id, string obj_name, H5.index_t idx_type, H5.iter_order_t order, hsize_t n, IntPtr name, size_t size, hid_t lapl_id);

/// <summary>
/// Gets a copy of the dataspace for an attribute.
Expand Down
14 changes: 14 additions & 0 deletions HDF5/H5Dpublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,20 @@ public static extern herr_t scatter
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t set_extent(hid_t dset_id, hsize_t[] size);

/// <summary>
/// Changes the sizes of a dataset’s dimensions.
/// See https://www.hdfgroup.org/HDF5/doc/RM/RM_H5D.html#Dataset-SetExtent
/// </summary>
/// <param name="dset_id">Dataset identifier</param>
/// <param name="size">Array containing the new magnitude of each
/// dimension of the dataset.</param>
/// <returns>Returns a non-negative value if successful; otherwise
/// returns a negative value.</returns>
[DllImport(Constants.DLLFileName, EntryPoint = "H5Dset_extent",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t set_extent(hid_t dset_id, hsize_t* size);

/// <summary>
/// Determines the number of bytes required to store variable-length
/// (VL) data.
Expand Down
23 changes: 23 additions & 0 deletions HDF5/H5Lpublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,29 @@ public extern static ssize_t get_name_by_idx
H5.iter_order_t order, hsize_t n, [Out] StringBuilder name, size_t size,
hid_t lapl_id = H5P.DEFAULT);

/// <summary>
/// Retrieves name of the nth link in a group, according to the order
/// within a specified field or index.
/// See https://www.hdfgroup.org/HDF5/doc/RM/RM_H5L.html#Link-GetNameByIdx
/// </summary>
/// <param name="loc_id">File or group identifier specifying location
/// of subject group</param>
/// <param name="group_name">Name of subject group</param>
/// <param name="idx_type">Index or field which determines the order</param>
/// <param name="order">Order within field or index</param>
/// <param name="n">Link for which to retrieve information</param>
/// <param name="name">Buffer in which link value is returned</param>
/// <param name="size">Size in bytes of <paramref name="name"/></param>
/// <param name="lapl_id">Link access property list</param>
/// <returns>Returns the size of the link name if successful; otherwise
/// returns a negative value.</returns>
/// <remarks>ASCII strings ONLY!</remarks>
[DllImport(Constants.DLLFileName, EntryPoint = "H5Lget_name_by_idx",
CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Ansi),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public extern static ssize_t get_name_by_idx(hid_t loc_id, string group_name, H5.index_t idx_type, H5.iter_order_t order, hsize_t n, IntPtr name /*out*/, size_t size, hid_t lapl_id);

/// <summary>
/// Returns the value of a symbolic link.
/// See https://www.hdfgroup.org/HDF5/doc/RM/RM_H5L.html#Link-GetVal
Expand Down
41 changes: 41 additions & 0 deletions HDF5/H5Ppublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,32 @@ public static extern H5Z.filter_t get_filter
[Out] uint[] cd_values, size_t namelen, [Out] byte[] name,
ref uint filter_config);


/// <summary>
/// Returns information about a filter in a pipeline.
/// See https://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetFilter2
/// </summary>
/// <param name="plist_id">Dataset or group creation property list
/// identifier.</param>
/// <param name="idx">Sequence number within the filter pipeline of the
/// filter for which information is sought.</param>
/// <param name="flags">Bit vector specifying certain general
/// properties of the filter.</param>
/// <param name="cd_nelmts">Number of elements in
/// <paramref name="cd_values"/>.</param>
/// <param name="cd_values">Auxiliary data for the filter.</param>
/// <param name="namelen">Anticipated number of characters in
/// <paramref name="name"/>.</param>
/// <param name="name">Name of the filter.</param>
/// <param name="filter_config">Bit field.</param>
/// <returns>Returns the filter identifier if successful. Otherwise
/// returns a negative value.</returns>
[DllImport(Constants.DLLFileName, EntryPoint = "H5Pget_filter2",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern H5Z.filter_t get_filter2(hid_t plist_id, uint filter, ref uint flags, ref hsize_t cd_nelmts, uint* cd_values, size_t namelen, string name, ref uint filter_config);


/// <summary>
/// Returns information about the specified filter.
/// See https://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetFilterById2
Expand Down Expand Up @@ -2064,6 +2090,21 @@ public static extern herr_t set_chunk
(hid_t plist_id, int ndims,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]hsize_t[] dims);

/// <summary>
/// Sets the size of the chunks used to store a chunked layout dataset.
/// See https://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetChunk
/// </summary>
/// <param name="plist_id">Dataset creation property list identifier.</param>
/// <param name="ndims">The number of dimensions of each chunk.</param>
/// <param name="dims">An array defining the size, in dataset elements,
/// of each chunk.</param>
/// <returns>Returns a non-negative value if successful; otherwise
/// returns a negative value.</returns>
[DllImport(Constants.DLLFileName, EntryPoint = "H5Pset_chunk",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t set_chunk(hid_t plist_id, int ndims, hsize_t* dims);

#if HDF5_VER1_10

/// <summary>
Expand Down
50 changes: 50 additions & 0 deletions HDF5/H5Spublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,21 @@ public static extern hid_t create_simple
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)]hsize_t[] dims,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)]hsize_t[] maxdims);

/// <summary>
/// Creates a new simple dataspace and opens it for access.
/// See https://www.hdfgroup.org/HDF5/doc/RM/RM_H5S.html#Dataspace-CreateSimple
/// </summary>
/// <param name="rank">Number of dimensions of dataspace.</param>
/// <param name="dims">Array specifying the size of each dimension.</param>
/// <param name="maxdims">Array specifying the maximum size of each
/// dimension.</param>
/// <returns>Returns a dataspace identifier if successful; otherwise
/// returns a negative value.</returns>
[DllImport(Constants.DLLFileName, EntryPoint = "H5Screate_simple",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern hid_t create_simple(int rank, hsize_t* dims, hsize_t* maxdims);

/// <summary>
/// Decode a binary object description of data space and return a new
/// object handle.
Expand Down Expand Up @@ -431,6 +446,24 @@ public static extern int get_simple_extent_dims
[MarshalAs(UnmanagedType.LPArray)]hsize_t[] dims,
[MarshalAs(UnmanagedType.LPArray)]hsize_t[] maxdims);


/// <summary>
/// Retrieves dataspace dimension size and maximum size.
/// See https://www.hdfgroup.org/HDF5/doc/RM/RM_H5S.html#Dataspace-ExtentDims
/// </summary>
/// <param name="space_id">Identifier of the dataspace object to query</param>
/// <param name="dims">Pointer to array to store the size of each dimension.</param>
/// <param name="maxdims">Pointer to array to store the maximum size of each dimension.</param>
/// <returns>Returns the number of dimensions in the dataspace if
/// successful; otherwise returns a negative value.</returns>
/// <remarks>Either or both of <paramref name="dims"/> and
/// <paramref name="maxdims"/> may be <code>NULL</code>.</remarks>
[DllImport(Constants.DLLFileName,
EntryPoint = "H5Sget_simple_extent_dims",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern int get_simple_extent_dims (hid_t space_id, hsize_t* dims, hsize_t* maxdims);

/// <summary>
/// Determines the dimensionality of a dataspace.
/// See https://www.hdfgroup.org/HDF5/doc/RM/RM_H5S.html#Dataspace-ExtentNdims
Expand Down Expand Up @@ -576,6 +609,23 @@ public static extern herr_t select_hyperslab
[MarshalAs(UnmanagedType.LPArray)] hsize_t[] count,
[MarshalAs(UnmanagedType.LPArray)] hsize_t[] block);

/// <summary>
/// Selects a hyperslab region to add to the current selected region.
/// See https://www.hdfgroup.org/HDF5/doc/RM/RM_H5S.html#Dataspace-SelectHyperslab
/// </summary>
/// <param name="space_id">Identifier of dataspace selection to modify</param>
/// <param name="op">Operation to perform on current selection.</param>
/// <param name="start">Offset of start of hyperslab</param>
/// <param name="stride">Number of blocks included in hyperslab.</param>
/// <param name="count">Hyperslab stride.</param>
/// <param name="block">Size of block in hyperslab.</param>
/// <returns>Returns a non-negative value if successful; otherwise
/// returns a negative value.</returns>
[DllImport(Constants.DLLFileName, EntryPoint = "H5Sselect_hyperslab",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t select_hyperslab(hid_t space_id, seloper_t op, hsize_t* start, hsize_t* stride, hsize_t* count, hsize_t* block);

/// <summary>
/// Resets the selection region to include no elements.
/// See https://www.hdfgroup.org/HDF5/doc/RM/RM_H5S.html#Dataspace-SelectNone
Expand Down
4 changes: 2 additions & 2 deletions UnitTests/H5DTest/H5Dset_extent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ public void H5Dset_extentTest2()
hid_t dset = H5D.create_anon(m_v0_test_file, H5T.IEEE_F32BE,
space, dcpl);
Assert.IsTrue(dset >= 0);
Assert.IsFalse(H5D.set_extent(dset, null) >= 0);
Assert.IsFalse(H5D.set_extent(dset, (ulong[])null) >= 0);
Assert.IsTrue(H5D.close(dset) >= 0);

dset = H5D.create_anon(m_v2_test_file, H5T.IEEE_F32BE,
space, dcpl);
Assert.IsTrue(dset >= 0);
Assert.IsFalse(H5D.set_extent(dset, null) >= 0);
Assert.IsFalse(H5D.set_extent(dset, (ulong[])null) >= 0);
Assert.IsTrue(H5D.close(dset) >= 0);

Assert.IsTrue(H5P.close(dcpl) >= 0);
Expand Down
4 changes: 2 additions & 2 deletions UnitTests/H5STest/H5Sget_simple_extent_dims.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void H5Sget_simple_extent_dimsTest1()

space = H5S.create_simple(dims.Length, dims, dims);
Assert.IsTrue(
H5S.get_simple_extent_dims(space, null, null) == 3);
H5S.get_simple_extent_dims(space, (ulong[])null, null) == 3);

Assert.IsTrue(
H5S.get_simple_extent_dims(space, dims_out, null) == 3);
Expand All @@ -66,7 +66,7 @@ public void H5Sget_simple_extent_dimsTest2()

space = H5S.create_simple(dims.Length, dims, max_dims);
Assert.IsTrue(
H5S.get_simple_extent_dims(space, null, null) == 3);
H5S.get_simple_extent_dims(space, (ulong[])null, null) == 3);

Assert.IsTrue(
H5S.get_simple_extent_dims(space, dims_out, null) == 3);
Expand Down
2 changes: 1 addition & 1 deletion UnitTests/H5STest/H5Sselect_hyperslab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void H5Sselect_hyperslabTest2()
{
Assert.IsFalse(
H5S.select_hyperslab(Utilities.RandomInvalidHandle(),
H5S.seloper_t.SET, null, null, null, null) >= 0);
H5S.seloper_t.SET, (ulong[])null, null, null, null) >= 0);
}
}
}

0 comments on commit b4d327a

Please sign in to comment.