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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#include <iostream>
#include <string>
#include <unordered_map>
#include "Morse.h"
MorseCode::MorseCode() : encodeMap{
{ 'A', ".-" },{ 'B', "-..." },{ 'C', "-.-." },{ 'D', "-.." },{ 'E', "." },
{ 'F', "..-." },{ 'G', "--." },{ 'H', "...." },{ 'I', ".." },{ 'J', ".---" },{ 'K', "-.-" },
{ 'L', ".-.." },{ 'M', "--" },{ 'N', "-." },{ 'O', "---" },{ 'P', ".--." },{ 'Q', "--.-" },
{ 'R', ".-." },{ 'S', "..." },{ 'T', "-" },{ 'U', "..-" },{ 'V', "...-" },{ 'W', ".--" },
{ 'X', "-..-" },{ 'Y', "-.--" },{ 'Z', "--.." },{ '1', ".----" },{ '2', "..---" },{ '3', "...--" },{ '4', "....-" },
{ '5', "....." },{ '6', "-...." },{ '7', "--..." },{ '8', "---.." },{ '9', "----." },{ '0', "-----" },
{ '.', ".-.-.-" },{ ',', "--..--" },{ ':', "---..." },{ '?', "..--.." },{ '-', "-...-" },
{ '/', "-..-." }
}
{
}
MorseCode::MorseCode() : decodeMap{
{ ".-", 'A' }, { "-...", 'B' },{ "-.-.", 'C' },{ "-..", 'D' },{ ".", 'E' },
{ "..-.", 'F' },{ "--.", 'G' },{ "....", 'H' },{ "..", 'I' },{ ".---", 'J' },{ "-.-", 'K' },
{ ".-..", 'L' },{ "--", 'M' },{ "-.", 'N' },{ "---", 'O' },{ ".--.", 'P' },{ "--.-", 'Q' },
{ ".-.", 'R' },{ "...", 'S' },{ "-", 'T' },{ "..-", 'U' },{ "...-", 'V' },{ ".--", 'W' },
{ "-..-", 'X' },{ "-.--", 'Y' },{ "--..", 'Z' },{ ".----", '1' },{ "..---", '2' },{ "...--", '3' },{ "....-", '4' },
{ ".....", '5' },{ "-....", '6' },{ "--...", '7' },{ "---..", '8' },{ "----.", '9' },{ "-----", '0' },
{ ".-.-.-", '.' },{ "--..--", ',' },{ "---...", ':' },{ "..--..", '?' },{ "-...-", '-' },
{ "-..-.", '/' }, { " ", ' '}
}
{
}
std::string MorseCode::enCode(const char&) const
{
//unordered_map<string, char>const_iterator got = encodeMap.find(enCode);
//std::unordered_map<std::string, char>::const_iterator got = encodeMap.find (enCode);
// (got == encodeMap.end())
//std::cout << "not found";
//else
//std::cout << got->first << " is " << got->second;
//std::cout << std::endl;
std::string input;
//auto thing = encodeMap.find(input);
return std::string();
}
char MorseCode::deCode(const std::string &) const
{
std::string input;
return 0;
}
|