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)
6 // See http://www.boost.org/libs/test for the library home page.
10 // Version : $Revision$
12 // Description : common code used by any agent serving as XML printer
13 // ***************************************************************************
15 #ifndef BOOST_TEST_XML_PRINTER_HPP_071894GER
16 #define BOOST_TEST_XML_PRINTER_HPP_071894GER
19 #include <boost/test/utils/basic_cstring/basic_cstring.hpp>
20 #include <boost/test/utils/fixed_mapping.hpp>
21 #include <boost/test/utils/custom_manip.hpp>
22 #include <boost/test/utils/foreach.hpp>
23 #include <boost/test/utils/basic_cstring/io.hpp>
26 #include <boost/config.hpp>
31 #include <boost/test/detail/suppress_warnings.hpp>
33 //____________________________________________________________________________//
39 // ************************************************************************** //
40 // ************** xml print helpers ************** //
41 // ************************************************************************** //
44 print_escaped( std::ostream& where_to, const_string value )
46 static fixed_mapping<char,char const*> char_type(
56 BOOST_TEST_FOREACH( char, c, value ) {
57 char const* ref = char_type[c];
60 where_to << '&' << ref << ';';
66 //____________________________________________________________________________//
69 print_escaped( std::ostream& where_to, std::string const& value )
71 print_escaped( where_to, const_string( value ) );
74 //____________________________________________________________________________//
78 print_escaped( std::ostream& where_to, T const& value )
83 //____________________________________________________________________________//
85 typedef custom_manip<struct attr_value_t> attr_value;
89 operator<<( custom_printer<attr_value> const& p, T const& value )
92 print_escaped( *p, value );
98 //____________________________________________________________________________//
100 typedef custom_manip<struct cdata_t> cdata;
103 operator<<( custom_printer<cdata> const& p, const_string value )
105 return *p << BOOST_TEST_L( "<![CDATA[" ) << value << BOOST_TEST_L( "]]>" );
108 //____________________________________________________________________________//
110 } // namespace unit_test
114 //____________________________________________________________________________//
116 #include <boost/test/detail/enable_warnings.hpp>
118 #endif // BOOST_TEST_XML_PRINTER_HPP_071894GER