Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:18

0001 // ----------------------------------------------------------------------------
0002 // Copyright (C) 2002-2007 Marcin Kalicinski
0003 // Copyright (C) 2007 Alexey Baskakov
0004 //
0005 // Distributed under the Boost Software License, Version 1.0. 
0006 // (See accompanying file LICENSE_1_0.txt or copy at 
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // For more information, see www.boost.org
0010 // ----------------------------------------------------------------------------
0011 #ifndef BOOST_PROPERTY_TREE_DETAIL_XML_PARSER_WRITER_SETTINGS_HPP_INCLUDED
0012 #define BOOST_PROPERTY_TREE_DETAIL_XML_PARSER_WRITER_SETTINGS_HPP_INCLUDED
0013 
0014 #include <string>
0015 #include <boost/property_tree/detail/ptree_utils.hpp>
0016 
0017 namespace boost { namespace property_tree { namespace xml_parser
0018 {
0019 
0020     // Naively convert narrow string to another character type
0021     template<class Str>
0022     Str widen(const char *text)
0023     {
0024         typedef typename Str::value_type Ch;
0025         Str result;
0026         while (*text)
0027         {
0028             result += Ch(*text);
0029             ++text;
0030         }
0031         return result;
0032     }
0033 
0034     //! Xml writer settings. The default settings lead to no pretty printing.
0035     template<class Str>
0036     class xml_writer_settings
0037     {
0038         typedef typename Str::value_type Ch;
0039     public:
0040         xml_writer_settings(Ch inchar = Ch(' '),
0041                 typename Str::size_type incount = 0,
0042                 const Str &enc = widen<Str>("utf-8"))
0043             : indent_char(inchar)
0044             , indent_count(incount)
0045             , encoding(enc)
0046         {
0047         }
0048 
0049         Ch indent_char;
0050         typename Str::size_type indent_count;
0051         Str encoding;
0052     };
0053 
0054     template <class Str>
0055     xml_writer_settings<Str> xml_writer_make_settings(typename Str::value_type indent_char = (typename Str::value_type)(' '),
0056         typename Str::size_type indent_count = 0,
0057         const Str &encoding = widen<Str>("utf-8"))
0058     {
0059         return xml_writer_settings<Str>(indent_char, indent_count, encoding);
0060     }
0061 
0062 } } }
0063 
0064 #endif