/*
 * 2004 Utah High School Programming Contest, University of Utah
 * Take-Home Problem
 *
 * Decrypt.hpp
 *
 * This file contains the definition of the Decrypt class.
 */

#ifndef DECRYPT_HPP
#define DECRYPT_HPP

#include "Dictionary.hpp"

#include <string>

using namespace std;

/**
 * This is the "main class" of the program: it contains the top-level objects
 * and methods.  Its `main' method implements the overall program logic, but
 * all the real work is performed by helper methods and other objects.  The
 * required C++ `main' function, defined in `main.cpp', simply invokes the main
 * method of this class.
 */
class Decrypt {
private:
    /**
     * The "default dictionary" for solving cryptograms.  This is initialized
     * from the "raw word array" in the Words class.  This dictionary is used
     * by the `decrypt' method in this class in order to make Puzzle objects.
     */
    static const Dictionary DICT;
    
public:
    /**
     * This method implements the overall program logic.  It processes the
     * command line arguments, reads the input cryptogram file, deciphers the
     * cryptogram, and outputs the decoded result.
     *
     * @param argc    the number of command line arguments
     * @param argv    the array of command line arguments (strings)
     */
    static int main(int argc, char *argv[]);
    
    /**
     * This method reads the contents of a file into a given string.  If the
     * file is read successfully, this method returns `true'.  Otherwise, this
     * method prints an error message (to `cerr') and returns `false'.
     *
     * @param filename    the name of the file to be read
     * @param contents    the string that the file contents will be read into
     * @return            true if the file was read successfully, false if not
     */
    static bool read_file(const char* filename, string& contents);
    
    /**
     * This method runs the steps required to decipher a given cryptogram.  The
     * parameter given to this method is modified and decrypted.
     *
     * @param cryptogram    the string containing the encrypted message.  This
     *                      string is modified to contain the decrypted
     *                      message.
     */
    static void decrypt(string& cryptogram);
};

#endif // DECRYPT_HPP

// End of file.

