GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmHdf5Utils.h File Reference

Declaration of the GmHdf5Utils namespace (contains previous static routines from the GmHdf5 class later renamed to GmXdmfHdf5) More...

#include "gmCoreConfig.h"
#include <QString>
#include <QVariant>
#include <QVector>
#include <H5Opublic.h>
Include dependency graph for gmHdf5Utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void GmHdf5Utils::addAttribute (H5::H5Object *obj, const QString &name, int value)
 Adds an int attribute to the given object. Might throw an HDF5 exception.
 
void GmHdf5Utils::addAttribute (H5::H5Object *obj, const QString &name, unsigned value)
 Adds an unsigned int attribute to the given object. Might throw an HDF5 exception.
 
void GmHdf5Utils::addAttribute (H5::H5Object *obj, const QString &name, double value)
 Adds a double attribute to the given object. Might throw an HDF5 exception.
 
void GmHdf5Utils::addAttribute (H5::H5Object *obj, const QString &name, bool value)
 Adds a boolean attribute to the given object. Might throw an HDF5 exception.
 
void GmHdf5Utils::addAttribute (H5::H5Object *obj, const QString &name, const char *value)
 Adds a string attribute to the given object. Might throw an HDF5 exception.
 
void GmHdf5Utils::addAttribute (H5::H5Object *obj, const QString &name, const QString &value)
 Adds a string attribute to the given object. Might throw an HDF5 exception.
 
void GmHdf5Utils::addAttribute (H5::H5Object *obj, const QString &name, const QStringList &value)
 Adds the given string list as a vector attribute. Might throw an HDF5 exception.
 
void GmHdf5Utils::addAttribute (H5::H5Object *obj, const QString &name, unsigned n, const int *values)
 Adds an int vector attribute to the given object. Might throw an HDF5 exception.
 
void GmHdf5Utils::addAttribute (H5::H5Object *obj, const QString &name, unsigned n, const unsigned *values)
 Adds an unsigned vector attribute to the given object. Might throw an HDF5 exception.
 
void GmHdf5Utils::addAttribute (H5::H5Object *obj, const QString &name, unsigned n, const double *values)
 Adds a double vector attribute to the given object. Might throw an HDF5 exception.
 
bool GmHdf5Utils::saveStringTable (H5::H5File *file, const QString &dsName, const QStringList &values)
 Saves the complete set of given values to a new table with one string column. Returns false on error (exceptions treated internally).
 
bool GmHdf5Utils::saveDataTable (H5::H5File *file, const QString &dsName, int n, int d, const double *values)
 Saves the complete set of given values to a new table with d columns and n lines. Expects the data vector to be linearized by line. Returns false on error (exceptions treated internally).
 
bool GmHdf5Utils::saveDataTable (H5::H5File *file, const QString &dsName, int n, int d, const int *values)
 Saves the complete set of given values to a new table with d columns and n lines. Expects the data vector to be linearized by line. Returns false on error (exceptions treated internally).
 
QVariant GmHdf5Utils::loadAttribute (H5::H5Object *obj, const QString &name)
 Returns the value of the given object attribute as a Variant object. Returns an invalid variant if the attribute was not found. Might throw an HDF5 exception.
 
QVariant GmHdf5Utils::loadAttribute (H5::H5Object *obj, const QString &name, const H5::DataType &type)
 Returns the value of the given object attribute as a Variant object. Returns an invalid variant if the attribute was not found or if the attribute type is different from type. Might throw an HDF5 exception.
 
H5O_type_t GmHdf5Utils::childObjectType (H5::H5Object *father, const QString &childName)
 Returns the type of the given object (name relative to the given father). If the named child doesn't exists, returns H5O_TYPE_UNKNOWN. Also returns H5O_TYPE_UNKNOWN on Hdf5 exceptions.
 
bool GmHdf5Utils::tableSize (H5::H5Object *father, const QString &childName, hsize_t sizes[2])
 Returns the dimensions of the given table object (name relative to the given father). If the named child doesn't exists or is not a simple "2D" table (rank different from 1 or 2), returns false. Sizes is filled with the number of rows and columns of the table. A rank 1 table is considered to have just 1 column.
 
bool GmHdf5Utils::checkTableLayout (H5::H5Object *father, const QString &childName, int ncol, const H5::DataType &type, int *nlines, int *ncolumns)
 Returns true if the table specified by a father object and its child path exists, has the given number of columns ('ncol') and the given data type. Otherwise returns false.
 
QVector< QPair< QString, H5O_type_t > > GmHdf5Utils::listObjectChildren (H5::H5Object *object)
 Returns a list of object's children, together with their types. Might throw an HDF5 exception.
 
bool GmHdf5Utils::loadStringTable (H5::H5File *file, const QString &dsName, QStringList &values)
 Loads the contents of the given string table to the values list. Returns false on error. Exceptions are treated internally.
 
bool GmHdf5Utils::loadDataTable (H5::H5File *file, const QString &dsName, int valuesSize, double *values, int offset)
 Loads the specified number of values from the specified table, starting at the given offset. Expects that the table has at least the given valuesSize entries after the offset and that the values vector is sized accordingly. For multi dimension data, it is read "by lines". Returns false on error (exceptions treated internally).
 
bool GmHdf5Utils::loadDataTable (H5::H5File *file, const QString &dsName, int valuesSize, int *values, int offset)
 Loads the specified number of values from the specified table, starting at the given offset. Expects that the table has at least the given valuesSize entries after the offset and that the values vector is sized accordingly. For multi dimension data, it is read "by lines". Returns false on error (exceptions treated internally).
 
bool GmHdf5Utils::loadDataTable (H5::H5File *file, const QString &dsName, QVector< double > &values)
 Loads the full contents from the specified table into the given vector, resized to fit the table size. Returns false on error (exceptions treated internally).
 
bool GmHdf5Utils::loadDataTable (H5::H5File *file, const QString &dsName, QVector< int > &values)
 Loads the full contents from the specified table into the given vector, resized to fit the table size. Returns false on error (exceptions treated internally).
 

Detailed Description

Declaration of the GmHdf5Utils namespace (contains previous static routines from the GmHdf5 class later renamed to GmXdmfHdf5)

Author
Carlos Augusto Teixeira Mendes
Date
may, 2022

Function Documentation

◆ checkTableLayout()

GMC_API_EXPORT bool GmHdf5Utils::checkTableLayout ( H5::H5Object * father,
const QString & childName,
int ncol,
const H5::DataType & type,
int * nlines,
int * ncolumns )

Returns true if the table specified by a father object and its child path exists, has the given number of columns ('ncol') and the given data type. Otherwise returns false.

If nlines is not NULL, it will be filled with the number of table lines if the table exists. Otherwise it will be filled with -1. Keep in mind that if the table exists but does not match the given layout (columns & type) the number of lines will still be filled. Exceptions are treated internally.

if ncol is 0, any number of columns will be accepted and, if ncolumns is not NULL, it will be filled with the real number of mesh columns.

◆ loadStringTable()

GMC_API_EXPORT bool GmHdf5Utils::loadStringTable ( H5::H5File * file,
const QString & dsName,
QStringList & values )

Loads the contents of the given string table to the values list. Returns false on error. Exceptions are treated internally.

Expects the table to hava a single column with string data.