Commit 230c4877 authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

[API] moved demangle from DataTypes.h to demangle.h

parent 932f536b
......@@ -31,19 +31,6 @@
#include <string>
#include <type_traits>
#ifdef __GLIBCXX__
#define HAVE_CXXABI_H
#include <cxxabi.h>
#else
#ifdef __has_include
#if __has_include(<cxxabi.h>)
#define HAVE_CXXABI_H
#include <cxxabi.h>
#endif
#endif
#endif
namespace walberla {
......@@ -332,28 +319,6 @@ TypeToString(double)
template< typename T > inline const char* typeToString( T ) { return typeToString<T>(); }
// type info demangling
inline std::string demangle( const std::string & name )
{
#ifdef HAVE_CXXABI_H
int status = 0;
std::size_t size = 0;
const char * demangled = abi::__cxa_demangle( name.c_str(), NULL, &size, &status );
if( demangled == nullptr )
{
return name;
}
std::string demangled_str(demangled);
std::free( const_cast<char*>(demangled) );
return demangled_str;
#else
return name;
#endif
}
} // namespace walberla
#define WALBERLA_UNUSED(x) (void)(x)
......
......@@ -20,6 +20,7 @@
//======================================================================================================================
#include "PrintStacktrace.h"
#include "demangle.h"
#include "core/DataTypes.h"
#include <iostream>
......
//======================================================================================================================
//
// 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 demangle.h
//! \author Florian Schornbaum <florian.schornbaum@fau.de>
//
//======================================================================================================================
#pragma once
#include <string>
#ifdef __GLIBCXX__
#define HAVE_CXXABI_H
#include <cxxabi.h>
#else
#ifdef __has_include
#if __has_include(<cxxabi.h>)
#define HAVE_CXXABI_H
#include <cxxabi.h>
#endif
#endif
#endif
namespace walberla {
namespace debug {
inline std::string demangle( const std::string & name )
{
#ifdef HAVE_CXXABI_H
int status = 0;
std::size_t size = 0;
const char * demangled = abi::__cxa_demangle( name.c_str(), NULL, &size, &status );
if( demangled == nullptr )
{
return name;
}
std::string demangled_str(demangled);
std::free( const_cast<char*>(demangled) );
return demangled_str;
#else
return name;
#endif
}
} // namespace debug
} // namespace walberla
......@@ -25,6 +25,7 @@
#include "IBlockID.h"
#include "core/Abort.h"
#include "core/debug/demangle.h"
#include "core/NonCopyable.h"
#include "core/debug/Debug.h"
#include "core/math/AABB.h"
......@@ -103,8 +104,8 @@ public:
catch (...) {}
#ifndef NDEBUG
WALBERLA_ABORT( "BlockData access type violation! (The block data you added is of a different type than the block data you are trying to access!)"
"\nThe original data type was: " << demangle( typeInfo_ ) <<
"\nYou try to retrieve data of type: " << demangle( typeid(U).name() ) )
"\nThe original data type was: " << debug::demangle( typeInfo_ ) <<
"\nYou try to retrieve data of type: " << debug::demangle( typeid(U).name() ) )
#else
WALBERLA_ABORT( "BlockData access type violation! (The block data you added is of a different type than the block data you are trying to access!)" )
#endif
......
......@@ -28,6 +28,7 @@
//*************************************************************************************************
#include "core/Abort.h"
#include "core/debug/demangle.h"
#include "core/math/AABB.h"
#include "core/math/Vector3.h"
......@@ -57,7 +58,7 @@ void correctBodyPosition(const math::AABB& domain, const Vec3& center, Vec3& pos
template < class BodyT >
std::unique_ptr<BodyT> instantiate( mpi::RecvBuffer& /*buffer*/, const math::AABB& /*domain*/, const math::AABB& /*block*/, BodyT*& /*newBody*/ )
{
WALBERLA_ABORT( "Body instantiation not implemented! (" << demangle(typeid(BodyT).name()) << ")" );
WALBERLA_ABORT( "Body instantiation not implemented! (" << debug::demangle(typeid(BodyT).name()) << ")" );
}
} // namespace communication
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment