-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIOManager.cpp
More file actions
32 lines (29 loc) · 802 Bytes
/
IOManager.cpp
File metadata and controls
32 lines (29 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "IOManager.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <fstream>
#include <exception>
#include <cctype>
IOManager::IOManager(std::string _inputFile, std::string _outputFile) : outputFile_(_outputFile) {
std::ifstream fin;
std::stringstream ss;
fin.open(_inputFile.c_str());
if (fin.fail()) throw std::invalid_argument("Bad input file name.");
char next;
while (!fin.eof()) {
fin.get(next);
if (!isalpha(next)) continue;
if (isupper(next)) next = tolower(next);
ss << next;
}
fin.close();
this->plaintext_ = ss.str();
}
void IOManager::writeCipherText(std::string _encrypted) {
std::ofstream fout;
fout.open(outputFile_);
if (fout.fail()) throw std::invalid_argument("Bad output file.");
fout << _encrypted;
fout.close();
}