#include "outputfilemedium.hh" #include "posexcept.hh" using namespace std ; /* *** Constructors *** */ /** * Prepares the OutputFileMedium to write to a CSV file. * @param filename The name of the file to open. * @throw error_opening_input_file if the file cannot be opened. */ OutputFileMedium::OutputFileMedium(const string &_file_name): file_name(_file_name) { file.open(file_name.c_str()) ; if (! file) throw error_opening_input_file(file_name) ; } OutputFileMedium::~OutputFileMedium() { file.close() ; } /* *** Operations *** */ /** * @return true if the string has been written successfuly, or false * if not. */ bool OutputFileMedium::write_string_to_file(const string &text) { if (! file) return false ; file << text.c_str() ; return true ; }