From cd9c77b98b710b59effc97e9a94b09fe2ae8ca00 Mon Sep 17 00:00:00 2001 From: Sebastian Eibl <sebastian.eibl@fau.de> Date: Mon, 15 Jun 2020 14:46:14 +0200 Subject: [PATCH] [API] move typeToString to own file --- src/blockforest/SetupBlockForest.cpp | 1 + src/core/DataTypes.h | 29 ----------- src/core/typeToString.h | 52 +++++++++++++++++++ .../containment_octree/ContainmentOctree.h | 1 + .../distance_octree/DistanceOctree.h | 2 + 5 files changed, 56 insertions(+), 29 deletions(-) create mode 100644 src/core/typeToString.h diff --git a/src/blockforest/SetupBlockForest.cpp b/src/blockforest/SetupBlockForest.cpp index b57abcccf..449e8bea3 100644 --- a/src/blockforest/SetupBlockForest.cpp +++ b/src/blockforest/SetupBlockForest.cpp @@ -34,6 +34,7 @@ #include "core/debug/CheckFunctions.h" #include "core/logging/Logging.h" #include "core/math/Sample.h" +#include "core/typeToString.h" #include "domain_decomposition/MapPointToPeriodicDomain.h" diff --git a/src/core/DataTypes.h b/src/core/DataTypes.h index f90781461..5694e7fbc 100644 --- a/src/core/DataTypes.h +++ b/src/core/DataTypes.h @@ -290,35 +290,6 @@ inline bool floatIsEqual( float lhs, float rhs, const float epsilon = real_compa return std::fabs( lhs - rhs ) < epsilon; } - - -// data type to string conversion - -template< typename T > inline const char* typeToString(); - -#define TypeToString(X) template<> inline const char* typeToString< X >() { \ - static char string[] = #X; \ - return string; \ -} - -TypeToString(bool) -TypeToString(char) -TypeToString(short) -TypeToString(int) -TypeToString(long) -TypeToString(long long) -TypeToString(unsigned char) -TypeToString(unsigned short) -TypeToString(unsigned int) -TypeToString(unsigned long) -TypeToString(unsigned long long) -TypeToString(float) -TypeToString(double) - -#undef TypeToString - -template< typename T > inline const char* typeToString( T ) { return typeToString<T>(); } - } // namespace walberla #define WALBERLA_UNUSED(x) (void)(x) diff --git a/src/core/typeToString.h b/src/core/typeToString.h new file mode 100644 index 000000000..ca49ecefa --- /dev/null +++ b/src/core/typeToString.h @@ -0,0 +1,52 @@ +//====================================================================================================================== +// +// This file is part of waLBerla. waLBerla 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 3 of +// the License, or (at your option) any later version. +// +// waLBerla 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 waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file typeToString.h +//! \author Florian Schornbaum <florian.schornbaum@fau.de> +// +//====================================================================================================================== + +#pragma once + +namespace walberla { + +// data type to string conversion + +template< typename T > inline const char* typeToString(); + +#define TypeToString(X) template<> inline const char* typeToString< X >() { \ + static char string[] = #X; \ + return string; \ +} + +TypeToString(bool) +TypeToString(char) +TypeToString(short) +TypeToString(int) +TypeToString(long) +TypeToString(long long) +TypeToString(unsigned char) +TypeToString(unsigned short) +TypeToString(unsigned int) +TypeToString(unsigned long) +TypeToString(unsigned long long) +TypeToString(float) +TypeToString(double) + +#undef TypeToString + +template< typename T > inline const char* typeToString( T ) { return typeToString<T>(); } + +} // namespace walberla diff --git a/src/geometry/containment_octree/ContainmentOctree.h b/src/geometry/containment_octree/ContainmentOctree.h index f83014c05..96d091c00 100644 --- a/src/geometry/containment_octree/ContainmentOctree.h +++ b/src/geometry/containment_octree/ContainmentOctree.h @@ -30,6 +30,7 @@ #include "core/DataTypes.h" #include "core/math/GenericAABB.h" #include "core/math/KahanSummation.h" +#include "core/typeToString.h" #include <queue> #include <vector> diff --git a/src/mesh_common/distance_octree/DistanceOctree.h b/src/mesh_common/distance_octree/DistanceOctree.h index 2c34b9c6c..ce1a21c16 100644 --- a/src/mesh_common/distance_octree/DistanceOctree.h +++ b/src/mesh_common/distance_octree/DistanceOctree.h @@ -33,6 +33,8 @@ #include "core/math/GenericAABB.h" #include "core/math/Vector3.h" +#include "core/typeToString.h" + #include <vector> #include <queue> -- GitLab