29 #ifndef CDPL_UTIL_FILEDATAWRITER_HPP
30 #define CDPL_UTIL_FILEDATAWRITER_HPP
53 template <
typename WriterImpl,
typename DataType =
typename WriterImpl::DataType>
66 std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out | std::ios_base::trunc | std::ios_base::binary);
85 operator const void*()
const;
104 template <
typename WriterImpl,
typename DataType>
106 stream(file_name.c_str(), mode), fileName(file_name), writer(stream)
111 writer.setParent(
this);
115 template <
typename WriterImpl,
typename DataType>
122 }
catch (
const std::exception& e) {
123 throw Base::IOError(
"FileDataWriter: while writing file '" + fileName +
"': " + e.what());
129 template <
typename WriterImpl,
typename DataType>
136 template <
typename WriterImpl,
typename DataType>
139 return writer.operator
const void*();
142 template <
typename WriterImpl,
typename DataType>
145 return writer.operator!();
Definition of exception classes.
Definition of class CDPL::Base::DataWriter.
void invokeIOCallbacks(double progress) const
Invokes all registered I/O callback functions with the argument *this.
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
Convenience wrapper that adapts a stream-based writer implementation WriterImpl into a file-based Bas...
Definition: FileDataWriter.hpp:55
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)
Constructs a FileDataWriter instance that opens the file file_name in the given mode and forwards all...
Definition: FileDataWriter.hpp:105
void close()
Closes the wrapped writer and the underlying file stream.
Definition: FileDataWriter.hpp:130
FileDataWriter & write(const DataType &obj)
Writes obj as the next record via the wrapped writer.
Definition: FileDataWriter.hpp:117
bool operator!() const
Tells whether the writer is in a bad (non-writable) state.
Definition: FileDataWriter.hpp:143
The namespace of the Chemical Data Processing Library.