#include "textfilewriter.hh" #include "configuration.hh" #include "posexcept.hh" using namespace std ; /* *** Constructors *** */ /** * @param _file_name The name of the file to open. * @throw error_opening_input_file if the file cannot be opened. */ TextFileWriter::TextFileWriter(const string &_file_name): file_name(_file_name) { file.open(file_name.c_str()) ; if (! file) throw error_opening_output_file(file_name) ; } TextFileWriter::~TextFileWriter() { file.close() ; } /* *** Operations *** */ /** * @return true if the string has been written successfuly, or false * if not. */ bool TextFileWriter::write_text(const string &text) { if (! file) return false ; file << text ; if (Configuration::bool_value("flush-output-files")) file.flush() ; return true ; }