| 42 | // ************************************************************************** // |
| 43 | |
| 44 | inline void |
| 45 | print_escaped( std::ostream& where_to, const_string value ) |
| 46 | { |
| 47 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) |
| 48 | static std::map<char,char const*> const char_type{{ |
| 49 | {'<' , "lt"}, |
| 50 | {'>' , "gt"}, |
| 51 | {'&' , "amp"}, |
| 52 | {'\'', "apos"}, |
| 53 | {'"' , "quot"} |
| 54 | }}; |
| 55 | #else |
| 56 | static std::map<char,char const*> char_type; |
| 57 | |
| 58 | if( char_type.empty() ) { |
| 59 | char_type['<'] = "lt"; |
| 60 | char_type['>'] = "gt"; |
| 61 | char_type['&'] = "amp"; |
| 62 | char_type['\'']= "apos"; |
| 63 | char_type['"'] = "quot"; |
| 64 | } |
| 65 | #endif |
| 66 | |
| 67 | BOOST_TEST_FOREACH( char, c, value ) { |
| 68 | std::map<char,char const*>::const_iterator found_ref = char_type.find( c ); |
| 69 | |
| 70 | if( found_ref != char_type.end() ) |
| 71 | where_to << '&' << found_ref->second << ';'; |
| 72 | else |
| 73 | where_to << c; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | //____________________________________________________________________________// |
| 78 | |