Hex  1.0
Hydrogen-electron collision solver
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions
HDFFile Class Reference

HDF I/O management. More...

#include <hdffile.h>

Public Types

enum  FileAccess { readonly, overwrite, failifexists, readwrite }
 Access mode. More...
 

Public Member Functions

 HDFFile (std::string filename, FileAccess flag)
 Constructor from filename and access mode. More...
 
 ~HDFFile ()
 Destructor. More...
 
size_t size (std::string dataset) const
 Get size of the dataset of valid file. More...
 
template<typename T >
bool read (std::string dataset, T *buffer, size_t length) const
 load data from a valid file. More...
 
template<typename T >
bool write (std::string dataset, T const *data, size_t length)
 Write data to a valid file. More...
 
bool valid () const
 Check that the file is valid. More...
 
template<>
bool read (std::string dataset, int *buffer, size_t length) const
 
template<>
bool read (std::string dataset, unsigned int *buffer, size_t length) const
 
template<>
bool read (std::string dataset, long *buffer, size_t length) const
 
template<>
bool read (std::string dataset, unsigned long *buffer, size_t length) const
 
template<>
bool read (std::string dataset, double *buffer, size_t length) const
 
template<>
bool read (std::string dataset, Complex *buffer, size_t length) const
 
template<>
bool write (std::string dataset, int const *buffer, size_t length)
 
template<>
bool write (std::string dataset, unsigned int const *buffer, size_t length)
 
template<>
bool write (std::string dataset, long const *buffer, size_t length)
 
template<>
bool write (std::string dataset, unsigned long const *buffer, size_t length)
 
template<>
bool write (std::string dataset, double const *buffer, size_t length)
 
template<>
bool write (std::string dataset, Complex const *buffer, size_t length)
 

Detailed Description

This class abstracts the raw functions for work with HDF files, so that template functions can be used and the user doesn't need to bother with type specializations. The typical usage is

* rArray nums = linspace (1., 10., 10);
*
* ...
*
* HDFFile hdffile("test.hdf", readonly);
*
* if (hdffile.valid())
* hdffile.write("nums", nums.data(), nums.size());
* else
* throw exception ("Cannot write to test.hdf!");
*
*

Member Enumeration Documentation

This flag is used in the constructor of HDFFile to specify access mode to the file (read only, overwrite etc.).

Enumerator
readonly 
overwrite 
failifexists 
readwrite 

Constructor & Destructor Documentation

HDFFile::HDFFile ( std::string  filename,
FileAccess  flag 
)
HDFFile::~HDFFile ( )

Member Function Documentation

template<typename T >
bool HDFFile::read ( std::string  dataset,
T *  buffer,
size_t  length 
) const
template<>
bool HDFFile::read ( std::string  dataset,
int *  buffer,
size_t  length 
) const
template<>
bool HDFFile::read ( std::string  dataset,
unsigned int *  buffer,
size_t  length 
) const
template<>
bool HDFFile::read ( std::string  dataset,
long *  buffer,
size_t  length 
) const
template<>
bool HDFFile::read ( std::string  dataset,
unsigned long *  buffer,
size_t  length 
) const
template<>
bool HDFFile::read ( std::string  dataset,
double *  buffer,
size_t  length 
) const
template<>
bool HDFFile::read ( std::string  dataset,
Complex buffer,
size_t  length 
) const
size_t HDFFile::size ( std::string  dataset) const
bool HDFFile::valid ( ) const
inline
template<typename T >
bool HDFFile::write ( std::string  dataset,
T const *  data,
size_t  length 
)
template<>
bool HDFFile::write ( std::string  dataset,
int const *  buffer,
size_t  length 
)
template<>
bool HDFFile::write ( std::string  dataset,
unsigned int const *  buffer,
size_t  length 
)
template<>
bool HDFFile::write ( std::string  dataset,
long const *  buffer,
size_t  length 
)
template<>
bool HDFFile::write ( std::string  dataset,
unsigned long const *  buffer,
size_t  length 
)
template<>
bool HDFFile::write ( std::string  dataset,
double const *  buffer,
size_t  length 
)
template<>
bool HDFFile::write ( std::string  dataset,
Complex const *  buffer,
size_t  length 
)

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