ddn.data.hdf5.utils

HDF5 Wrapper Utilities

This module provides utility functions for the HDF5 D wrapper library, including string conversions, ID validation, and scope guards.

License

BSD-3-Clause

Types 1

structScopeGuard(alias fn)

RAII scope guard for HDF5 resources.

This struct provides automatic cleanup of HDF5 resources when the scope is exited, similar to D's scope(exit).

Example:

auto guard = scopeGuard(() => H5Fclose(fileId));
// ... use fileId ...
// H5Fclose is automatically called when guard goes out of scope

Fields
private bool _dismissed
Methods
void dismiss() @safe nothrow @nogcPrevents the cleanup function from being called
Destructors

Functions 9

fnconst(char) * toStringz(string s) @trusted pure nothrow @nogcConverts a D string to a null-terminated C string.
fnstring fromStringz(const(char) * cstr) @trusted pure nothrowConverts a null-terminated C string to a D string.
fnstring fromStringzN(const(char) * cstr, size_t maxLen) @trusted pure nothrowConverts a null-terminated C string to a D string with known maximum length.
fnhid_t validateId(hid_t id, string objectType = "object")Validates an HDF5 ID and throws an exception if invalid.
fnvoid validateIds(hid_t[] ids, string objectType = "object")Validates multiple HDF5 IDs and throws an exception if any is invalid.
fnauto scopeGuard(alias fn)()Creates a scope guard that calls the given delegate on scope exit.
fnvoid closeId(alias closeFunc)(hid_t * id)Generic ID closer for use with scope guards.
fnherr_t safeCall(herr_t operation, lazy string errorMsg)Safely executes an HDF5 operation and handles errors.
fnhid_t safeCallId(hid_t operation, lazy string errorMsg)Safely executes an HDF5 operation that returns an ID.