#ifndef GUARD_code_h
#define GUARD_code_h
#include<string>
#include<vector>
#include<map>

		
/****************************************************************************
 * This class maintains a letter substitution code by storing two maps from 'char'
 * to 'char'. Each represents a partial substitution code in which each letter is
 * coded as a different letter, though some letters may not have a code value 
 * available. 
 *
 * The maps are inverses of each other, in the sense the each decodes the other's
 * code.
 * ****************************************************************************/


/* Should any more of these functions be designated const with respect to the 
 * calling object? Should we write any constructors?
 */

bool process_pair(std::string& s1, std::string& s2);// Checks that non-alpha's match.
					  // Makes alpha's uppercase
class Code
{
	std::map<char,char> code_key;//encryption key
	std::map<char,char> reverse_key;//decryption key				
	bool add_pair(char base, char codeIt);//Adds a pair to the code if it 
					      //doesn't conflict with existing
					      //pairs.	

	public:
	bool load(std::string string1, std::string string2);//Treat string2 as encoding
       					          //string1. If that's valid,
						  //insert the corresponding 
						  //character pairs into the code.	
	void show() const;// display the code key. The const after the parameter	
			  // list says that this function doesn't change the
			  // calling object. 
	
	void unload(std::string s);//remove the characters in the string from the 
				//set of keys.
	void clear(); //Empty both maps.
	bool change(char base,char codeIt);//Change the coded value of base to
					  //codeIt, if its not already in use.
	void random(); //Load a randomly generated letter substitution code.
	std::string apply(const std::string& plain);// Encode input according to code_key, with '-' for uncoded letters.
	std::string apply_reverse(const std::string& coded);// Decode input string.
	int code_size();// Return the number of characters with code values.
	void invert();
	bool encryptable(const std::string& s); //Returns true if all characters in s
						//have code values in code_key, false otherwise.

	
};

#endif

				
			
			
			
				
				

				
				
		
