string_from_type.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2015.
  6. // Modifications copyright (c) 2015, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  8. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  9. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  10. // Use, modification and distribution is subject to the Boost Software License,
  11. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. #ifndef GEOMETRY_TEST_STRING_FROM_TYPE_HPP
  14. #define GEOMETRY_TEST_STRING_FROM_TYPE_HPP
  15. #include <string>
  16. #if defined(HAVE_TTMATH)
  17. # include <boost/geometry/extensions/contrib/ttmath_stub.hpp>
  18. #endif
  19. #if defined(HAVE_CLN) || defined(HAVE_GMP)
  20. # include <boost/numeric_adaptor/numeric_adaptor.hpp>
  21. #endif
  22. #if defined(HAVE_GMP)
  23. # include <boost/numeric_adaptor/gmp_value_type.hpp>
  24. #endif
  25. #if defined(HAVE_CLN)
  26. # include <boost/numeric_adaptor/cln_value_type.hpp>
  27. #endif
  28. template <typename T>
  29. struct string_from_type {};
  30. template <> struct string_from_type<void>
  31. { static std::string name() { return "v"; } };
  32. template <> struct string_from_type<float>
  33. { static std::string name() { return "f"; } };
  34. template <> struct string_from_type<double>
  35. { static std::string name() { return "d"; } };
  36. template <> struct string_from_type<long double>
  37. { static std::string name() { return "e"; } };
  38. template <> struct string_from_type<short int>
  39. { static std::string name() { return "s"; } };
  40. template <> struct string_from_type<int>
  41. { static std::string name() { return "i"; } };
  42. template <> struct string_from_type<long>
  43. { static std::string name() { return "l"; } };
  44. #if defined(BOOST_HAS_LONG_LONG)
  45. // this is what g++ and clang++ use
  46. template <> struct string_from_type<boost::long_long_type>
  47. { static std::string name() { return "x"; } };
  48. #endif
  49. #if defined(BOOST_HAS_INT128)
  50. // this is what g++ and clang++ use
  51. template <> struct string_from_type<boost::int128_type>
  52. { static std::string name() { return "n"; } };
  53. #endif
  54. #if defined(HAVE_TTMATH)
  55. template <> struct string_from_type<ttmath_big>
  56. { static std::string name() { return "t"; } };
  57. #endif
  58. #if defined(BOOST_RATIONAL_HPP)
  59. template <typename T> struct string_from_type<boost::rational<T> >
  60. { static std::string name() { return "r"; } };
  61. #endif
  62. #if defined(HAVE_GMP)
  63. template <> struct string_from_type<boost::numeric_adaptor::gmp_value_type>
  64. { static std::string name() { return "g"; } };
  65. #endif
  66. #if defined(HAVE_CLN)
  67. template <> struct string_from_type<boost::numeric_adaptor::cln_value_type>
  68. { static std::string name() { return "c"; } };
  69. #endif
  70. #endif // GEOMETRY_TEST_STRING_FROM_TYPE_HPP