embedded_string_type.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2015.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file embedded_string_type.hpp
  9. * \author Andrey Semashev
  10. * \date 16.08.2009
  11. *
  12. * This header is the Boost.Log library implementation, see the library documentation
  13. * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
  14. */
  15. #ifndef BOOST_LOG_DETAIL_EMBEDDED_STRING_TYPE_HPP_INCLUDED_
  16. #define BOOST_LOG_DETAIL_EMBEDDED_STRING_TYPE_HPP_INCLUDED_
  17. #include <string>
  18. #include <boost/type_traits/remove_cv.hpp>
  19. #include <boost/log/detail/config.hpp>
  20. #include <boost/log/detail/header.hpp>
  21. #ifdef BOOST_HAS_PRAGMA_ONCE
  22. #pragma once
  23. #endif
  24. namespace boost {
  25. BOOST_LOG_OPEN_NAMESPACE
  26. namespace aux {
  27. template< typename T, typename ArgT >
  28. struct make_embedded_string_type_impl
  29. {
  30. typedef ArgT type;
  31. };
  32. template< typename ArgT >
  33. struct make_embedded_string_type_impl< char, ArgT >
  34. {
  35. typedef std::basic_string< char > type;
  36. };
  37. template< typename ArgT >
  38. struct make_embedded_string_type_impl< const char, ArgT >
  39. {
  40. typedef std::basic_string< char > type;
  41. };
  42. template< typename ArgT >
  43. struct make_embedded_string_type_impl< wchar_t, ArgT >
  44. {
  45. typedef std::basic_string< wchar_t > type;
  46. };
  47. template< typename ArgT >
  48. struct make_embedded_string_type_impl< const wchar_t, ArgT >
  49. {
  50. typedef std::basic_string< wchar_t > type;
  51. };
  52. #if !defined(BOOST_NO_CXX11_CHAR16_T)
  53. template< typename ArgT >
  54. struct make_embedded_string_type_impl< char16_t, ArgT >
  55. {
  56. typedef std::basic_string< char16_t > type;
  57. };
  58. template< typename ArgT >
  59. struct make_embedded_string_type_impl< const char16_t, ArgT >
  60. {
  61. typedef std::basic_string< char16_t > type;
  62. };
  63. #endif
  64. #if !defined(BOOST_NO_CXX11_CHAR32_T)
  65. template< typename ArgT >
  66. struct make_embedded_string_type_impl< char32_t, ArgT >
  67. {
  68. typedef std::basic_string< char32_t > type;
  69. };
  70. template< typename ArgT >
  71. struct make_embedded_string_type_impl< const char32_t, ArgT >
  72. {
  73. typedef std::basic_string< char32_t > type;
  74. };
  75. #endif
  76. //! An auxiliary type translator to store strings by value in function objects and attribute values
  77. template< typename ArgT >
  78. struct make_embedded_string_type :
  79. public remove_cv< ArgT >
  80. {
  81. };
  82. template< typename ArgT >
  83. struct make_embedded_string_type< ArgT* > :
  84. public make_embedded_string_type_impl< ArgT, ArgT* >
  85. {
  86. };
  87. template< typename ArgT, unsigned int CountV >
  88. struct make_embedded_string_type< ArgT[CountV] > :
  89. public make_embedded_string_type_impl< ArgT, ArgT[CountV] >
  90. {
  91. };
  92. template< typename ArgT, unsigned int CountV >
  93. struct make_embedded_string_type< ArgT(&)[CountV] > :
  94. public make_embedded_string_type_impl< ArgT, ArgT(&)[CountV] >
  95. {
  96. };
  97. } // namespace aux
  98. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  99. } // namespace boost
  100. #include <boost/log/detail/footer.hpp>
  101. #endif // BOOST_LOG_DETAIL_EMBEDDED_STRING_TYPE_HPP_INCLUDED_