From 6a1a032a86e9af6ff88931628c720cc06c78d1f3 Mon Sep 17 00:00:00 2001 From: Jack Pappas Date: Thu, 31 Aug 2017 20:01:35 -0400 Subject: [PATCH 1/4] Small documentation fix (XML entities). --- HDF5/H5Dpublic.cs | 2 +- HDF5/H5Fpublic.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HDF5/H5Dpublic.cs b/HDF5/H5Dpublic.cs index 030229a..6614a71 100644 --- a/HDF5/H5Dpublic.cs +++ b/HDF5/H5Dpublic.cs @@ -84,7 +84,7 @@ public enum chunk_index_t #if HDF5_VER1_10 /// /// Single Chunk index (cur dims[]=max dims[]=chunk dims[]; - /// filtered & non-filtered) + /// filtered & non-filtered) /// SINGLE = 1, /// diff --git a/HDF5/H5Fpublic.cs b/HDF5/H5Fpublic.cs index f26fa60..4fc1542 100644 --- a/HDF5/H5Fpublic.cs +++ b/HDF5/H5Fpublic.cs @@ -226,7 +226,7 @@ public struct sohm_t /// public hsize_t hdr_size; /// - /// Shared object header message index & heap size + /// Shared object header message index & heap size /// public H5.ih_info_t msgs_info; } From 7fd77276b1e3ecd03496de59c88b826f52b286ce Mon Sep 17 00:00:00 2001 From: Jack Pappas Date: Thu, 31 Aug 2017 20:04:49 -0400 Subject: [PATCH 2/4] Add H5PT class/signatures and partial work on H5LT class/signatures. --- HDF.PInvoke.csproj | 2 + HDF5/H5LTpublic.cs | 103 +++++++++++++++ HDF5/H5PTpublic.cs | 233 +++++++++++++++++++++++++++++++++ UnitTests/H5LTTest/H5LTTest.cs | 39 ++++++ UnitTests/H5PTTest/H5PTTest.cs | 39 ++++++ UnitTests/UnitTests.csproj | 1 + 6 files changed, 417 insertions(+) create mode 100644 HDF5/H5LTpublic.cs create mode 100644 HDF5/H5PTpublic.cs create mode 100644 UnitTests/H5LTTest/H5LTTest.cs create mode 100644 UnitTests/H5PTTest/H5PTTest.cs diff --git a/HDF.PInvoke.csproj b/HDF.PInvoke.csproj index 77a8e50..9a757fd 100644 --- a/HDF.PInvoke.csproj +++ b/HDF.PInvoke.csproj @@ -74,7 +74,9 @@ + + diff --git a/HDF5/H5LTpublic.cs b/HDF5/H5LTpublic.cs new file mode 100644 index 0000000..c59271f --- /dev/null +++ b/HDF5/H5LTpublic.cs @@ -0,0 +1,103 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +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 hbool_t = System.UInt32; +using htri_t = System.Int32; + +using ssize_t = System.IntPtr; + +#if HDF5_VER1_10 +using hid_t = System.Int64; +#else +using hid_t = System.Int32; +#endif + +namespace HDF.PInvoke +{ + /// + /// H5LT: HDF5 Lite. + /// + [SuppressMessage("ReSharper", "InconsistentNaming")] + [SuppressUnmanagedCodeSecurity] + public static class H5LT + { + static H5LT() + { + H5.open(); + } + + /// + /// Determines whether an HDF5 path is valid and, optionally, whether the path resolves to an HDF5 object. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTpath_valid + /// + /// An identifier of an object in the file. + /// The path to the object to check. Links in may be of any type. + /// If TRUE, determine whether the final component of path resolves to an object; if FALSE, do not check. + /// + /// Upon success: + /// If is set to FALSE + /// Returns TRUE if the path is valid; otherwise returns FALSE. + /// If is set to TRUE + /// Returns TRUE if the path is valid and resolves to an HDF5 object; otherwise returns FALSE. + /// Upon error, returns a negative value. + /// + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTpath_valid", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern htri_t path_valid(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string path, hbool_t check_object_valid); + + /// + /// Opens an HDF5 file image in memory. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTopen_file_image + /// + /// A pointer to the supplied initial image. + /// Size of the supplied buffer. + /// Flags specifying whether to open the image read-only or read/write, whether HDF5 is to take control of the buffer, and instruction regarding releasing the buffer. + /// Returns a file identifier if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTopen_file_image", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern hid_t open_file_image(IntPtr buf_ptr, size_t buf_size, uint flags); + + /// + /// Creates and writes a dataset of a type . + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTmake_dataset + /// + /// Identifier of the file or group to create the dataset within. + /// The name of the dataset to create. + /// Number of dimensions of dataspace. + /// An array of the size of each dimension. + /// Identifier of the datatype to use when creating the dataset. + /// Buffer with data to be written to the dataset. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTmake_dataset", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t make_dataset(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, int rank, [MarshalAs(UnmanagedType.LPArray)] hsize_t[] dims, hid_t type_id, IntPtr buffer); + + + } +} diff --git a/HDF5/H5PTpublic.cs b/HDF5/H5PTpublic.cs new file mode 100644 index 0000000..80eb731 --- /dev/null +++ b/HDF5/H5PTpublic.cs @@ -0,0 +1,233 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +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 +{ + /// + /// H5PT: HDF5 Packet Table. + /// + [SuppressMessage("ReSharper", "InconsistentNaming")] + public static class H5PT + { + static H5PT() + { + H5.open(); + } + + /// + /// Creates a packet table to store fixed-length or variable-length packets. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTcreate + /// + /// Identifier of the file or group to create the table within. + /// The name of the packet table to create. + /// The datatype of the packet. + /// + /// 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. + /// + /// Identifier of the property list. Can be used to specify the compression of the packet table. + /// Returns an identifier for the new packet table or on error. + [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); + + /// + /// Opens an existing packet table. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTopen + /// + /// Identifier of the file or group within which the packet table can be found. + /// The name of the packet table to open. + /// Returns an identifier for the packet table, or on error. + [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); + + /// + /// Closes an open packet table. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTclose + /// + /// Identifier of packet table to be closed. + /// Returns a non-negative value if successful, otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5PTclose", + CallingConvention = CallingConvention.Cdecl), + SuppressUnmanagedCodeSecurity, SecuritySafeCritical] + public static extern herr_t close(hid_t table_id); + + /// + /// Appends packets to the end of a packet table. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTappend + /// + /// Identifier of packet table to which packets should be appended. + /// Number of packets to be appended. + /// Buffer holding data to write. + /// Returns an identifier for the packet table, or on error. + [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); + + /// + /// Resets a packet table's index to the first packet. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTcreate_index + /// + /// Identifier of packet table whose index should be initialized. + /// Returns a non-negative value if successful, otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5PTcreate_index", + CallingConvention = CallingConvention.Cdecl), + SuppressUnmanagedCodeSecurity, SecuritySafeCritical] + public static extern herr_t create_index(hid_t table_id); + + /// + /// Sets a packet table's index. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTset_index + /// + /// Identifier of packet table whose index is to be set. + /// The packet to which the index should point. + /// Returns a non-negative value if successful, otherwise returns a negative value. + [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); + + /// + /// Reads a number of packets from a packet table. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTread_packets + /// + /// Identifier of packet table to read from. + /// Packet to start reading from. + /// Number of packets to be read. + /// Buffer into which to read data. + /// Returns a non-negative value if successful, otherwise returns a negative value. + [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); + + /// + /// Reads packets from a packet table starting at the current index. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTget_next + /// + /// Identifier of packet table to read from. + /// Number of packets to be read. + /// Buffer into which to read data. + /// Returns a non-negative value if successful, otherwise returns a negative value. + [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); + + /// + /// Returns the backend dataset of this packet table. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTget_dataset + /// + /// Identifier of the packet table. + /// Returns a dataset identifier or on error. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5PTget_dataset", + CallingConvention = CallingConvention.Cdecl), + SuppressUnmanagedCodeSecurity, SecuritySafeCritical] + public static extern hid_t get_dataset(hid_t table_id); + + /// + /// Returns the backend datatype of this packet table. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTget_type + /// + /// Identifier of the packet table. + /// Returns a datatype identifier or on error. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5PTget_type", + CallingConvention = CallingConvention.Cdecl), + SuppressUnmanagedCodeSecurity, SecuritySafeCritical] + public static extern hid_t get_type(hid_t table_id); + + /// + /// Returns the number of packets in a packet table. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTget_num_packets + /// + /// Identifier of packet table to query. + /// Number of packets in packet table. + /// Returns a non-negative value if successful, otherwise returns a negative value. + [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); + + /// + /// Determines whether an identifier points to a packet table. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTis_valid + /// + /// Identifier to query. + /// Returns a non-negative value if is a valid packet table, otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5PTis_valid", + CallingConvention = CallingConvention.Cdecl), + SuppressUnmanagedCodeSecurity, SecuritySafeCritical] + public static extern herr_t is_valid(hid_t table_id); + + /// + /// 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 + /// + /// Packet table to query. + /// Returns 1 for a variable-length packet table, 0 for fixed-length, or a negative value on error. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5PTis_varlen", + CallingConvention = CallingConvention.Cdecl), + SuppressUnmanagedCodeSecurity, SecuritySafeCritical] + public static extern herr_t is_varlen(hid_t table_id); + + /// + /// 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 + /// + /// Packet table whose memory should be freed. + /// Size of . + /// Buffer that was used to read in variable-length packets. + /// Returns a non-negative value if successful, otherwise returns a negative value. + [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); + } +} diff --git a/UnitTests/H5LTTest/H5LTTest.cs b/UnitTests/H5LTTest/H5LTTest.cs new file mode 100644 index 0000000..278c61d --- /dev/null +++ b/UnitTests/H5LTTest/H5LTTest.cs @@ -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 help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +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 + { + // + } +} \ No newline at end of file diff --git a/UnitTests/H5PTTest/H5PTTest.cs b/UnitTests/H5PTTest/H5PTTest.cs new file mode 100644 index 0000000..a7bea82 --- /dev/null +++ b/UnitTests/H5PTTest/H5PTTest.cs @@ -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 help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +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 + { + // + } +} \ No newline at end of file diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index e32865c..3988b48 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -212,6 +212,7 @@ + From e261efc8f6e16df1813da94d53519449538f9b55 Mon Sep 17 00:00:00 2001 From: Jack Pappas Date: Sat, 2 Sep 2017 14:25:53 -0400 Subject: [PATCH 3/4] Added more H5LT signatures. --- HDF5/H5LTpublic.cs | 280 +++++++++++++++++++++++++++++++++++++++++++++ HDF5/H5PTpublic.cs | 29 ++++- 2 files changed, 307 insertions(+), 2 deletions(-) diff --git a/HDF5/H5LTpublic.cs b/HDF5/H5LTpublic.cs index c59271f..bed596a 100644 --- a/HDF5/H5LTpublic.cs +++ b/HDF5/H5LTpublic.cs @@ -98,6 +98,286 @@ static H5LT() SecuritySafeCritical] public static extern herr_t make_dataset(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, int rank, [MarshalAs(UnmanagedType.LPArray)] hsize_t[] dims, hid_t type_id, IntPtr buffer); + /// + /// Creates and writes a dataset of type 'character' (). + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTmake_dataset_char + /// + /// Identifier of the file or group to create the dataset within. + /// The name of the dataset to create. + /// Number of dimensions of dataspace. + /// An array of the size of each dimension. + /// Buffer with data to be written to the dataset. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTmake_dataset_char", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t make_dataset_char(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, int rank, [MarshalAs(UnmanagedType.LPArray)] hsize_t[] dims, IntPtr buffer); + + /// + /// Creates and writes a dataset of type 'short signed integer' (). + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTmake_dataset_short + /// + /// Identifier of the file or group to create the dataset within. + /// The name of the dataset to create. + /// Number of dimensions of dataspace. + /// An array of the size of each dimension. + /// Buffer with data to be written to the dataset. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTmake_dataset_short", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t make_dataset_short(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, int rank, [MarshalAs(UnmanagedType.LPArray)] hsize_t[] dims, IntPtr buffer); + + /// + /// Creates and writes a dataset of type 'native signed integer' (). + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTmake_dataset_int + /// + /// Identifier of the file or group to create the dataset within. + /// The name of the dataset to create. + /// Number of dimensions of dataspace. + /// An array of the size of each dimension. + /// Buffer with data to be written to the dataset. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTmake_dataset_int", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t make_dataset_int(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, int rank, [MarshalAs(UnmanagedType.LPArray)] hsize_t[] dims, IntPtr buffer); + + /// + /// Creates and writes a dataset of type 'long signed integer' (). + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTmake_dataset_long + /// + /// Identifier of the file or group to create the dataset within. + /// The name of the dataset to create. + /// Number of dimensions of dataspace. + /// An array of the size of each dimension. + /// Buffer with data to be written to the dataset. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTmake_dataset_long", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t make_dataset_long(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, int rank, [MarshalAs(UnmanagedType.LPArray)] hsize_t[] dims, IntPtr buffer); + /// + /// Creates and writes a dataset of type 'native floating point' (). + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTmake_dataset_float + /// + /// Identifier of the file or group to create the dataset within. + /// The name of the dataset to create. + /// Number of dimensions of dataspace. + /// An array of the size of each dimension. + /// Buffer with data to be written to the dataset. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTmake_dataset_float", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t make_dataset_float(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, int rank, [MarshalAs(UnmanagedType.LPArray)] hsize_t[] dims, IntPtr buffer); + + /// + /// Creates and writes a dataset of type 'native floating-point double' (). + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTmake_dataset_double + /// + /// Identifier of the file or group to create the dataset within. + /// The name of the dataset to create. + /// Number of dimensions of dataspace. + /// An array of the size of each dimension. + /// Buffer with data to be written to the dataset. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTmake_dataset_double", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t make_dataset_double(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, int rank, [MarshalAs(UnmanagedType.LPArray)] hsize_t[] dims, IntPtr buffer); + + /// + /// Creates and writes a dataset of type 'C string' (). + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTmake_dataset_string + /// + /// Identifier of the file or group to create the dataset within. + /// The name of the dataset to create. + /// Buffer with data to be written to the dataset. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTmake_dataset_string", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t make_dataset_string(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, IntPtr buffer); + + /// + /// Reads a dataset from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTread_dataset + /// + /// Identifier of the file or group to read the dataset within. + /// The name of the dataset to read. + /// Identifier of the datatype to use when reading the dataset. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTread_dataset", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t read_dataset(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, hid_t type_id, IntPtr buffer); + + /// + /// Reads a dataset of type 'character' () from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTread_dataset_char + /// + /// Identifier of the file or group to read the dataset within. + /// The name of the dataset to read. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTread_dataset_char", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t read_dataset_char(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, IntPtr buffer); + + /// + /// Reads a dataset of type 'short signed integer' () from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTread_dataset_short + /// + /// Identifier of the file or group to read the dataset within. + /// The name of the dataset to read. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTread_dataset_short", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t read_dataset_short(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, IntPtr buffer); + + /// + /// Reads a dataset of type 'native signed integer' () from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTread_dataset_int + /// + /// Identifier of the file or group to read the dataset within. + /// The name of the dataset to read. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTread_dataset_int", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t read_dataset_int(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, IntPtr buffer); + + /// + /// Reads a dataset of type 'long signed integer' () from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTread_dataset_long + /// + /// Identifier of the file or group to read the dataset within. + /// The name of the dataset to read. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTread_dataset_long", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t read_dataset_long(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, IntPtr buffer); + + /// + /// Reads a dataset of type 'native floating point' () from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTread_dataset_float + /// + /// Identifier of the file or group to read the dataset within. + /// The name of the dataset to read. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTread_dataset_float", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t read_dataset_float(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, IntPtr buffer); + + /// + /// Reads a dataset of type 'native floating point double' () from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTread_dataset_double + /// + /// Identifier of the file or group to read the dataset within. + /// The name of the dataset to read. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTread_dataset_double", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t read_dataset_double(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, IntPtr buffer); + + /// + /// Reads a dataset of type 'C string' () from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTread_dataset_string + /// + /// Identifier of the file or group to read the dataset within. + /// The name of the dataset to read. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTread_dataset_string", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t read_dataset_string(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, IntPtr buffer); + + /// + /// Determines whether a dataset exists. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTfind_dataset + /// + /// Identifier of the group containing the dataset. + /// Dataset name. + /// Returns 1 if the dataset exists, returns 0 otherwise. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTfind_dataset", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t find_dataset(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name); + + /// + /// Gets the dimensionality of a dataset. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_dataset_ndims + /// + /// Identifier of the object to locate the dataset within. + /// Dataset name. + /// The dimensionality of the dataset. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_dataset_ndims", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_dataset_ndims(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, out int rank); + + /// + /// Gets information about a dataset. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_dataset_info + /// + /// Identifier of the object to locate the dataset within. + /// Dataset name. + /// The dimensions of the dataset. + /// The class identifier. + /// The size of the datatype in bytes. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_dataset_info", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_dataset_info(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string dset_name, IntPtr /* hsize_t* */ dims, out H5T.class_t class_id, out size_t type_size); + + /// + /// Creates and writes a string attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTset_attribute_string + /// + /// Identifier of the object (dataset or group) to create the attribute within. + /// The name of the object to attach the attribute. + /// The attribute name. + /// Buffer with data to be written to the attribute. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTset_attribute_string", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t set_attribute_string(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, [MarshalAs(UnmanagedType.LPStr)] string attr_data); } } diff --git a/HDF5/H5PTpublic.cs b/HDF5/H5PTpublic.cs index 80eb731..d3c79b8 100644 --- a/HDF5/H5PTpublic.cs +++ b/HDF5/H5PTpublic.cs @@ -62,13 +62,38 @@ static H5PT() 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); + /// + /// Creates a packet table to store fixed-length packets. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTcreate_fl + /// + /// Identifier of the file or group to create the table within. + /// The name of the packet table to create. + /// The datatype of the packet. + /// + /// 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. + /// + /// + /// 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. + /// + /// Returns an identifier for the new packet table or on error. + [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); + /// /// Opens an existing packet table. /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTopen /// /// Identifier of the file or group within which the packet table can be found. /// The name of the packet table to open. - /// Returns an identifier for the packet table, or on error. + /// Returns an identifier for the packet table, or on error. [DllImport(Constants.HLDLLFileName, EntryPoint = "H5PTopen", CallingConvention = CallingConvention.Cdecl), @@ -94,7 +119,7 @@ static H5PT() /// Identifier of packet table to which packets should be appended. /// Number of packets to be appended. /// Buffer holding data to write. - /// Returns an identifier for the packet table, or on error. + /// Returns an identifier for the packet table, or on error. [DllImport(Constants.HLDLLFileName, EntryPoint = "H5PTappend", CallingConvention = CallingConvention.Cdecl), From 66f16515919cfd791abdb641c9897fbfabd08737 Mon Sep 17 00:00:00 2001 From: Jack Pappas Date: Sat, 9 Sep 2017 18:19:34 -0400 Subject: [PATCH 4/4] Finished signatures for H5LT API. --- HDF5/H5LTpublic.cs | 557 ++++++++++++++++++++++++++++++++++++- UnitTests/UnitTests.csproj | 1 + 2 files changed, 557 insertions(+), 1 deletion(-) diff --git a/HDF5/H5LTpublic.cs b/HDF5/H5LTpublic.cs index bed596a..8d1155d 100644 --- a/HDF5/H5LTpublic.cs +++ b/HDF5/H5LTpublic.cs @@ -17,7 +17,7 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using System.Security; - +using System.Text; using herr_t = System.Int32; using hsize_t = System.UInt64; using size_t = System.IntPtr; @@ -46,6 +46,57 @@ static H5LT() H5.open(); } + #region Flag definitions for H5LTopen_file_image() + + /// + /// Open image for read-write. + /// + public const uint H5LT_FILE_IMAGE_OPEN_RW = 0x0001u; + + /// + /// The HDF5 lib won't copy user supplied image buffer. + /// The same image is open with the core driver. + /// + public const uint H5LT_FILE_IMAGE_DONT_COPY = 0x0002u; + + /// + /// The HDF5 lib won't deallocate user supplied image buffer. + /// The user application is reponsible for doing so. + /// + public const uint H5LT_FILE_IMAGE_DONT_RELEASE = 0x0004u; + + public const uint H5LT_FILE_IMAGE_ALL = 0x0007u; + + #endregion + + public enum lang_t + { + /// + /// this is the first + /// + LANG_ERR = -1, + + /// + /// DDL (Data Definition Language). + /// + DDL = 0, + + /// + /// C language. + /// + C = 1, + + /// + /// FORTRAN language. + /// + FORTRAN = 2, + + /// + /// this is the last + /// + NO_LANG = 3 + } + /// /// Determines whether an HDF5 path is valid and, optionally, whether the path resolves to an HDF5 object. /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTpath_valid @@ -379,5 +430,509 @@ static H5LT() SecuritySafeCritical] public static extern herr_t set_attribute_string(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, [MarshalAs(UnmanagedType.LPStr)] string attr_name, [MarshalAs(UnmanagedType.LPStr)] string attr_data); + + /// + /// Creates and writes an attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTset_attribute_char + /// + /// Identifier of the object (dataset or group) to create the attribute within. + /// The name of the object to attach the attribute. + /// The attribute name. + /// Buffer with data to be written to the attribute. + /// + /// The size of the 1D array (one in the case of a scalar attribute). + /// This value is used by H5Screate_simple to create the dataspace. + /// + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTset_attribute_char", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t set_attribute_char(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* sbyte* */ buffer, hsize_t size); + + /// + /// Creates and writes an attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTset_attribute_uchar + /// + /// Identifier of the object (dataset or group) to create the attribute within. + /// The name of the object to attach the attribute. + /// The attribute name. + /// Buffer with data to be written to the attribute. + /// + /// The size of the 1D array (one in the case of a scalar attribute). + /// This value is used by H5Screate_simple to create the dataspace. + /// + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTset_attribute_uchar", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t set_attribute_uchar(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* byte* */ buffer, hsize_t size); + + /// + /// Creates and writes an attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTset_attribute_short + /// + /// Identifier of the object (dataset or group) to create the attribute within. + /// The name of the object to attach the attribute. + /// The attribute name. + /// Buffer with data to be written to the attribute. + /// + /// The size of the 1D array (one in the case of a scalar attribute). + /// This value is used by H5Screate_simple to create the dataspace. + /// + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTset_attribute_short", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t set_attribute_short(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* short* */ buffer, hsize_t size); + + /// + /// Creates and writes an attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTset_attribute_ushort + /// + /// Identifier of the object (dataset or group) to create the attribute within. + /// The name of the object to attach the attribute. + /// The attribute name. + /// Buffer with data to be written to the attribute. + /// + /// The size of the 1D array (one in the case of a scalar attribute). + /// This value is used by H5Screate_simple to create the dataspace. + /// + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTset_attribute_ushort", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t set_attribute_ushort(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* ushort* */ buffer, hsize_t size); + + /// + /// Creates and writes an attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTset_attribute_int + /// + /// Identifier of the object (dataset or group) to create the attribute within. + /// The name of the object to attach the attribute. + /// The attribute name. + /// Buffer with data to be written to the attribute. + /// + /// The size of the 1D array (one in the case of a scalar attribute). + /// This value is used by H5Screate_simple to create the dataspace. + /// + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTset_attribute_int", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t set_attribute_int(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* int* */ buffer, hsize_t size); + + /// + /// Creates and writes an attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTset_attribute_uint + /// + /// Identifier of the object (dataset or group) to create the attribute within. + /// The name of the object to attach the attribute. + /// The attribute name. + /// Buffer with data to be written to the attribute. + /// + /// The size of the 1D array (one in the case of a scalar attribute). + /// This value is used by H5Screate_simple to create the dataspace. + /// + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTset_attribute_uint", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t set_attribute_uint(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* uint* */ buffer, hsize_t size); + + /// + /// Creates and writes an attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTset_attribute_long + /// + /// Identifier of the object (dataset or group) to create the attribute within. + /// The name of the object to attach the attribute. + /// The attribute name. + /// Buffer with data to be written to the attribute. + /// + /// The size of the 1D array (one in the case of a scalar attribute). + /// This value is used by H5Screate_simple to create the dataspace. + /// + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTset_attribute_long", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t set_attribute_long(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* long* */ buffer, hsize_t size); + + /// + /// Creates and writes an attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTset_attribute_ulong + /// + /// Identifier of the object (dataset or group) to create the attribute within. + /// The name of the object to attach the attribute. + /// The attribute name. + /// Buffer with data to be written to the attribute. + /// + /// The size of the 1D array (one in the case of a scalar attribute). + /// This value is used by H5Screate_simple to create the dataspace. + /// + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTset_attribute_ulong", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t set_attribute_ulong(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* ulong* */ buffer, hsize_t size); + + /// + /// Creates and writes an attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTset_attribute_long_long + /// + /// Identifier of the object (dataset or group) to create the attribute within. + /// The name of the object to attach the attribute. + /// The attribute name. + /// Buffer with data to be written to the attribute. + /// + /// The size of the 1D array (one in the case of a scalar attribute). + /// This value is used by H5Screate_simple to create the dataspace. + /// + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTset_attribute_long_long", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t set_attribute_long_long(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* long* */ buffer, hsize_t size); + + /// + /// Creates and writes an attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTset_attribute_float + /// + /// Identifier of the object (dataset or group) to create the attribute within. + /// The name of the object to attach the attribute. + /// The attribute name. + /// Buffer with data to be written to the attribute. + /// + /// The size of the 1D array (one in the case of a scalar attribute). + /// This value is used by H5Screate_simple to create the dataspace. + /// + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTset_attribute_float", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t set_attribute_float(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* float* */ buffer, hsize_t size); + + /// + /// Creates and writes an attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTset_attribute_double + /// + /// Identifier of the object (dataset or group) to create the attribute within. + /// The name of the object to attach the attribute. + /// The attribute name. + /// Buffer with data to be written to the attribute. + /// + /// The size of the 1D array (one in the case of a scalar attribute). + /// This value is used by H5Screate_simple to create the dataspace. + /// + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTset_attribute_double", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t set_attribute_double(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* float* */ buffer, hsize_t size); + + /// + /// Reads an attribute from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// Identifier of the memory datatype. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, hid_t mem_type_id, IntPtr /* void* */ data); + + /// + /// Reads an attribute from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_string + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_string", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_string(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* sbyte* */ data); + + /// + /// Reads an attribute from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_char + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_char", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_char(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* sbyte* */ data); + + /// + /// Reads an attribute from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_uchar + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_uchar", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_uchar(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* byte* */ data); + + /// + /// Reads an attribute from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_short + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_short", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_short(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* short* */ data); + + /// + /// Reads an attribute from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_ushort + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_ushort", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_ushort(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* ushort* */ data); + + /// + /// Reads an attribute from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_int + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_int", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_int(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* int* */ data); + + /// + /// Reads an attribute from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_uint + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_uint", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_uint(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* uint* */ data); + + /// + /// Reads an attribute from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_long + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_long", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_long(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* long* */ data); + + /// + /// Reads an attribute from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_long_long + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_long_long", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_long_long(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* long* */ data); + + /// + /// Reads an attribute from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_ulong + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_ulong", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_ulong(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* ulong* */ data); + + /// + /// Reads an attribute from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_float + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_float", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_float(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* float* */ data); + + /// + /// Reads an attribute from disk. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_double + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// Buffer with data. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_double", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_double(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* double* */ data); + + /// + /// Determines whether an attribute exists. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTfind_attribute + /// + /// Identifier of the object to which the attribute is expected to be attached. + /// The attribute name. + /// Returns 1 if the attribute exists; returns 0 otherwise. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTfind_attribute", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t find_attribute(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string attr_name); + + /// + /// Gets the dimensionality of an attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_ndims + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// The dimensionality of the attribute. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_ndims", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_ndims(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, out int rank); + + /// + /// Gets the dimensionality of an attribute. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTget_attribute_info + /// + /// Identifier of the object (dataset or group) to read the attribute from. + /// The name of the object that the attribute is attached to. + /// The attribute name. + /// The dimensions of the attribute. + /// The class identifier. To a list of the HDF5 class types please refer to the Datatype Interface API (H5T) help. + /// The size of the datatype in bytes. + /// Returns a non-negative value if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTget_attribute_info", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t get_attribute_info(hid_t loc_id, [MarshalAs(UnmanagedType.LPStr)] string obj_name, + [MarshalAs(UnmanagedType.LPStr)] string attr_name, IntPtr /* hsize_t* */ dims, out H5T.class_t type_class, out size_t type_size); + + /// + /// Creates an HDF5 datatype given a text description. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTtext_to_dtype + /// + /// A character string containing a DDL definition of the datatype to be created. + /// The language used to describe the datatype. The only currently supported language is . + /// Returns the datatype identifier(non-negative) if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTtext_to_dtype", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern hid_t text_to_dtype([MarshalAs(UnmanagedType.LPStr)] string text, lang_t lang_type); + + /// + /// Creates a text description of an HDF5 datatype. + /// See https://support.hdfgroup.org/HDF5/doc/HL/RM_H5LT.html#H5LTdtype_to_text + /// + /// Identifier of the datatype to be converted. + /// Buffer for the text description of the datatype. + /// The language used to describe the datatype. The currently supported language is . + /// The size of buffer needed to store the text description. + /// Returns non-negative if successful; otherwise returns a negative value. + [DllImport(Constants.HLDLLFileName, + EntryPoint = "H5LTdtype_to_text", + CallingConvention = CallingConvention.Cdecl), + SecuritySafeCritical] + public static extern herr_t dtype_to_text(hid_t datatype, [MarshalAs(UnmanagedType.LPStr)] StringBuilder str, lang_t lang_type, out size_t len); } } diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index 3988b48..55c34e7 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -189,6 +189,7 @@ +