LAMA
lama::XDRFileStream Class Reference

XDR file stream class to access XDR files Supported data types: (unsigned) int, (unsigned) long, float, double. More...

#include <XDRFileStream.hpp>

Public Member Functions

 XDRFileStream (const std::string &filename, const std::ios_base::openmode openmode)
 The default constructor creates a XDR stream in the specified openmode.
virtual ~XDRFileStream ()
 The default destructor destroys the XDR stream if the file has been opened.
template<typename T >
void read (T *const input, const std::streamsize n)
 Reads Values(s) of Type T from the XDR stream.
template<typename T >
void read (T *const input)
 Reads Values(s) of Type T from the XDR stream.
template<typename T >
void write (T *const input, const std::streamsize n)
 Writes Values of Type T to the XDR stream.
template<typename T >
void write (T *const input)
 Writes Values of Type T to the XDR stream.
bool is_open ()
 Checks if the vector file could be opened.
void close ()
 Destroys the XDR stream if it has been opened.

Private Member Functions

void openFilePointer (const std::string filename, const std::ios_base::openmode openmode)
template<typename T >
void xdrRead (T *const data)
template<typename T >
void xdrWrite (const T *const data)
template<typename T >
int getSize (const T)
bool isLittleEndian ()

Private Attributes

std::string m_filename
std::fstream m_filestream
std::ios_base::openmode m_openmode

Detailed Description

XDR file stream class to access XDR files Supported data types: (unsigned) int, (unsigned) long, float, double.


Constructor & Destructor Documentation

lama::XDRFileStream::XDRFileStream ( const std::string &  filename,
const std::ios_base::openmode  openmode 
)

The default constructor creates a XDR stream in the specified openmode.

(in/out)

Parameters:
[in]filenameIncludes (the path and) the file name.
[in]openmodeOpenmode of the XDR stream defined in standard C++ I/O openmode (std::ios::in or std::ios::out). The binary (std::ios::in) mode is automatically added.

References openFilePointer().

The default destructor destroys the XDR stream if the file has been opened.

References close().


Member Function Documentation

Destroys the XDR stream if it has been opened.

References is_open(), and m_filestream.

Referenced by ~XDRFileStream().

template<typename T >
int lama::XDRFileStream::getSize ( const T  ) [private]

References LAMA_THROWEXCEPTION.

Referenced by xdrRead(), and xdrWrite().

Checks if the vector file could be opened.

Returns:
Returns true if the file could be successfully opened.

References m_filestream.

Referenced by close(), xdrRead(), and xdrWrite().

Referenced by xdrRead(), and xdrWrite().

void lama::XDRFileStream::openFilePointer ( const std::string  filename,
const std::ios_base::openmode  openmode 
) [private]

References m_filename, m_filestream, and m_openmode.

Referenced by XDRFileStream().

template<typename T >
void lama::XDRFileStream::read ( T *const  input,
const std::streamsize  n 
)

Reads Values(s) of Type T from the XDR stream.

Parameters:
[out]inputData pointer for the data which should be read from the XDR stream.
[in]nNumber of values which should be read to the input field.

References LAMA_THROWEXCEPTION, m_openmode, and xdrRead().

Referenced by read(), and lama::readData().

template<typename T >
void lama::XDRFileStream::read ( T *const  input)

Reads Values(s) of Type T from the XDR stream.

Parameters:
[out]inputData pointer for the data which should be read from the XDR stream.

References read().

template<typename T >
void lama::XDRFileStream::write ( T *const  input,
const std::streamsize  n 
)

Writes Values of Type T to the XDR stream.

Parameters:
[in]outputData pointer for the data which should be written to the XDR stream.
[in]nNumber of values which should be written to the output

References LAMA_THROWEXCEPTION, m_openmode, and xdrWrite().

Referenced by write(), lama::StorageIO< T >::writeCSRToXDRFile(), and lama::writeData().

template<typename T >
void lama::XDRFileStream::write ( T *const  input)

Writes Values of Type T to the XDR stream.

Parameters:
[in]outputData pointer for the data which should be written to the XDR stream.

References write().

template<typename T >
void lama::XDRFileStream::xdrRead ( T *const  data) [private]
template<typename T >
void lama::XDRFileStream::xdrWrite ( const T *const  data) [private]

Field Documentation

std::string lama::XDRFileStream::m_filename [private]

Referenced by openFilePointer().

std::ios_base::openmode lama::XDRFileStream::m_openmode [private]

Referenced by openFilePointer(), read(), and write().


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