Mercurial > public > cpp-enigma
annotate enigma/enigma_types.h @ 15:9e02d8696e67
Added enigma_machine::step().
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 04 Jul 2012 19:52:41 -0500 |
parents | 1459e74fda3f |
children |
rev | line source |
---|---|
bgneal@0 | 1 #ifndef CPP_ENIGMA_ENIGMA_TYPES_H |
bgneal@0 | 2 #define CPP_ENIGMA_ENIGMA_TYPES_H |
bgneal@0 | 3 // Copyright (C) 2012 by Brian Neal. |
bgneal@0 | 4 // This file is part of Cpp-Enigma, the Enigma Machine simulation. |
bgneal@0 | 5 // Cpp-Enigma is released under the MIT License (see License.txt). |
bgneal@0 | 6 // |
bgneal@0 | 7 // enigma_types.h - This file contains common types used throughout Cpp-Enigma. |
bgneal@0 | 8 |
bgneal@0 | 9 #include <exception> |
bgneal@0 | 10 #include <string> |
bgneal@1 | 11 #include <array> |
bgneal@0 | 12 |
bgneal@0 | 13 namespace enigma |
bgneal@0 | 14 { |
bgneal@0 | 15 class enigma_error : public std::exception |
bgneal@0 | 16 { |
bgneal@0 | 17 public: |
bgneal@0 | 18 explicit enigma_error(const std::string& what_arg) |
bgneal@0 | 19 : what_arg(what_arg) |
bgneal@0 | 20 {} |
bgneal@0 | 21 |
bgneal@0 | 22 virtual ~enigma_error() throw() {} |
bgneal@0 | 23 |
bgneal@0 | 24 virtual const char* what() const throw() |
bgneal@0 | 25 { |
bgneal@0 | 26 return what_arg.c_str(); |
bgneal@0 | 27 } |
bgneal@0 | 28 |
bgneal@0 | 29 private: |
bgneal@0 | 30 std::string what_arg; |
bgneal@0 | 31 }; |
bgneal@1 | 32 |
bgneal@1 | 33 // Arrays of 26 items are very commonly used: |
bgneal@1 | 34 typedef std::array<int, 26> alpha_int_array; |
bgneal@1 | 35 typedef std::array<bool, 26> alpha_bool_array; |
bgneal@0 | 36 } |
bgneal@0 | 37 |
bgneal@0 | 38 #endif |