BVB Source Codes

mars Show to_string_stub.hpp Source code

Return Download mars: download to_string_stub.hpp Source code - Download mars Source code - Type:.hpp
  1. //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
  2.  
  3. //Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5.  
  6. #ifndef UUID_E788439ED9F011DCB181F25B55D89593
  7. #define UUID_E788439ED9F011DCB181F25B55D89593
  8. #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  9. #pragma GCC system_header
  10. #endif
  11. #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  12. #pragma warning(push,1)
  13. #endif
  14.  
  15. #include <boost/exception/to_string.hpp>
  16. #include <boost/exception/detail/object_hex_dump.hpp>
  17. #include <boost/assert.hpp>
  18.  
  19. namespace mars_boost {} namespace boost = mars_boost; namespace
  20. mars_boost
  21.     {
  22.     namespace
  23.     exception_detail
  24.         {
  25.         template <bool ToStringAvailable>
  26.         struct
  27.         to_string_dispatcher
  28.             {
  29.             template <class T,class Stub>
  30.             static
  31.             std::string
  32.             convert( T const & x, Stub )
  33.                 {
  34.                 return to_string(x);
  35.                 }
  36.             };
  37.  
  38.         template <>
  39.         struct
  40.         to_string_dispatcher<false>
  41.             {
  42.             template <class T,class Stub>
  43.             static
  44.             std::string
  45.             convert( T const & x, Stub s )
  46.                 {
  47.                 return s(x);
  48.                 }
  49.  
  50.             template <class T>
  51.             static
  52.             std::string
  53.             convert( T const & x, std::string s )
  54.                 {
  55.                 return s;
  56.                 }
  57.  
  58.             template <class T>
  59.             static
  60.             std::string
  61.             convert( T const & x, char const * s )
  62.                 {
  63.                 BOOST_ASSERT(s!=0);
  64.                 return s;
  65.                 }
  66.             };
  67.  
  68.         namespace
  69.         to_string_dispatch
  70.             {
  71.             template <class T,class Stub>
  72.             inline
  73.             std::string
  74.             dispatch( T const & x, Stub s )
  75.                 {
  76.                 return to_string_dispatcher<has_to_string<T>::value>::convert(x,s);
  77.                 }
  78.             }
  79.  
  80.         template <class T>
  81.         inline
  82.         std::string
  83.         string_stub_dump( T const & x )
  84.             {
  85.             return "[ " + exception_detail::object_hex_dump(x) + " ]";
  86.             }
  87.         }
  88.  
  89.     template <class T>
  90.     inline
  91.     std::string
  92.     to_string_stub( T const & x )
  93.         {
  94.         return exception_detail::to_string_dispatch::dispatch(x,&exception_detail::string_stub_dump<T>);
  95.         }
  96.  
  97.     template <class T,class Stub>
  98.     inline
  99.     std::string
  100.     to_string_stub( T const & x, Stub s )
  101.         {
  102.         return exception_detail::to_string_dispatch::dispatch(x,s);
  103.         }
  104.  
  105.     template <class T,class U,class Stub>
  106.     inline
  107.     std::string
  108.     to_string_stub( std::pair<T,U> const & x, Stub s )
  109.         {
  110.         return std::string("(") + to_string_stub(x.first,s) + ',' + to_string_stub(x.second,s) + ')';
  111.         }
  112.     }
  113.  
  114. #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  115. #pragma warning(pop)
  116. #endif
  117. #endif
  118.  
downloadto_string_stub.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