basic_sink_backend.hpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 basic_sink_backend.hpp
  9. * \author Andrey Semashev
  10. * \date 04.11.2007
  11. *
  12. * The header contains implementation of base classes for sink backends.
  13. */
  14. #ifndef BOOST_LOG_SINKS_BASIC_SINK_BACKEND_HPP_INCLUDED_
  15. #define BOOST_LOG_SINKS_BASIC_SINK_BACKEND_HPP_INCLUDED_
  16. #include <string>
  17. #include <boost/type_traits/is_same.hpp>
  18. #include <boost/log/detail/config.hpp>
  19. #include <boost/log/sinks/frontend_requirements.hpp>
  20. #include <boost/log/core/record_view.hpp>
  21. #include <boost/log/attributes/attribute_value_set.hpp>
  22. #include <boost/log/detail/header.hpp>
  23. #ifdef BOOST_HAS_PRAGMA_ONCE
  24. #pragma once
  25. #endif
  26. namespace boost {
  27. BOOST_LOG_OPEN_NAMESPACE
  28. namespace sinks {
  29. /*!
  30. * \brief Base class for a logging sink backend
  31. *
  32. * The \c basic_sink_backend class template defines a number of types that
  33. * all sink backends are required to define. All sink backends have to derive from the class.
  34. */
  35. template< typename FrontendRequirementsT >
  36. struct basic_sink_backend
  37. {
  38. //! Frontend requirements tag
  39. typedef FrontendRequirementsT frontend_requirements;
  40. BOOST_DEFAULTED_FUNCTION(basic_sink_backend(), {})
  41. BOOST_DELETED_FUNCTION(basic_sink_backend(basic_sink_backend const&))
  42. BOOST_DELETED_FUNCTION(basic_sink_backend& operator= (basic_sink_backend const&))
  43. };
  44. /*!
  45. * \brief A base class for a logging sink backend with message formatting support
  46. *
  47. * The \c basic_formatted_sink_backend class template indicates to the frontend that
  48. * the backend requires logging record formatting.
  49. *
  50. * The class allows to request encoding conversion in case if the sink backend
  51. * requires the formatted string in some particular encoding (e.g. if underlying API
  52. * supports only narrow or wide characters). In order to perform conversion one
  53. * should specify the desired final character type in the \c TargetCharT template
  54. * parameter.
  55. */
  56. template<
  57. typename CharT,
  58. typename FrontendRequirementsT = synchronized_feeding
  59. >
  60. struct basic_formatted_sink_backend :
  61. public basic_sink_backend<
  62. typename combine_requirements< FrontendRequirementsT, formatted_records >::type
  63. >
  64. {
  65. private:
  66. typedef basic_sink_backend<
  67. typename combine_requirements< FrontendRequirementsT, formatted_records >::type
  68. > base_type;
  69. public:
  70. //! Character type
  71. typedef CharT char_type;
  72. //! Formatted string type
  73. typedef std::basic_string< char_type > string_type;
  74. //! Frontend requirements
  75. typedef typename base_type::frontend_requirements frontend_requirements;
  76. };
  77. } // namespace sinks
  78. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  79. } // namespace boost
  80. #include <boost/log/detail/footer.hpp>
  81. #endif // BOOST_LOG_SINKS_BASIC_SINK_BACKEND_HPP_INCLUDED_