• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   attr_comparison.hpp
9  * \author Andrey Semashev
10  * \date   06.08.2010
11  *
12  * \brief  This header contains tools for attribute comparison in attribute-related tests.
13  */
14 
15 #ifndef BOOST_LOG_TESTS_ATTR_COMPARISON_HPP_INCLUDED_
16 #define BOOST_LOG_TESTS_ATTR_COMPARISON_HPP_INCLUDED_
17 
18 #include <ostream>
19 #include <boost/log/attributes/attribute.hpp>
20 
21 class attribute_factory_helper :
22     public boost::log::attribute
23 {
24     typedef boost::log::attribute base_type;
25 
26 public:
attribute_factory_helper(base_type const & that)27     attribute_factory_helper(base_type const& that) : base_type(that)
28     {
29     }
30 
get_impl() const31     impl* get_impl() const
32     {
33         return base_type::get_impl();
34     }
35 };
36 
37 namespace boost {
38 
39 BOOST_LOG_OPEN_NAMESPACE
40 
operator ==(attribute const & left,attribute const & right)41 inline bool operator== (attribute const& left, attribute const& right)
42 {
43     return attribute_factory_helper(left).get_impl() == attribute_factory_helper(right).get_impl();
44 }
operator !=(attribute const & left,attribute const & right)45 inline bool operator!= (attribute const& left, attribute const& right)
46 {
47     return attribute_factory_helper(left).get_impl() != attribute_factory_helper(right).get_impl();
48 }
49 
operator <<(std::ostream & strm,attribute const & val)50 inline std::ostream& operator<< (std::ostream& strm, attribute const& val)
51 {
52     strm << attribute_factory_helper(val).get_impl();
53     return strm;
54 }
55 
56 BOOST_LOG_CLOSE_NAMESPACE // namespace log
57 
58 } // namespace boost
59 
60 #endif // BOOST_LOG_TESTS_ATTR_COMPARISON_HPP_INCLUDED_
61