xml_printer.hpp
来自「Boost provides free peer-reviewed portab」· HPP 代码 · 共 120 行
HPP
120 行
// (C) Copyright Gennadiy Rozental 2004-2008.// 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)// See http://www.boost.org/libs/test for the library home page.//// File : $RCSfile$//// Version : $Revision: 49312 $//// Description : common code used by any agent serving as XML printer// ***************************************************************************#ifndef BOOST_TEST_XML_PRINTER_HPP_071894GER#define BOOST_TEST_XML_PRINTER_HPP_071894GER// Boost.Test#include <boost/test/utils/basic_cstring/basic_cstring.hpp>#include <boost/test/utils/fixed_mapping.hpp>#include <boost/test/utils/custom_manip.hpp>#include <boost/test/utils/foreach.hpp>// Boost#include <boost/config.hpp>// STL#include <iostream>#include <boost/test/detail/suppress_warnings.hpp>//____________________________________________________________________________//namespace boost {namespace unit_test {// ************************************************************************** //// ************** xml print helpers ************** //// ************************************************************************** //inline voidprint_escaped( std::ostream& where_to, const_string value ){ static fixed_mapping<char,char const*> char_type( '<' , "lt", '>' , "gt", '&' , "amp", '\'', "apos" , '"' , "quot", 0 ); BOOST_TEST_FOREACH( char, c, value ) { char const* ref = char_type[c]; if( ref ) where_to << '&' << ref << ';'; else where_to << c; }}//____________________________________________________________________________//inline voidprint_escaped( std::ostream& where_to, std::string const& value ){ print_escaped( where_to, const_string( value ) );}//____________________________________________________________________________//template<typename T>inline voidprint_escaped( std::ostream& where_to, T const& value ){ where_to << value;}//____________________________________________________________________________//typedef custom_manip<struct attr_value_t> attr_value;template<typename T>inline std::ostream&operator<<( custom_printer<attr_value> const& p, T const& value ){ *p << "=\""; print_escaped( *p, value ); *p << '"'; return *p;}//____________________________________________________________________________//typedef custom_manip<struct pcdata_t> pcdata;inline std::ostream&operator<<( custom_printer<pcdata> const& p, const_string value ){ print_escaped( *p, value ); return *p;}//____________________________________________________________________________//} // namespace unit_test} // namespace boost//____________________________________________________________________________//#include <boost/test/detail/enable_warnings.hpp>#endif // BOOST_TEST_XML_PRINTER_HPP_071894GER
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?