29 lines
No EOL
564 B
C++
29 lines
No EOL
564 B
C++
#include "morse_code.h"
|
|
|
|
Morse_code::Morse_code(std::string filename) {
|
|
std::ifstream in(filename);
|
|
|
|
char c;
|
|
while (in >> c) {
|
|
std::string s;
|
|
in >> s;
|
|
morse_map.insert(std::make_pair(c, s)); // gay ass
|
|
}
|
|
}
|
|
|
|
std::string Morse_code::encode(const std::string &str) {
|
|
|
|
std::string res;
|
|
|
|
for (auto &c : str) {
|
|
auto it = morse_map.find(c);
|
|
if (it != morse_map.end()) {
|
|
res += it->second + " ";
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
|
|
// std::string Morse_code::decode(const std::string &str) {
|
|
|
|
// }
|