HL-HDF
hlhdf.c File Reference

Common functions for working with an HDF5 file through the HL-HDF API. More...

#include "hlhdf.h"
#include "hlhdf_private.h"
#include "hlhdf_debug.h"
#include "hlhdf_alloc.h"
#include "hlhdf_defines_private.h"
#include <string.h>
#include <stdlib.h>

Functions

void HL_disableErrorReporting (void)
 Disables error reporting.
 
void HL_enableErrorReporting (void)
 Enables error reporting.
 
int HL_isErrorReportingEnabled (void)
 Returns if error reporting is enabled or not.
 
void HL_init (void)
 Initializes the HLHDF handler functions.
 
void HL_setDebugMode (int flag)
 Toggles the debug mode for HLHDF.
 
int HL_isHDF5File (const char *filename)
 Verifies if the provided filename is a valid HDF5 file or not.
 
HL_FileCreationPropertyHLFileCreationProperty_new (void)
 Creates a file property instance that can be passed on to createHlHdfFile when creating a HDF5 file.
 
void HLFileCreationProperty_free (HL_FileCreationProperty *prop)
 Deallocates the HL_FileCreationProperty instance.
 
int HL_sizeOfFormat (const char *format)
 Calculates the size in bytes of the provided format specifiers.
 
int HL_isFormatSupported (const char *format)
 Verifies if the format name is supported by HLHDF.
 
HL_FormatSpecifier HL_getFormatSpecifier (const char *format)
 Returns the format specifier for the provided format string.
 
const char * HL_getFormatSpecifierString (HL_FormatSpecifier specifier)
 Returns the string representation of the provided specifier.
 
const char * HL_getHDF5Version (void)
 Returns the version that was used for building this binary.
 
HL_CompressionHLCompression_new (HL_CompressionType aType)
 Creates an allocated and initialized instance of HL_Compression.
 
HL_CompressionHLCompression_clone (HL_Compression *inv)
 Creates a copy of the provided HL_Compression instance.
 
void HLCompression_init (HL_Compression *inv, HL_CompressionType aType)
 Initializes a HL_Compressiosn instance.
 
void HLCompression_free (HL_Compression *inv)
 Deallocates the HL_Compression instance.
 
hid_t openHlHdfFile (const char *filename, const char *how)
 Opens a HDF5 file by specifying the file and an option mode.
 
hid_t createHlHdfFile (const char *filename, HL_FileCreationProperty *property)
 Creates a HDF5 file.
 
hid_t getFixedType (hid_t type)
 Translates a HDF5 type identifier into a native type identifier.
 
hid_t HL_translateFormatSpecifierToType (HL_FormatSpecifier specifier)
 
hid_t HL_translateFormatStringToDatatype (const char *dataType)
 Returns a native data type from the format specifier.
 
char * getTypeNameString (hid_t type)
 Returns the type as represented by HDF5.
 
HL_FormatSpecifier HL_getFormatSpecifierFromType (hid_t type)
 Returns the format specifier for the provided type identifier.
 
const char * getFormatNameString (hid_t type)
 Returns the format specifier as defined by HLHDF.
 
char * getStringPadName (hid_t type)
 Returns the String Pad name as represented by HDF5.
 
char * getStringCsetName (hid_t type)
 Returns the CSET name as represented in HDF5.
 
char * getStringCtypeName (hid_t type)
 Returns the CTYPE name as represented in HDF5.
 
int extractParentChildName (HL_Node *node, char **parent, char **child)
 Extracts the parent and child name from the node name.
 
int openGroupOrDataset (hid_t file_id, const char *name, hid_t *lid, HL_Type *type)
 Opens a group or dataset hid and returns the type as well.
 

Detailed Description

Common functions for working with an HDF5 file through the HL-HDF API.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2009-06-15

Function Documentation

◆ createHlHdfFile()

hid_t createHlHdfFile ( const char * filename,
HL_FileCreationProperty * property )

Creates a HDF5 file.

If the filename already exists this file will be truncated.

Parameters
[in]filenamethe name of the file to create
[in]propertyThe properties for trimming the filesize and structure. (May be NULL)
Returns
the file identifier or -1 on failure.

◆ extractParentChildName()

int extractParentChildName ( HL_Node * node,
char ** parent,
char ** child )

Extracts the parent and child name from the node name.

Example: '/group1/group2/group3' will be splitted into '/group1/group2' and 'group3'.

Parameters
[in]nodethe node containing the name that should be splitted
[out]parentthe parent path
[out]childthis nodes name.
Returns
1 on success, otherwise 0.

◆ getFixedType()

hid_t getFixedType ( hid_t type)

Translates a HDF5 type identifier into a native type identifier.

This identifier is used within the HLHDF library.

Parameters
[in]typethe type that should be translated
Returns
a reference to the native type identifier, <0 on failure. Remember to call H5Tclose on the returned type.

◆ getFormatNameString()

const char * getFormatNameString ( hid_t type)

Returns the format specifier as defined by HLHDF.

Parameters
[in]typethe type identifier, must be a native type.
Returns
the format specifier string or NULL on failure. See here for valid values.

◆ getStringCsetName()

char * getStringCsetName ( hid_t type)

Returns the CSET name as represented in HDF5.

Parameters
[in]typethe type identifier
Returns
the CSET name as represented in HDF5.

◆ getStringCtypeName()

char * getStringCtypeName ( hid_t type)

Returns the CTYPE name as represented in HDF5.

Parameters
[in]typethe type identifier
Returns
the CTYPE name as represented in HDF5.

◆ getStringPadName()

char * getStringPadName ( hid_t type)

Returns the String Pad name as represented by HDF5.

Parameters
[in]typethe type identifier
Returns
the String Pad name as defined in HDF5.

◆ getTypeNameString()

char * getTypeNameString ( hid_t type)

Returns the type as represented by HDF5.

For example 'H5T_STD_I8BE'.

Parameters
[in]typethe type identifier
Returns
an allocated string with the name or NULL upon failure.

◆ HL_getFormatSpecifier()

HL_FormatSpecifier HL_getFormatSpecifier ( const char * format)

Returns the format specifier for the provided format string.

Parameters
[in]formatthe format name
Returns
the format specifier. HLHDF_UNDEFINED is also returned on error

◆ HL_getFormatSpecifierFromType()

HL_FormatSpecifier HL_getFormatSpecifierFromType ( hid_t type)

Returns the format specifier for the provided type identifier.

Parameters
[in]typethe type identifier, must be a native type.
Returns
the format specifier or HLHDF_UNDEFINED on error.

◆ HL_getFormatSpecifierString()

const char * HL_getFormatSpecifierString ( HL_FormatSpecifier specifier)

Returns the string representation of the provided specifier.

Parameters
[in]specifier- the specifier
Returns
NULL if not a valid specifier, otherwise the format.

◆ HL_getHDF5Version()

const char * HL_getHDF5Version ( void )

Returns the version that was used for building this binary.

Returns
the version string.

◆ HL_translateFormatStringToDatatype()

hid_t HL_translateFormatStringToDatatype ( const char * dataType)

Returns a native data type from the format specifier.

Parameters
[in]dataTypeFormat specifier. See here for valid format specifiers.
Returns
the reference to the type or <0 on failure.

◆ openGroupOrDataset()

int openGroupOrDataset ( hid_t file_id,
const char * name,
hid_t * lid,
HL_Type * type )

Opens a group or dataset hid and returns the type as well.

Parameters
[in]file_id- the file pointer
[in]name- the node name to open
[out]lid- the opened hid
[out]type- the type of the opened hid
Returns
0 on failure, otherwise 1

◆ openHlHdfFile()

hid_t openHlHdfFile ( const char * filename,
const char * how )

Opens a HDF5 file by specifying the file and an option mode.

Parameters
[in]filenamethe filename
[in]howhow the file should be opened, 'r', 'w' or 'rw'
Returns
the file identifier or -1 on failure.