From 539e6c33ec736c9e9ef5c37f8a984c8ad8a9347e Mon Sep 17 00:00:00 2001 From: Matthew Ellison Date: Sat, 5 May 2018 15:13:19 -0400 Subject: [PATCH] Added new documentation --- SourceFiles/Atbash.cpp | 59 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/SourceFiles/Atbash.cpp b/SourceFiles/Atbash.cpp index 7bb21f0..f038563 100644 --- a/SourceFiles/Atbash.cpp +++ b/SourceFiles/Atbash.cpp @@ -1,22 +1,33 @@ //Ciphers/SourceFiles/Atbash.cpp //Matthew Ellison // Created: 4-30-18 -//Modified: 4-30-18 +//Modified: 5-5-18 //This file contains the implementation of the Atbash class #include "../Headers/Atbash.hpp" #include +/** + * @brief Construct a new Atbash object + * + */ Atbash::Atbash(){ } +/** + * @brief Destroy the Atbash object + * + */ Atbash::~Atbash(){ } +/** + * @brief Strips all invalid characters from input and sets it to inputString + * + * @param input The string that you wish to encode or decode + */ void Atbash::setInputString(std::string input){ - //Make sure inputString is empty - reset(); //Strip all punctuation and whitespace from input and make all letters capital for(int cnt = 0;cnt < input.size();++cnt){ char letter = input[cnt]; @@ -32,14 +43,29 @@ void Atbash::setInputString(std::string input){ } } +/** + * @brief Returns the stripped inputString + * + * @return The current inputString + */ std::string Atbash::getInputString() const{ return inputString; } +/** + * @brief Returns the current outputString + * + * @return The current outputString + */ std::string Atbash::getOutputString() const{ return outputString; } +/** + * @brief Uses the Atbash cipher to encode inputString and store it in outputString + * + * @return The encoded inputString (outputString) + */ std::string Atbash::encode(){ //Step through every element in the inputString and shift it the correct amount for(int cnt = 0;cnt < inputString.size();++cnt){ @@ -49,14 +75,25 @@ std::string Atbash::encode(){ return outputString; } +/** + * @brief A simple interface that makes sure inputString is set and encodes it using the Atbash cipher + * + * @param input The string that you wish to encode + * @return The encoded string + */ std::string Atbash::encode(std::string input){ + //Make sure everything is empty before you begin + reset(); setInputString(input); return encode(); } +/** + * @brief Uses the Atbash cipher to decode inputString and store it in outputString + * + * @return The decoded inputString (outputString) + */ std::string Atbash::decode(){ - //Make sure outputString is empty - outputString = ""; for(int cnt = 0;cnt < inputString.size();++cnt){ outputString += (inputString[cnt] + 25 - (2 * (inputString[cnt] - 'A'))); } @@ -64,11 +101,23 @@ std::string Atbash::decode(){ return outputString; } +/** + * @brief A simple interface that makes sure inputString is set and decodes it using the Atbash cipher + * + * @param input The string that you wish to encode + * @return The decoded string + */ std::string Atbash::decode(std::string input){ + //Make sure everything is empty before you begin + reset(); setInputString(input); return decode(); } +/** + * @brief Resets all variables + * + */ void Atbash::reset(){ inputString = outputString = ""; }