diff --git a/src/morse.cpp b/src/morse.cpp index 84b9037..e5a46ef 100644 --- a/src/morse.cpp +++ b/src/morse.cpp @@ -4,7 +4,7 @@ #include "morse.h" -std::map morseCode = { +std::map morseMap = { {'A', ".-"}, {'B', "-..."}, {'C', "-.-."}, @@ -82,7 +82,7 @@ void refurbishMessage(std::string &msg) // Remove all other unknown characters msg.erase(remove_if(msg.begin(), msg.end(), - [](const char &c) { return c != ' ' && morseCode.find(c) == morseCode.end(); }), + [](const char &c) { return c != ' ' && morseMap.find(c) == morseMap.end(); }), msg.end()); // Remove spaces, if there are too many of them @@ -104,20 +104,20 @@ std::string messageToMorse(std::string &msg) } // Ignore and continue with next char, if not found - auto search = morseCode.find(c); - if (search == morseCode.end()) { + auto search = morseMap.find(c); + if (search == morseMap.end()) { continue; } - for (unsigned int j = 0; j < morseCode[c].length(); j++) { - char m = morseCode[c][j]; + for (unsigned int j = 0; j < morseMap[c].length(); j++) { + char m = morseMap[c][j]; if (j == 0 && i > 0 && msg[i - 1] != ' ') { morseString.push_back('c'); } morseString += m; - if (j < morseCode[c].length() - 1) { + if (j < morseMap[c].length() - 1) { morseString.push_back('i'); } } @@ -140,12 +140,12 @@ std::string charToMorse(char ch) return morseString; } - for (unsigned int j = 0; j < morseCode[ch].length(); j++) { - char m = morseCode[ch][j]; + for (unsigned int j = 0; j < morseMap[ch].length(); j++) { + char m = morseMap[ch][j]; morseString += m; - if (j < morseCode[ch].length() - 1) { + if (j < morseMap[ch].length() - 1) { morseString.push_back('i'); } }