Mantid
Loading...
Searching...
No Matches
Namespaces | Macros | Functions
H5Util.cpp File Reference
#include "MantidNexus/H5Util.h"
#include "MantidNexus/UniqueID.h"
#include <Poco/Logger.h>
#include <H5Cpp.h>
#include <algorithm>
#include <array>
#include <boost/numeric/conversion/cast.hpp>
#include <sstream>
#include <stdexcept>
#include <string>

Go to the source code of this file.

Namespaces

namespace  Mantid
 Helper class which provides the Collimation Length for SANS instruments.
 
namespace  Mantid::Nexus
 Header for a base Nexus::Exception.
 
namespace  Mantid::Nexus::H5Util
 Operations for help with narrowing casts.
 

Macros

#define RUN_H5UTIL_FUNCTION(dataType, func_name, ...)
 This macro matches the dataType in terms of PredType, with the actual primitive datatype.
 

Functions

MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::copyGroup (H5::H5Object &dest, const std::string &destGroupAddress, H5::H5Object &src, const std::string &srcGroupAddress)
 Copy a group and all of its contents, between the same or different HDF5 files or groups.
 
Group Mantid::Nexus::H5Util::createGroupCanSAS (Group &group, const std::string &name, const std::string &nxtype, const std::string &cstype)
 
Group Mantid::Nexus::H5Util::createGroupCanSAS (H5File &file, const std::string &name, const std::string &nxtype, const std::string &cstype)
 
Group Mantid::Nexus::H5Util::createGroupNXS (Group &group, const std::string &name, const std::string &nxtype)
 
Group Mantid::Nexus::H5Util::createGroupNXS (H5File &file, const std::string &name, const std::string &nxtype)
 
MANTID_NEXUS_DLL H5::FileAccPropList Mantid::Nexus::H5Util::defaultFileAcc ()
 Default file access is H5F_CLOSE_STRONG.
 
MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::deleteObjectLink (H5::H5Object &h5, const std::string &target)
 Delete a target link for a group or dataset from a parent group.
 
MANTID_NEXUS_DLL H5::DataSpace Mantid::Nexus::H5Util::getDataSpace (const size_t length)
 Create a 1D data-space to hold data of length.
 
template<typename NumT >
DataType Mantid::Nexus::H5Util::getType ()
 Convert a primitive type to the appropriate H5::DataType.
 
template<>
MANTID_NEXUS_DLL DataType Mantid::Nexus::H5Util::getType< bool > ()
 
template<>
MANTID_NEXUS_DLL DataType Mantid::Nexus::H5Util::getType< char > ()
 
template<>
MANTID_NEXUS_DLL DataType Mantid::Nexus::H5Util::getType< double > ()
 
template<>
MANTID_NEXUS_DLL DataType Mantid::Nexus::H5Util::getType< float > ()
 
template<>
MANTID_NEXUS_DLL DataType Mantid::Nexus::H5Util::getType< int16_t > ()
 
template<>
MANTID_NEXUS_DLL DataType Mantid::Nexus::H5Util::getType< int32_t > ()
 
template<>
MANTID_NEXUS_DLL DataType Mantid::Nexus::H5Util::getType< int64_t > ()
 
template<>
MANTID_NEXUS_DLL DataType Mantid::Nexus::H5Util::getType< int8_t > ()
 
template<>
MANTID_NEXUS_DLL DataType Mantid::Nexus::H5Util::getType< std::string > ()
 
template<>
MANTID_NEXUS_DLL DataType Mantid::Nexus::H5Util::getType< uint16_t > ()
 
template<>
MANTID_NEXUS_DLL DataType Mantid::Nexus::H5Util::getType< uint32_t > ()
 
template<>
MANTID_NEXUS_DLL DataType Mantid::Nexus::H5Util::getType< uint64_t > ()
 
template<>
MANTID_NEXUS_DLL DataType Mantid::Nexus::H5Util::getType< uint8_t > ()
 
MANTID_NEXUS_DLL bool Mantid::Nexus::H5Util::groupExists (H5::H5Object const &h5, const std::string &groupAddress)
 Test if a group already exists within an HDF5 file or parent group.
 
MANTID_NEXUS_DLL bool Mantid::Nexus::H5Util::hasAttribute (const H5::H5Object &object, const char *attributeName)
 
MANTID_NEXUS_DLL bool Mantid::Nexus::H5Util::isHdf5 (std::string const &filename)
 Determine if a given file can be opened with HDF5 using the CORRECT file access level (H5F_CLOSE_STRONG)
 
MANTID_NEXUS_DLL bool Mantid::Nexus::H5Util::keyHasValue (H5::H5Object const &h5, const std::string &key, const std::string &value)
 Test if an attribute is present and has a specific string value for an HDF5 group or dataset.
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const DataSet &dataset, std::vector< char > &output, const size_t length, const size_t offset)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const DataSet &dataset, std::vector< double > &output, const size_t length, const size_t offset)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const DataSet &dataset, std::vector< float > &output, const size_t length, const size_t offset)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const DataSet &dataset, std::vector< int16_t > &output, const size_t length, const size_t offset)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const DataSet &dataset, std::vector< int32_t > &output, const size_t length, const size_t offset)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const DataSet &dataset, std::vector< int64_t > &output, const size_t length, const size_t offset)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const DataSet &dataset, std::vector< int8_t > &output, const size_t length, const size_t offset)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const DataSet &dataset, std::vector< uint16_t > &output, const size_t length, const size_t offset)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const DataSet &dataset, std::vector< uint32_t > &output, const size_t length, const size_t offset)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const DataSet &dataset, std::vector< uint64_t > &output, const size_t length, const size_t offset)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const DataSet &dataset, std::vector< uint8_t > &output, const size_t length, const size_t offset)
 
template<typename OutT , Narrowing narrow>
void Mantid::Nexus::H5Util::readArray1DCoerce (const H5::DataSet &dataset, std::vector< OutT > &output, const size_t length, const size_t offset)
 Read a standard vector from a dataset, coerced to type of OutT.
 
template<typename OutT , Narrowing narrow>
std::vector< OutT > Mantid::Nexus::H5Util::readArray1DCoerce (const H5::Group &group, const std::string &name)
 
template MANTID_NEXUS_DLL std::vector< float > Mantid::Nexus::H5Util::readArray1DCoerce (const H5::Group &group, const std::string &name)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const H5::Group &group, const std::string &name, std::vector< double > &output)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const H5::Group &group, const std::string &name, std::vector< float > &output)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const H5::Group &group, const std::string &name, std::vector< int32_t > &output)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const H5::Group &group, const std::string &name, std::vector< int64_t > &output)
 
template<typename OutT , Narrowing narrow>
void Mantid::Nexus::H5Util::readArray1DCoerce (const H5::Group &group, const std::string &name, std::vector< OutT > &output)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const H5::Group &group, const std::string &name, std::vector< uint32_t > &output)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readArray1DCoerce (const H5::Group &group, const std::string &name, std::vector< uint64_t > &output)
 
template<typename OutT , Narrowing narrow>
std::vector< OutT > Mantid::Nexus::H5Util::readNumArrayAttributeCoerce (const H5::H5Object &object, const std::string &attributeName)
 Read a numerical array from an attribute, coerced to type of OutT.
 
template MANTID_NEXUS_DLL std::vector< float > Mantid::Nexus::H5Util::readNumArrayAttributeCoerce (const H5::H5Object &object, const std::string &attributeName)
 
template<typename OutT , Narrowing narrow>
OutT Mantid::Nexus::H5Util::readNumAttributeCoerce (const H5::H5Object &object, const std::string &attributeName)
 Read a single quantity from an attribute, coerced to type of OutT.
 
template MANTID_NEXUS_DLL float Mantid::Nexus::H5Util::readNumAttributeCoerce (const H5::H5Object &object, const std::string &attributeName)
 
MANTID_NEXUS_DLL std::string Mantid::Nexus::H5Util::readString (const H5::DataSet &dataset)
 
MANTID_NEXUS_DLL std::string Mantid::Nexus::H5Util::readString (const H5::Group &group, const std::string &name)
 
MANTID_NEXUS_DLL std::string Mantid::Nexus::H5Util::readString (H5::H5File &file, const std::string &address)
 
MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::readStringAttribute (const H5::H5Object &object, const std::string &attributeName, std::string &output)
 
std::vector< std::string > Mantid::Nexus::H5Util::readStringVector (DataSet &dataset)
 
std::vector< std::string > Mantid::Nexus::H5Util::readStringVector (Group &group, const std::string &name)
 Returns 1D vector of variable length strings.
 
MANTID_NEXUS_DLL H5::DSetCreatPropList Mantid::Nexus::H5Util::setCompressionAttributes (const std::size_t length, const int deflateLevel=6)
 Sets up the chunking and compression rate.
 
void Mantid::Nexus::H5Util::write (Group &group, const std::string &name, const std::string &value)
 
template<typename NumT >
void Mantid::Nexus::H5Util::writeArray1D (Group &group, const std::string &name, const std::vector< NumT > &values)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeArray1D (H5::Group &group, const std::string &name, const std::vector< double > &values)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeArray1D (H5::Group &group, const std::string &name, const std::vector< float > &values)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeArray1D (H5::Group &group, const std::string &name, const std::vector< int32_t > &values)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeArray1D (H5::Group &group, const std::string &name, const std::vector< int64_t > &values)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeArray1D (H5::Group &group, const std::string &name, const std::vector< uint32_t > &values)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeArray1D (H5::Group &group, const std::string &name, const std::vector< uint64_t > &values)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const char &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const double &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const float &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const int16_t &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const int32_t &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const int64_t &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const int8_t &value)
 
template<typename NumT >
void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const NumT &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const std::vector< char > &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const std::vector< double > &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const std::vector< float > &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const std::vector< int16_t > &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const std::vector< int32_t > &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const std::vector< int64_t > &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const std::vector< int8_t > &value)
 
template<typename NumT >
void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const std::vector< NumT > &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const std::vector< uint16_t > &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const std::vector< uint32_t > &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const std::vector< uint64_t > &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const std::vector< uint8_t > &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const uint16_t &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const uint32_t &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const uint64_t &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeNumAttribute (const H5::H5Object &object, const std::string &name, const uint8_t &value)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeScalarDataSetWithStrAttributes (H5::Group &group, const std::string &name, const double &value, const std::map< std::string, std::string > &attributes)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeScalarDataSetWithStrAttributes (H5::Group &group, const std::string &name, const float &value, const std::map< std::string, std::string > &attributes)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeScalarDataSetWithStrAttributes (H5::Group &group, const std::string &name, const int32_t &value, const std::map< std::string, std::string > &attributes)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeScalarDataSetWithStrAttributes (H5::Group &group, const std::string &name, const int64_t &value, const std::map< std::string, std::string > &attributes)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeScalarDataSetWithStrAttributes (H5::Group &group, const std::string &name, const std::string &value, const std::map< std::string, std::string > &attributes)
 
template<typename T >
void Mantid::Nexus::H5Util::writeScalarDataSetWithStrAttributes (H5::Group &group, const std::string &name, const T &value, const std::map< std::string, std::string > &attributes)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeScalarDataSetWithStrAttributes (H5::Group &group, const std::string &name, const uint32_t &value, const std::map< std::string, std::string > &attributes)
 
template MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeScalarDataSetWithStrAttributes (H5::Group &group, const std::string &name, const uint64_t &value, const std::map< std::string, std::string > &attributes)
 
MANTID_NEXUS_DLL void Mantid::Nexus::H5Util::writeStrAttribute (const H5::H5Object &object, const std::string &name, const std::string &value)
 

Macro Definition Documentation

◆ RUN_H5UTIL_FUNCTION

#define RUN_H5UTIL_FUNCTION (   dataType,
  func_name,
  ... 
)
Value:
if (dataType == PredType::NATIVE_FLOAT) { \
func_name<float, OutT, narrow>(__VA_ARGS__); \
} else if (dataType == PredType::NATIVE_DOUBLE) { \
func_name<double, OutT, narrow>(__VA_ARGS__); \
} else if (dataType == PredType::NATIVE_INT8) { \
func_name<int8_t, OutT, narrow>(__VA_ARGS__); \
} else if (dataType == PredType::NATIVE_UINT8) { \
func_name<uint8_t, OutT, narrow>(__VA_ARGS__); \
} else if (dataType == PredType::NATIVE_INT16) { \
func_name<int16_t, OutT, narrow>(__VA_ARGS__); \
} else if (dataType == PredType::NATIVE_UINT16) { \
func_name<uint16_t, OutT, narrow>(__VA_ARGS__); \
} else if (dataType == PredType::NATIVE_INT32) { \
func_name<int32_t, OutT, narrow>(__VA_ARGS__); \
} else if (dataType == PredType::NATIVE_UINT32) { \
func_name<uint32_t, OutT, narrow>(__VA_ARGS__); \
} else if (dataType == PredType::NATIVE_INT64) { \
func_name<int64_t, OutT, narrow>(__VA_ARGS__); \
} else if (dataType == PredType::NATIVE_UINT64) { \
func_name<uint64_t, OutT, narrow>(__VA_ARGS__); \
} else if (dataType == PredType::C_S1) { \
func_name<char, OutT, narrow>(__VA_ARGS__); \
} else { \
std::string msg = "H5Util: error in narrowing, unknown H5Cpp PredType "; \
msg += dataType.fromClass() + "."; \
throw DataTypeIException(msg); \
}

This macro matches the dataType in terms of PredType, with the actual primitive datatype.

The macro assumes it is called from inside a function where OutT, narrow are defined. It assumes that func_name is a template function with parameters <InT, OutT, narrow> It will set InT to the proper value, based on dataType.

Definition at line 90 of file H5Util.cpp.