Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add signatures for H5PT, H5LT #128

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions HDF.PInvoke.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@
<Compile Include="HDF5\Constants.cs" />
<Compile Include="HDF5\H5ACpublic.cs" />
<Compile Include="HDF5\H5Eglobals.cs" />
<Compile Include="HDF5\H5LTpublic.cs" />
<Compile Include="HDF5\H5Pglobals.cs" />
<Compile Include="HDF5\H5PTpublic.cs" />
<Compile Include="HDF5\H5Rpublic.cs" />
<Compile Include="HDF5\H5PLpublic.cs" />
<Compile Include="HDF5\H5Dpublic.cs" />
Expand Down
2 changes: 1 addition & 1 deletion HDF5/H5Dpublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public enum chunk_index_t
#if HDF5_VER1_10
/// <summary>
/// Single Chunk index (cur dims[]=max dims[]=chunk dims[];
/// filtered & non-filtered)
/// filtered &amp; non-filtered)
/// </summary>
SINGLE = 1,
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion HDF5/H5Fpublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public struct sohm_t
/// </summary>
public hsize_t hdr_size;
/// <summary>
/// Shared object header message index & heap size
/// Shared object header message index &amp; heap size
/// </summary>
public H5.ih_info_t msgs_info;
}
Expand Down
938 changes: 938 additions & 0 deletions HDF5/H5LTpublic.cs

Large diffs are not rendered by default.

258 changes: 258 additions & 0 deletions HDF5/H5PTpublic.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from [email protected]. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Security;

using herr_t = System.Int32;
using hsize_t = System.UInt64;
using size_t = System.IntPtr;
using uint32_t = System.UInt32;

#if HDF5_VER1_10
using hid_t = System.Int64;
#else
using hid_t = System.Int32;
#endif

namespace HDF.PInvoke
{
/// <summary>
/// H5PT: HDF5 Packet Table.
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public static class H5PT
{
static H5PT()
{
H5.open();
}

/// <summary>
/// Creates a packet table to store fixed-length or variable-length packets.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTcreate
/// </summary>
/// <param name="loc_id">Identifier of the file or group to create the table within.</param>
/// <param name="table_name">The name of the packet table to create.</param>
/// <param name="dtype_id">The datatype of the packet.</param>
/// <param name="chunk_size">
/// Chunk size, in number of table entries per chunk.
/// Packet table datasets use HDF5 chunked storage to allow them to grow.
/// This value allows the user to set the size of a chunk. The chunk size affects performance.
/// </param>
/// <param name="plist_id">Identifier of the property list. Can be used to specify the compression of the packet table.</param>
/// <returns>Returns an identifier for the new packet table or <see cref="H5I.H5I_INVALID_HID"/> on error.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTcreate",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern hid_t create (hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string table_name, hid_t dtype_id, hsize_t chunk_size, hid_t plist_id);

/// <summary>
/// Creates a packet table to store fixed-length packets.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTcreate_fl
/// </summary>
/// <param name="loc_id">Identifier of the file or group to create the table within.</param>
/// <param name="table_name">The name of the packet table to create.</param>
/// <param name="dtype_id">The datatype of the packet.</param>
/// <param name="chunk_size">
/// Chunk size, in number of table entries per chunk.
/// Packet table datasets use HDF5 chunked storage to allow them to grow.
/// This value allows the user to set the size of a chunk. The chunk size affects performance.
/// </param>
/// <param name="compression">
/// Compression level, a value of 0 through 9. Level 0 is faster but offers the least compression;
/// level 9 is slower but offers maximum compression.
/// A setting of -1 indicates that no compression is desired.
/// </param>
/// <returns>Returns an identifier for the new packet table or <see cref="H5I.H5I_INVALID_HID"/> on error.</returns>
[Obsolete("Call H5PT.create() instead.")]
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTcreate_fl",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern hid_t create_fl(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string table_name, hid_t dtype_id, hsize_t chunk_size, int compression);

/// <summary>
/// Opens an existing packet table.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTopen
/// </summary>
/// <param name="loc_id">Identifier of the file or group within which the packet table can be found.</param>
/// <param name="dset_name">The name of the packet table to open.</param>
/// <returns>Returns an identifier for the packet table, or <see cref="H5I.H5I_INVALID_HID"/> on error.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTopen",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern hid_t open(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name);

/// <summary>
/// Closes an open packet table.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTclose
/// </summary>
/// <param name="table_id">Identifier of packet table to be closed.</param>
/// <returns>Returns a non-negative value if successful, otherwise returns a negative value.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTclose",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t close(hid_t table_id);

/// <summary>
/// Appends packets to the end of a packet table.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTappend
/// </summary>
/// <param name="table_id">Identifier of packet table to which packets should be appended.</param>
/// <param name="nrecords">Number of packets to be appended.</param>
/// <param name="data">Buffer holding data to write.</param>
/// <returns>Returns an identifier for the packet table, or <see cref="H5I.H5I_INVALID_HID"/> on error.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTappend",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t append(hid_t table_id, size_t nrecords, IntPtr data);

/// <summary>
/// Resets a packet table's index to the first packet.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTcreate_index
/// </summary>
/// <param name="table_id">Identifier of packet table whose index should be initialized.</param>
/// <returns>Returns a non-negative value if successful, otherwise returns a negative value.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTcreate_index",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t create_index(hid_t table_id);

/// <summary>
/// Sets a packet table's index.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTset_index
/// </summary>
/// <param name="table_id">Identifier of packet table whose index is to be set.</param>
/// <param name="index">The packet to which the index should point.</param>
/// <returns>Returns a non-negative value if successful, otherwise returns a negative value.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTset_index",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t set_index(hid_t table_id, hsize_t index);

/// <summary>
/// Reads a number of packets from a packet table.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTread_packets
/// </summary>
/// <param name="table_id">Identifier of packet table to read from.</param>
/// <param name="start">Packet to start reading from.</param>
/// <param name="nrecords">Number of packets to be read.</param>
/// <param name="data">Buffer into which to read data.</param>
/// <returns>Returns a non-negative value if successful, otherwise returns a negative value.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTread_packets",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t read_packets(hid_t table_id, hsize_t start, size_t nrecords, IntPtr data);

/// <summary>
/// Reads packets from a packet table starting at the current index.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTget_next
/// </summary>
/// <param name="table_id">Identifier of packet table to read from.</param>
/// <param name="nrecords">Number of packets to be read.</param>
/// <param name="data">Buffer into which to read data.</param>
/// <returns>Returns a non-negative value if successful, otherwise returns a negative value.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTget_next",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t get_next(hid_t table_id, size_t nrecords, IntPtr data);

/// <summary>
/// Returns the backend dataset of this packet table.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTget_dataset
/// </summary>
/// <param name="table_id">Identifier of the packet table.</param>
/// <returns>Returns a dataset identifier or <see cref="H5I.H5I_INVALID_HID"/> on error.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTget_dataset",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern hid_t get_dataset(hid_t table_id);

/// <summary>
/// Returns the backend datatype of this packet table.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTget_type
/// </summary>
/// <param name="table_id">Identifier of the packet table.</param>
/// <returns>Returns a datatype identifier or <see cref="H5I.H5I_INVALID_HID"/> on error.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTget_type",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern hid_t get_type(hid_t table_id);

/// <summary>
/// Returns the number of packets in a packet table.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTget_num_packets
/// </summary>
/// <param name="table_id">Identifier of packet table to query.</param>
/// <param name="nrecords">Number of packets in packet table.</param>
/// <returns>Returns a non-negative value if successful, otherwise returns a negative value.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTget_num_packets",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t get_num_packets(hid_t table_id, out hsize_t nrecords);

/// <summary>
/// Determines whether an identifier points to a packet table.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTis_valid
/// </summary>
/// <param name="table_id">Identifier to query.</param>
/// <returns>Returns a non-negative value if <paramref name="table_id"/> is a valid packet table, otherwise returns a negative value.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTis_valid",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t is_valid(hid_t table_id);

/// <summary>
/// Determines whether a packet table contains variable-length or fixed-length packets.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTis_varlen
/// </summary>
/// <param name="table_id">Packet table to query.</param>
/// <returns>Returns 1 for a variable-length packet table, 0 for fixed-length, or a negative value on error.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTis_varlen",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t is_varlen(hid_t table_id);

/// <summary>
/// Releases memory allocated in the process of reading variable-length packets.
/// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTfree_vlen_buff
/// </summary>
/// <param name="table_id">Packet table whose memory should be freed.</param>
/// <param name="bufflen">Size of <paramref name="buff"/>.</param>
/// <param name="buff">Buffer that was used to read in variable-length packets.</param>
/// <returns>Returns a non-negative value if successful, otherwise returns a negative value.</returns>
[DllImport(Constants.HLDLLFileName,
EntryPoint = "H5PTfree_vlen_buff",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t free_vlen_buff(hid_t table_id, hsize_t bufflen, IntPtr buff);
}
}
39 changes: 39 additions & 0 deletions UnitTests/H5LTTest/H5LTTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from [email protected]. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

using System;
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HDF.PInvoke;

using herr_t = System.Int32;

#if HDF5_VER1_10
using hid_t = System.Int64;
#else
using hid_t = System.Int32;
#endif

namespace UnitTests
{
[TestClass]
public partial class H5LTTest
{
//
}
}
39 changes: 39 additions & 0 deletions UnitTests/H5PTTest/H5PTTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from [email protected]. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

using System;
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HDF.PInvoke;

using herr_t = System.Int32;

#if HDF5_VER1_10
using hid_t = System.Int64;
#else
using hid_t = System.Int32;
#endif

namespace UnitTests
{
[TestClass]
public partial class H5PTTest
{
//
}
}
2 changes: 2 additions & 0 deletions UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
<Compile Include="H5LTest\H5Lcreate_external.cs" />
<Compile Include="H5LTest\H5Lcopy.cs" />
<Compile Include="H5LTest\H5LTest.cs" />
<Compile Include="H5LTTest\H5LTTest.cs" />
<Compile Include="H5OTest\H5Ovisit_by_name.cs" />
<Compile Include="H5OTest\H5Ovisit.cs" />
<Compile Include="H5OTest\H5Olink.cs" />
Expand All @@ -212,6 +213,7 @@
<Compile Include="H5PTest\H5Pset_mdc_image_config.cs" />
<Compile Include="H5PTest\H5Pset_userblock.cs" />
<Compile Include="H5PTest\H5PTest.cs" />
<Compile Include="H5PTTest\H5PTTest.cs" />
<Compile Include="H5RTest\H5Rget_obj_type.cs" />
<Compile Include="H5RTest\H5Rdereference.cs" />
<Compile Include="H5RTest\H5Rget_region.cs" />
Expand Down