File indexing completed on 2024-09-27 07:03:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include <iostream>
0035 #include <exception>
0036 #include <cstdlib>
0037
0038 #include "filewriter.h"
0039
0040
0041 using namespace std;
0042
0043
0044 fileWriter::fileWriter()
0045 : _fileName(""),
0046 _fileStream()
0047 { }
0048
0049
0050 fileWriter::fileWriter(const string& fileName) :
0051 _fileName(fileName)
0052 ,_fileStream(fileName.c_str())
0053 { }
0054
0055 fileWriter::~fileWriter()
0056 { }
0057
0058 int fileWriter::open()
0059 {
0060 try
0061 {
0062 _fileStream.open(_fileName.c_str());
0063 _fileStream.precision(15);
0064 _fileStream.setf(ios::fixed);
0065 }
0066 catch (const ios::failure & error)
0067 {
0068 cerr << "I/O exception: " << error.what() << endl;
0069 return EXIT_FAILURE;
0070 }
0071 return 0;
0072 }
0073
0074
0075 int fileWriter::open(const string& fileName)
0076 {
0077 _fileName = fileName;
0078 return open();
0079 }
0080
0081
0082 int fileWriter::close()
0083 {
0084 try
0085 {
0086 _fileStream.close();
0087 }
0088 catch (const ios::failure & error)
0089 {
0090 cerr << "I/O exception: " << error.what() << endl;
0091 return EXIT_FAILURE;
0092 }
0093 return 0;
0094 }