mirror of
https://bitbucket.org/Mattrixwv/cipherstream.git
synced 2025-12-06 18:33:58 -05:00
Added new documentation
This commit is contained in:
@@ -10,17 +10,26 @@
|
|||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
|
|
||||||
std::string Morse::code[] {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", //A-L
|
/**
|
||||||
"--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", //M-Z
|
* @brief Construct a new Morse object
|
||||||
"-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----."}; //0-9
|
*
|
||||||
|
*/
|
||||||
Morse::Morse(){
|
Morse::Morse(){
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Destroy the Morse object
|
||||||
|
*
|
||||||
|
*/
|
||||||
Morse::~Morse(){
|
Morse::~Morse(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Uses alphabet rules to set inputString
|
||||||
|
*
|
||||||
|
* @param input The string to be encoded
|
||||||
|
*/
|
||||||
void Morse::setEncodeInputString(std::string input){
|
void Morse::setEncodeInputString(std::string input){
|
||||||
//Make sure the input is empty to begin
|
//Make sure the input is empty to begin
|
||||||
std::string temp;
|
std::string temp;
|
||||||
@@ -37,6 +46,11 @@ void Morse::setEncodeInputString(std::string input){
|
|||||||
inputString.str(temp);
|
inputString.str(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Uses . & - rules to set inputString
|
||||||
|
*
|
||||||
|
* @param input The string that needs decoded
|
||||||
|
*/
|
||||||
void Morse::setDecodeInputString(std::string input){
|
void Morse::setDecodeInputString(std::string input){
|
||||||
std::string temp;
|
std::string temp;
|
||||||
//Step through every element in input, removing everything except . or -
|
//Step through every element in input, removing everything except . or -
|
||||||
@@ -53,14 +67,29 @@ void Morse::setDecodeInputString(std::string input){
|
|||||||
inputString.str(temp);
|
inputString.str(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the string that needs encoded/decoded
|
||||||
|
*
|
||||||
|
* @return The string that needs encoded/decoded
|
||||||
|
*/
|
||||||
std::string Morse::getInputString() const{
|
std::string Morse::getInputString() const{
|
||||||
return inputString.str();
|
return inputString.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the encoded/decoded message
|
||||||
|
*
|
||||||
|
* @return The encoded/decoded message
|
||||||
|
*/
|
||||||
std::string Morse::getOutputString() const{
|
std::string Morse::getOutputString() const{
|
||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Encodes inputString and stores the result in outputString
|
||||||
|
*
|
||||||
|
* @return The encoded message
|
||||||
|
*/
|
||||||
std::string Morse::encode(){
|
std::string Morse::encode(){
|
||||||
outputString = "";
|
outputString = "";
|
||||||
std::string temp = inputString.str();
|
std::string temp = inputString.str();
|
||||||
@@ -89,11 +118,22 @@ std::string Morse::encode(){
|
|||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Encodes the message contained in input
|
||||||
|
*
|
||||||
|
* @param input The message that needs encoded
|
||||||
|
* @return The encoded message
|
||||||
|
*/
|
||||||
std::string Morse::encode(std::string input){
|
std::string Morse::encode(std::string input){
|
||||||
setEncodeInputString(input);
|
setEncodeInputString(input);
|
||||||
return encode();
|
return encode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Decodes inputString and stores the result in outputString
|
||||||
|
*
|
||||||
|
* @return The decoded message
|
||||||
|
*/
|
||||||
std::string Morse::decode(){
|
std::string Morse::decode(){
|
||||||
outputString = "";
|
outputString = "";
|
||||||
//Loop until you reach the end of the input
|
//Loop until you reach the end of the input
|
||||||
@@ -128,11 +168,21 @@ std::string Morse::decode(){
|
|||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Decodes the message contained in input
|
||||||
|
*
|
||||||
|
* @param input The message that needs decoded
|
||||||
|
* @return The decoded message
|
||||||
|
*/
|
||||||
std::string Morse::decode(std::string input){
|
std::string Morse::decode(std::string input){
|
||||||
setDecodeInputString(input);
|
setDecodeInputString(input);
|
||||||
return decode();
|
return decode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Makes sure all variables are blank
|
||||||
|
*
|
||||||
|
*/
|
||||||
void Morse::reset(){
|
void Morse::reset(){
|
||||||
inputString.str("");
|
inputString.str("");
|
||||||
outputString = "";
|
outputString = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user