summaryrefslogtreecommitdiff
path: root/libs/log/test/common/attr_comparison.hpp
blob: b4be4f484c2aaf318f435a66f6546a185e81dbef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 *          Copyright Andrey Semashev 2007 - 2015.
 * Distributed under the Boost Software License, Version 1.0.
 *    (See accompanying file LICENSE_1_0.txt or copy at
 *          http://www.boost.org/LICENSE_1_0.txt)
 */
/*!
 * \file   attr_comparison.hpp
 * \author Andrey Semashev
 * \date   06.08.2010
 *
 * \brief  This header contains tools for attribute comparison in attribute-related tests.
 */

#ifndef BOOST_LOG_TESTS_ATTR_COMPARISON_HPP_INCLUDED_
#define BOOST_LOG_TESTS_ATTR_COMPARISON_HPP_INCLUDED_

#include <ostream>
#include <boost/log/attributes/attribute.hpp>

class attribute_factory_helper :
    public boost::log::attribute
{
    typedef boost::log::attribute base_type;

public:
    attribute_factory_helper(base_type const& that) : base_type(that)
    {
    }

    impl* get_impl() const
    {
        return base_type::get_impl();
    }
};

namespace boost {

BOOST_LOG_OPEN_NAMESPACE

inline bool operator== (attribute const& left, attribute const& right)
{
    return attribute_factory_helper(left).get_impl() == attribute_factory_helper(right).get_impl();
}
inline bool operator!= (attribute const& left, attribute const& right)
{
    return attribute_factory_helper(left).get_impl() != attribute_factory_helper(right).get_impl();
}

inline std::ostream& operator<< (std::ostream& strm, attribute const& val)
{
    strm << attribute_factory_helper(val).get_impl();
    return strm;
}

BOOST_LOG_CLOSE_NAMESPACE // namespace log

} // namespace boost

#endif // BOOST_LOG_TESTS_ATTR_COMPARISON_HPP_INCLUDED_