annotate enigma/enigma_utils.cpp @ 4:2792ca4ffa84

Created enigma_machine class and tests.
author Brian Neal <bgneal@gmail.com>
date Sun, 24 Jun 2012 18:39:05 -0500
parents
children 424111a36ed7
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 }