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