Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 1 | // (C) Copyright Gennadiy Rozental 2005-2008. |
| 2 | // Distributed under the Boost Software License, Version 1.0. |
| 3 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 4 | // http://www.boost.org/LICENSE_1_0.txt) |
| 5 | |
| 6 | // See http://www.boost.org/libs/test for the library home page. |
| 7 | // |
| 8 | // File : $RCSfile$ |
| 9 | // |
| 10 | // Version : $Revision: 49312 $ |
| 11 | // |
| 12 | // Description : simple helpers for creating cusom output manipulators |
| 13 | // *************************************************************************** |
| 14 | |
| 15 | #ifndef BOOST_TEST_CUSTOM_MANIP_HPP_071894GER |
| 16 | #define BOOST_TEST_CUSTOM_MANIP_HPP_071894GER |
| 17 | |
| 18 | // STL |
| 19 | #include <iosfwd> |
| 20 | |
| 21 | #include <ndnboost/test/detail/suppress_warnings.hpp> |
| 22 | |
| 23 | //____________________________________________________________________________// |
| 24 | |
| 25 | namespace ndnboost { |
| 26 | |
| 27 | namespace unit_test { |
| 28 | |
| 29 | // ************************************************************************** // |
| 30 | // ************** custom manipulators helpers ************** // |
| 31 | // ************************************************************************** // |
| 32 | |
| 33 | template<typename Manip> |
| 34 | struct custom_printer { |
| 35 | explicit custom_printer( std::ostream& ostr ) : m_ostr( &ostr ) {} |
| 36 | |
| 37 | std::ostream& operator*() const { return *m_ostr; } |
| 38 | |
| 39 | private: |
| 40 | std::ostream* const m_ostr; |
| 41 | }; |
| 42 | |
| 43 | //____________________________________________________________________________// |
| 44 | |
| 45 | template<typename Uniq> struct custom_manip {}; |
| 46 | |
| 47 | //____________________________________________________________________________// |
| 48 | |
| 49 | template<typename Uniq> |
| 50 | inline custom_printer<custom_manip<Uniq> > |
| 51 | operator<<( std::ostream& ostr, custom_manip<Uniq> const& ) { return custom_printer<custom_manip<Uniq> >( ostr ); } |
| 52 | |
| 53 | //____________________________________________________________________________// |
| 54 | |
| 55 | } // namespace unit_test |
| 56 | |
| 57 | } // namespace ndnboost |
| 58 | |
| 59 | //____________________________________________________________________________// |
| 60 | |
| 61 | #include <ndnboost/test/detail/enable_warnings.hpp> |
| 62 | |
| 63 | #endif // BOOST_TEST_CUSTOM_MANIP_HPP_071894GER |