mirror of
https://bitbucket.org/Mattrixwv/cipherstream.git
synced 2025-12-06 18:33:58 -05:00
37 lines
1.5 KiB
C++
37 lines
1.5 KiB
C++
//Ciphers/Headers/Morse.hpp
|
|
//Matthew Ellison
|
|
// Created: 5-1-18
|
|
//Modified: 5-5-18
|
|
//This file contains the declaration of the Morse class
|
|
//This class is designed to translate Morse Code into regular letters and numbers
|
|
|
|
#ifndef MORSE_HPP
|
|
#define MORSE_HPP
|
|
|
|
#include <string>
|
|
#include <sstream>
|
|
|
|
|
|
class Morse{
|
|
private:
|
|
//Holds the Morse representation of the alphanumeric characters
|
|
const std::string Morse::code[36] {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", //A-L
|
|
"--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", //M-Z
|
|
"-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----."}; //0-9
|
|
std::stringstream inputString; //The string that needs encoded/decoded
|
|
std::string outputString; //The encoded/decoded message
|
|
std::string encode(); //Encodes inputString and stores the result in outputString
|
|
std::string decode(); //Decodes inputString and stores the result in outputString
|
|
void setEncodeInputString(std::string input); //Encodes input and returns the result
|
|
void setDecodeInputString(std::string input); //Decodes input and returns the result
|
|
public:
|
|
Morse();
|
|
~Morse();
|
|
std::string getInputString() const; //Returns inputString
|
|
std::string getOutputString() const; //Returns outputString
|
|
std::string encode(std::string input); //Encodes input and returns the result
|
|
std::string decode(std::string input); //Decodes input and returns the result
|
|
void reset(); //Makes sure all variables are empty
|
|
};
|
|
|
|
#endif //MORSE_HPP
|