musrfit 1.10.0
nxs Namespace Reference

Common utilities for NeXus file handling. More...

Enumerations

enum class  HDFType { HDF4 , HDF5 , Unknown }
 Enumeration of supported HDF file types. More...
 

Functions

HDFType checkHDFType (const std::string &filename)
 Determine the HDF format type of a file by reading its header.
 
std::string getIso8601TimestampLocal ()
 get the current time and return it as na IOS8601 time stamp.
 

Detailed Description

Common utilities for NeXus file handling.

The nxs namespace provides utility functions that are common to both HDF4 and HDF5 implementations. This includes file type detection and shared enumerations.

See also
nxH4 for HDF4-specific implementation
nxH5 for HDF5-specific implementation

Enumeration Type Documentation

◆ HDFType

enum class nxs::HDFType
strong

Enumeration of supported HDF file types.

Used to identify whether a file is HDF4, HDF5, or of unknown format. This is determined by reading the file's magic bytes header.

Enumerator
HDF4 

HDF4 format (magic: 0x0e 0x03 0x13 0x01)

HDF5 

HDF5 format (magic: 0x89 'H' 'D' 'F' 0x0d 0x0a 0x1a 0x0a)

Unknown 

Unrecognized file format.

Examples
/workspace/LMU/musrfit/src/external/nexus/PNeXus.h.

Definition at line 141 of file PNeXus.h.

Function Documentation

◆ checkHDFType()

nxs::HDFType nxs::checkHDFType ( const std::string & filename)

Determine the HDF format type of a file by reading its header.

Opens the file in binary mode and reads the first 8 bytes to compare against known HDF4 and HDF5 magic byte signatures. This allows automatic format detection before attempting to open the file with the appropriate library.

Parameters
filenamePath to the file to check
Returns
nxs::HDFType indicating the format (HDF4, HDF5, or Unknown)
Examples
/workspace/LMU/musrfit/src/external/nexus/PNeXus.cpp, and /workspace/LMU/musrfit/src/external/nexus/PNeXus.h.

Definition at line 100 of file PNeXus.cpp.

References HDF4, HDF5, and Unknown.

Referenced by dump_header_nexus(), and PRunDataHandler::ReadNexusFile().

◆ getIso8601TimestampLocal()

std::string nxs::getIso8601TimestampLocal ( )

get the current time and return it as na IOS8601 time stamp.

Returns
ISO 8601 time stamp string
Examples
/workspace/LMU/musrfit/src/external/nexus/PNeXus.cpp, and /workspace/LMU/musrfit/src/external/nexus/PNeXus.h.

Definition at line 139 of file PNeXus.cpp.

Referenced by PRunDataHandler::WriteNexusFile().