From 94d3e79a8617f88dc0219cfdeedfa3147833719d Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 24 Jun 2019 14:43:36 +0200 Subject: Initialize at openlb-1-3 --- src/io/base64.cpp | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/io/base64.cpp (limited to 'src/io/base64.cpp') diff --git a/src/io/base64.cpp b/src/io/base64.cpp new file mode 100644 index 0000000..de373e0 --- /dev/null +++ b/src/io/base64.cpp @@ -0,0 +1,72 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2007 Jonas Latt + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "base64.h" +#include "base64.hh" + +namespace olb { + +// All of the following is a workaround to the following problem: on a +// 32-bit machine where unsigned int is the same as size_t, Base64Encoder +// needs to be instantiated on one integer type only. On some 64-bit +// platforms however, size_t is not equal to unsigned int. In that case, +// Base64Encoder needs to be instantiated twice. It is however not +// possible to instantiate this class first on unsigned int and then +// on size_t, because this yields a double instantiation, and thus +// an error, where these types are the same. To avoid this problem, +// the chosen instantiation types are unsigned int and size_t where +// these types are different, and unsigned char and unsigned int where +// they are similar. A template-based if-then-else construct is used +// to distinguish the two cases. + +template struct DistinctUint; + +template<> +struct DistinctUint { + typedef unsigned char T1; + typedef size_t T2; +}; + +template<> +struct DistinctUint { + typedef unsigned int T1; + typedef size_t T2; +}; + +typedef DistinctUint::T1 T1; +typedef DistinctUint::T2 T2; + +template class Base64Encoder; +template class Base64Encoder; +template class Base64Encoder; +template class Base64Encoder; +template class Base64Encoder; +template class Base64Encoder; + +template class Base64Decoder; +template class Base64Decoder; +template class Base64Decoder; +template class Base64Decoder; +template class Base64Decoder; + +} -- cgit v1.2.3