29 #ifndef CDPL_UTIL_FILEDATAWRITER_HPP
30 #define CDPL_UTIL_FILEDATAWRITER_HPP
49 template <
typename WriterImpl,
typename DataType =
typename WriterImpl::DataType>
55 std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out | std::ios_base::trunc | std::ios_base::binary);
61 operator const void*()
const;
75 template <
typename WriterImpl,
typename DataType>
77 stream(file_name.c_str(), mode), fileName(file_name), writer(stream)
79 writer.setParent(
this);
83 template <
typename WriterImpl,
typename DataType>
90 }
catch (
const std::exception& e) {
91 throw Base::IOError(
"FileDataWriter: while writing file '" + fileName +
"': " + e.what());
97 template <
typename WriterImpl,
typename DataType>
104 template <
typename WriterImpl,
typename DataType>
107 return writer.operator
const void*();
110 template <
typename WriterImpl,
typename DataType>
113 return writer.operator!();
Definition of exception classes.
Definition of the class CDPL::Base::DataWriter.
void invokeIOCallbacks(double progress) const
Invokes all registered I/O callback functions with the argument *this.
An interface for writing data objects of a given type to an arbitrary data sink.
Definition: DataWriter.hpp:63
typename WriterImpl::DataType DataType
The type of the written data objects.
Definition: DataWriter.hpp:74
Thrown to indicate that an I/O operation has failed because of physical (e.g. broken pipe) or logical...
Definition: Base/Exceptions.hpp:250
FileDataWriter.
Definition: FileDataWriter.hpp:51
FileDataWriter(const std::string &file_name, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out|std::ios_base::trunc|std::ios_base::binary)
Definition: FileDataWriter.hpp:76
void close()
Writes format dependent data (if required) to mark the end of output.
Definition: FileDataWriter.hpp:98
FileDataWriter & write(const DataType &obj)
Definition: FileDataWriter.hpp:85
bool operator!() const
Tells whether the writer is in a bad state.
Definition: FileDataWriter.hpp:111
The namespace of the Chemical Data Processing Library.