Mercurial > public > cpp-enigma
annotate enigma/enigma_utils.cpp @ 21:42593b23e738 tip
Sigh, still messed up. Another attempt.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 11 Jul 2012 20:26:15 -0500 |
parents | 424111a36ed7 |
children |
rev | line source |
---|---|
bgneal@4 | 1 // Copyright (C) 2012 by Brian Neal. |
bgneal@4 | 2 // This file is part of Cpp-Enigma, the Enigma Machine simulation. |
bgneal@4 | 3 // Cpp-Enigma is released under the MIT License (see License.txt). |
bgneal@4 | 4 // |
bgneal@4 | 5 // enigma_utils.cpp - Implementation file for enigma_utils.h. |
bgneal@4 | 6 |
bgneal@4 | 7 #include "enigma_utils.h" |
bgneal@4 | 8 |
bgneal@4 | 9 std::string enigma::remove_spaces(const std::string& s) |
bgneal@4 | 10 { |
bgneal@4 | 11 std::string result; |
bgneal@4 | 12 result.reserve(s.size()); |
bgneal@4 | 13 |
bgneal@4 | 14 for (const auto& c : s) |
bgneal@4 | 15 { |
bgneal@4 | 16 if (c != ' ') |
bgneal@4 | 17 { |
bgneal@4 | 18 result += c; |
bgneal@4 | 19 } |
bgneal@4 | 20 } |
bgneal@4 | 21 return result; |
bgneal@4 | 22 } |
bgneal@12 | 23 |
bgneal@12 | 24 //////////////////////////////////////////////////////////////////////////////// |
bgneal@12 | 25 |
bgneal@12 | 26 std::string enigma::preprocess_ciphertext(const std::string& s) |
bgneal@12 | 27 { |
bgneal@12 | 28 std::string result; |
bgneal@12 | 29 result.reserve(s.size()); |
bgneal@12 | 30 |
bgneal@12 | 31 for (const auto& c : s) |
bgneal@12 | 32 { |
bgneal@12 | 33 if (c != ' ') |
bgneal@12 | 34 { |
bgneal@12 | 35 result += c - 'A'; |
bgneal@12 | 36 } |
bgneal@12 | 37 } |
bgneal@12 | 38 return result; |
bgneal@12 | 39 } |