Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*==================================================================================================
- --------------------------------------------------------------------------------------------------
- [simpleCrypto.hpp]
- Main header file for the simpleCrypto program.
- (c) Damion 'Phr0z3n.dev' Tapper, 2014.
- Email: Phr0z3n.Dev@Gmail.com
- --------------------------------------------------------------------------------------------------
- ==================================================================================================*/
- /*===============================================--=================================================
- CONSTANT DEFINITIONS
- --------------------------------------------------------------------------------------------------*/
- /**
- * NOTE:
- * There is no doubt that there are header files, that already contain predefined logic
- * (_WIN32, _POSIX, etc), that could be used to determine respective environments.
- * There is also no doubt that there is always pros and cons, regarding using these predefined logics.
- * The overwhelming con: the ever evolving OSes. What about _WIN64, and _POSIX64? Besides, how lazy
- * are't though to not want to comment/uncomment a single line in order to make things work flawlessly?
- **/
- #define _WINDOWS 0x001
- #define _NIX 0x002
- /**
- * The program performs only two fundamental file operations: reading and writing (no appending, etc.).
- **/
- #define _FILE_READ 'r'
- #define _FILE_WRITE 'w'
- /**
- * Likewise, only two file flags are utilised.
- **/
- #define _FILE_READ_FLAG std::ios_base::in
- #define _FILE_WRITE_FLAG std::ios_base::out
- /*===============================================--=================================================
- (CCRYPT0) CLASS DEFINITION
- --------------------------------------------------------------------------------------------------*/
- class CCrypt0
- {
- /**
- * PUBLIC MEMBERS
- *
- * NOTE:
- * The members are arranged in the following specific order to adhere to standard coding
- * conventions.
- **/
- public:
- /**
- * The CCrypt0 class constructor.
- **/
- CCrypt0();
- /**
- * The CCrypt0 class destructor.
- **/
- ~CCrypt0();
- /**
- * FUNCTION PROTOTYPES
- *
- * The mainMenu function prototype.
- **/
- int mainMenu(void);
- /**
- * The encryptDecryptText/FileText function prototypes.
- **/
- void encryptDecryptText(void);
- void encryptDecryptFileText(void);
- /**
- * The outputMenu function prototype.
- **/
- void outputMenu(void);
- /**
- * The displayText function prototype.
- **/
- void displayText(void);
- /**
- * The doEncrypt/Decrypt function prototypes.
- **/
- inline void doEncrypt(void);
- inline void doDecrypt(void);
- /**
- * The fileNameEntry function prototype.
- *
- * NOTE:
- * Dynamic conventions are implemented in the code to make the program function as versatile
- * and efficient as possible: some functions take (lesser-used variables) parameters while,
- * the more fundamentally utilised variables are set in and retrieved from (private) variables
- * implemented in the (base) class itself. Then there is the issue of 'stack labour'.
- **/
- inline void fileNameEntry(char);
- /**
- * The readWriteText function prototype.
- **/
- void readWriteText(void);
- /**
- * The printFileWarningError function prototype.
- **/
- void printFileWarningError(void);
- /**
- * The clearScreen function prototype.
- **/
- void clearScreen(void);
- /**
- * Function to turn on/off console echo.
- **/
- void SetStdinEcho(bool);
- /**
- * NOTE:
- * The code implemented in the last two functions are definitely reusable and deserve their own
- * class. Their prototypes are declared in this class merely by convention and for efficiency.
- **/
- /**
- * ACCESSOR FUNCTIONS
- *
- * The set/getMainMenuOpt accessor functions.
- **/
- void setMainMenuOpt(char _mainMenuOpt){ mainMenuOpt = _mainMenuOpt; }
- char getMainMenuOpt(void){ return mainMenuOpt; }
- /**
- * The set/getFileName accessor functions.
- **/
- void setFileName(std::string *_fileNameBuffer){ fileName = *_fileNameBuffer; }
- std::string getFileName(void){ return fileName; }
- /**
- * The set/getFileFlag accessor functions.
- **/
- void setFileFlag(std::ios_base::openmode _fileFlag){ fileFlag = _fileFlag; }
- const std::ios_base::openmode getFileFlag(void){ return static_cast<const std::ios_base::openmode>(fileFlag); }
- /**
- * The set/getFileWarningError accessor functions.
- *
- * NOTE:
- * This concept is borrowed from, but is way superior to, the (unguarded) errno global
- * variable in C.
- **/
- void setFileWarningError(unsigned short _fileWarningError){ fileWarningError = _fileWarningError; }
- const unsigned short getFileWarningError(void){ return static_cast<const unsigned short>(fileWarningError); }
- /**
- * The set/getCryptBuffer accessor functions.
- **/
- void setCryptBuffer(std::string *_cryptBuffer){ cryptBuffer = *_cryptBuffer; }
- std::string getCryptBuffer(void){ return cryptBuffer; }
- /**
- * PRIVATE MEMBERS
- *
- * NOTE:
- * Merely variables paramount to the operations in the core of the program.
- **/
- private:
- char mainMenuOpt;
- std::string fileName;
- std::ios_base::openmode fileFlag;
- unsigned short fileWarningError;
- std::string cryptBuffer;
- protected:
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement