comparison enigma/enigma_utils.h @ 4:2792ca4ffa84

Created enigma_machine class and tests.
author Brian Neal <bgneal@gmail.com>
date Sun, 24 Jun 2012 18:39:05 -0500
parents 1459e74fda3f
children 424111a36ed7
comparison
equal deleted inserted replaced
3:f4e25e6b76c3 4:2792ca4ffa84
3 // Copyright (C) 2012 by Brian Neal. 3 // Copyright (C) 2012 by Brian Neal.
4 // This file is part of Cpp-Enigma, the Enigma Machine simulation. 4 // This file is part of Cpp-Enigma, the Enigma Machine simulation.
5 // Cpp-Enigma is released under the MIT License (see License.txt). 5 // Cpp-Enigma is released under the MIT License (see License.txt).
6 // 6 //
7 // enigma_utils.h - This file contains common functions used throughout Cpp-Enigma. 7 // enigma_utils.h - This file contains common functions used throughout Cpp-Enigma.
8
9 #include <string>
8 10
9 namespace enigma 11 namespace enigma
10 { 12 {
11 // This version of mod acts like Python's with respect to negative dividends. 13 // This version of mod acts like Python's with respect to negative dividends.
12 inline int alpha_mod(int dividend) 14 inline int alpha_mod(int dividend)
15 { 17 {
16 dividend += 26; 18 dividend += 26;
17 } 19 }
18 return dividend % 26; 20 return dividend % 26;
19 } 21 }
22
23 // Removes spaces from a string and returns the resulting string:
24 std::string remove_spaces(const std::string& s);
20 } 25 }
21 26
22 #endif 27 #endif