bgneal@0: #ifndef CPP_ENIGMA_ENIGMA_TYPES_H
bgneal@0: #define CPP_ENIGMA_ENIGMA_TYPES_H
bgneal@0: // Copyright (C) 2012 by Brian Neal.
bgneal@0: // This file is part of Cpp-Enigma, the Enigma Machine simulation.
bgneal@0: // Cpp-Enigma is released under the MIT License (see License.txt).
bgneal@0: //
bgneal@0: // enigma_types.h - This file contains common types used throughout Cpp-Enigma.
bgneal@0: 
bgneal@0: #include <exception>
bgneal@0: #include <string>
bgneal@1: #include <array>
bgneal@0: 
bgneal@0: namespace enigma
bgneal@0: {
bgneal@0:    class enigma_error : public std::exception
bgneal@0:    {
bgneal@0:    public:
bgneal@0:       explicit enigma_error(const std::string& what_arg)
bgneal@0:        : what_arg(what_arg)
bgneal@0:       {}
bgneal@0: 
bgneal@0:       virtual ~enigma_error() throw() {}
bgneal@0: 
bgneal@0:       virtual const char* what() const throw()
bgneal@0:       {
bgneal@0:          return what_arg.c_str();
bgneal@0:       }
bgneal@0: 
bgneal@0:    private:
bgneal@0:       std::string what_arg;
bgneal@0:    };
bgneal@1: 
bgneal@1:    // Arrays of 26 items are very commonly used:
bgneal@1:    typedef std::array<int, 26> alpha_int_array;
bgneal@1:    typedef std::array<bool, 26> alpha_bool_array;
bgneal@0: }
bgneal@0: 
bgneal@0: #endif