SpECTRE  v2024.03.19
h5::Header Class Reference

Writes header info about the build, git commit, branch, etc. More...

#include <Header.hpp>

Public Member Functions

const std::stringget_header () const
 
std::string get_env_variables () const
 Returns the environment variables at compile time of the simulation that produced the file.
 
std::string get_build_info () const
 Returns the contents of the BuildInfo.txt file generated by CMake of the simulation that produced the file.
 
const std::stringsubfile_path () const override
 Return the path to the subfile where this object is stored. More...
 
virtual const std::stringsubfile_path () const =0
 Return the path to the subfile where this object is stored. More...
 

Detailed Description

Writes header info about the build, git commit, branch, etc.

A Header object is used to store the info_from_build() result in the HDF5 files. The Header is automatically added to every single file by the constructor of H5File.

Example

You can read the header info out of an H5 file as shown in the example:

std::string input_source_yaml{"TestOption: 4\n\nOtherOption: 5\n\n"};
// Add a giant set of comments to the h5 file, to test that we can
// read and write very long yaml files to H5 attributes
input_source_yaml += "# "s;
for (size_t i = 0; i < 1000000; ++i) {
input_source_yaml += "abcdefghij"s;
// Output lines < 80 chars, as in an actual yaml input file
if (i % 7 == 0) {
input_source_yaml += "\n# "s;
}
}
input_source_yaml += "\n\n"s;
h5::H5File<h5::AccessType::ReadWrite> my_file0(h5_file_name, false,
input_source_yaml);
// Check that the header was written correctly
const std::string header = my_file0.get<h5::Header>("/header").get_header();
Writes header info about the build, git commit, branch, etc.
Definition: Header.hpp:28

Member Function Documentation

◆ subfile_path()

const std::string & h5::Header::subfile_path ( ) const
inlineoverridevirtual

Return the path to the subfile where this object is stored.

Implements h5::Object.


The documentation for this class was generated from the following file: