BVB Source Codes

mars Show demangle.hpp Source code

Return Download mars: download demangle.hpp Source code - Download mars Source code - Type:.hpp
  1. #ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED
  2. #define BOOST_CORE_DEMANGLE_HPP_INCLUDED
  3.  
  4. // core::demangle
  5. //
  6. // Copyright 2014 Peter Dimov
  7. // Copyright 2014 Andrey Semashev
  8. //
  9. // Distributed under the Boost Software License, Version 1.0.
  10. // See accompanying file LICENSE_1_0.txt or copy at
  11. // http://www.boost.org/LICENSE_1_0.txt
  12.  
  13. #include <boost/config.hpp>
  14. #include <string>
  15.  
  16. #if defined(BOOST_HAS_PRAGMA_ONCE)
  17. # pragma once
  18. #endif
  19.  
  20. #if defined( __clang__ ) && defined( __has_include )
  21. # if __has_include(<cxxabi.h>)
  22. #  define BOOST_CORE_HAS_CXXABI_H
  23. # endif
  24. #elif defined( __GLIBCXX__ ) || defined( __GLIBCPP__ )
  25. # define BOOST_CORE_HAS_CXXABI_H
  26. #endif
  27.  
  28. #if defined( BOOST_CORE_HAS_CXXABI_H )
  29. # include <cxxabi.h>
  30. // For some archtectures (mips, mips64, x86, x86_64) cxxabi.h in Android NDK is implemented by gabi++ library
  31. // (https://android.googlesource.com/platform/ndk/+/master/sources/cxx-stl/gabi++/), which does not implement
  32. // abi::__cxa_demangle(). We detect this implementation by checking the include guard here.
  33. # if defined( __GABIXX_CXXABI_H__ )
  34. #  undef BOOST_CORE_HAS_CXXABI_H
  35. # else
  36. #  include <cstdlib>
  37. #  include <cstddef>
  38. # endif
  39. #endif
  40.  
  41. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost
  42. {
  43.  
  44. namespace core
  45. {
  46.  
  47. inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT;
  48. inline void demangle_free( char const * name ) BOOST_NOEXCEPT;
  49.  
  50. class scoped_demangled_name
  51. {
  52. private:
  53.     char const * m_p;
  54.  
  55. public:
  56.     explicit scoped_demangled_name( char const * name ) BOOST_NOEXCEPT :
  57.         m_p( demangle_alloc( name ) )
  58.     {
  59.     }
  60.  
  61.     ~scoped_demangled_name() BOOST_NOEXCEPT
  62.     {
  63.         demangle_free( m_p );
  64.     }
  65.  
  66.     char const * get() const BOOST_NOEXCEPT
  67.     {
  68.         return m_p;
  69.     }
  70.  
  71.     BOOST_DELETED_FUNCTION(scoped_demangled_name( scoped_demangled_name const& ))
  72.     BOOST_DELETED_FUNCTION(scoped_demangled_name& operator= ( scoped_demangled_name const& ))
  73. };
  74.  
  75.  
  76. #if defined( BOOST_CORE_HAS_CXXABI_H )
  77.  
  78. inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT
  79. {
  80.     int status = 0;
  81.     std::size_t size = 0;
  82.     return abi::__cxa_demangle( name, NULL, &size, &status );
  83. }
  84.  
  85. inline void demangle_free( char const * name ) BOOST_NOEXCEPT
  86. {
  87.     std::free( const_cast< char* >( name ) );
  88. }
  89.  
  90. inline std::string demangle( char const * name )
  91. {
  92.     scoped_demangled_name demangled_name( name );
  93.     char const * const p = demangled_name.get();
  94.     if( p )
  95.     {
  96.         return p;
  97.     }
  98.     else
  99.     {
  100.         return name;
  101.     }
  102. }
  103.  
  104. #else
  105.  
  106. inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT
  107. {
  108.     return name;
  109. }
  110.  
  111. inline void demangle_free( char const * ) BOOST_NOEXCEPT
  112. {
  113. }
  114.  
  115. inline std::string demangle( char const * name )
  116. {
  117.     return name;
  118. }
  119.  
  120. #endif
  121.  
  122. } // namespace core
  123.  
  124. } // namespace mars_boost
  125.  
  126. #undef BOOST_CORE_HAS_CXXABI_H
  127.  
  128. #endif // #ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED
  129.  
downloaddemangle.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top