Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 1 | // (C) Copyright Gennadiy Rozental 2004-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 : basic_cstring i/o implementation |
| 13 | // *************************************************************************** |
| 14 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 15 | #ifndef NDNBOOST_TEST_BASIC_CSTRING_IO_HPP_071894GER |
| 16 | #define NDNBOOST_TEST_BASIC_CSTRING_IO_HPP_071894GER |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 17 | |
| 18 | // Boost.Test |
| 19 | #include <ndnboost/test/utils/basic_cstring/basic_cstring.hpp> |
| 20 | |
| 21 | // STL |
| 22 | #include <iosfwd> |
| 23 | #include <string> |
| 24 | |
| 25 | #include <ndnboost/test/detail/suppress_warnings.hpp> |
| 26 | |
| 27 | //____________________________________________________________________________// |
| 28 | |
| 29 | namespace ndnboost { |
| 30 | |
| 31 | namespace unit_test { |
| 32 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 33 | #ifdef NDNBOOST_CLASSIC_IOSTREAMS |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 34 | |
| 35 | template<typename CharT> |
| 36 | inline std::ostream& |
| 37 | operator<<( std::ostream& os, basic_cstring<CharT> const& str ) |
| 38 | { |
| 39 | typedef typename ut_detail::bcs_base_char<CharT>::type char_type; |
| 40 | char_type const* const beg = reinterpret_cast<char_type const* const>( str.begin() ); |
| 41 | char_type const* const end = reinterpret_cast<char_type const* const>( str.end() ); |
| 42 | os << std::basic_string<char_type>( beg, end - beg ); |
| 43 | |
| 44 | return os; |
| 45 | } |
| 46 | |
| 47 | #else |
| 48 | |
| 49 | template<typename CharT1, typename Tr,typename CharT2> |
| 50 | inline std::basic_ostream<CharT1,Tr>& |
| 51 | operator<<( std::basic_ostream<CharT1,Tr>& os, basic_cstring<CharT2> const& str ) |
| 52 | { |
| 53 | CharT1 const* const beg = reinterpret_cast<CharT1 const*>( str.begin() ); // !! |
| 54 | CharT1 const* const end = reinterpret_cast<CharT1 const*>( str.end() ); |
| 55 | os << std::basic_string<CharT1,Tr>( beg, end - beg ); |
| 56 | |
| 57 | return os; |
| 58 | } |
| 59 | |
| 60 | #endif |
| 61 | |
| 62 | //____________________________________________________________________________// |
| 63 | |
| 64 | |
| 65 | } // namespace unit_test |
| 66 | |
| 67 | } // namespace ndnboost |
| 68 | |
| 69 | //____________________________________________________________________________// |
| 70 | |
| 71 | #include <ndnboost/test/detail/enable_warnings.hpp> |
| 72 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 73 | #endif // NDNBOOST_TEST_BASIC_CSTRING_IO_HPP_071894GER |