From b55bdc9c0bb68236aa2de0a8eaec9f4c80cc2769 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Wed, 5 Sep 2018 23:54:48 +0200 Subject: Code style and clarity. --- tests/utility/encoder/encoderTestUtils.hpp | 31 ++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'tests/utility/encoder/encoderTestUtils.hpp') diff --git a/tests/utility/encoder/encoderTestUtils.hpp b/tests/utility/encoder/encoderTestUtils.hpp index d74c4709..cc1141c7 100644 --- a/tests/utility/encoder/encoderTestUtils.hpp +++ b/tests/utility/encoder/encoderTestUtils.hpp @@ -1,6 +1,6 @@ // // VMime library (http://www.vmime.org) -// Copyright (C) 2002-2013 Vincent Richard +// Copyright (C) 2002 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -23,25 +23,32 @@ // Helper function to obtain an encoder given its name -static vmime::shared_ptr getEncoder(const vmime::string& name, - int maxLineLength = 0, const vmime::propertySet props = vmime::propertySet()) -{ +static vmime::shared_ptr getEncoder( + const vmime::string& name, + int maxLineLength = 0, + const vmime::propertySet props = vmime::propertySet() +) { + vmime::shared_ptr enc = vmime::utility::encoder::encoderFactory::getInstance()->create(name); enc->getProperties() = props; - if (maxLineLength != 0) + if (maxLineLength != 0) { enc->getProperties()["maxlinelength"] = maxLineLength; + } return enc; } // Encoding helper function -static const vmime::string encode(const vmime::string& name, const vmime::string& in, - int maxLineLength = 0, const vmime::propertySet props = vmime::propertySet()) -{ +static const vmime::string encode( + const vmime::string& name, const vmime::string& in, + int maxLineLength = 0, + const vmime::propertySet props = vmime::propertySet() +) { + vmime::shared_ptr enc = getEncoder(name, maxLineLength, props); vmime::utility::inputStreamStringAdapter vin(in); @@ -56,8 +63,12 @@ static const vmime::string encode(const vmime::string& name, const vmime::string // Decoding helper function -static const vmime::string decode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0) -{ +static const vmime::string decode( + const vmime::string& name, + const vmime::string& in, + int maxLineLength = 0 +) { + vmime::shared_ptr enc = getEncoder(name, maxLineLength); vmime::utility::inputStreamStringAdapter vin(in); -- cgit v1.2.3