fix doc example typo
[boost.git] / boost / property_tree / detail / xml_parser_writer_settings.hpp
blobcb265ee4778bc348e00a7be95ef4b5596c6dd7b1
1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2002-2007 Marcin Kalicinski
3 // Copyright (C) 2007 Alexey Baskakov
4 //
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // For more information, see www.boost.org
10 // ----------------------------------------------------------------------------
11 #ifndef BOOST_PROPERTY_TREE_DETAIL_XML_PARSER_WRITER_SETTINGS_HPP_INCLUDED
12 #define BOOST_PROPERTY_TREE_DETAIL_XML_PARSER_WRITER_SETTINGS_HPP_INCLUDED
14 #include <string>
15 #include <boost/property_tree/detail/ptree_utils.hpp>
17 namespace boost { namespace property_tree { namespace xml_parser
20 // Naively convert narrow string to another character type
21 template<class Ch>
22 std::basic_string<Ch> widen(const char *text)
24 std::basic_string<Ch> result;
25 while (*text)
27 result += Ch(*text);
28 ++text;
30 return result;
33 //! Xml writer settings
34 template<class Ch>
35 class xml_writer_settings
37 public:
38 xml_writer_settings(Ch indent_char = Ch(' '),
39 typename std::basic_string<Ch>::size_type indent_count = 4,
40 const std::basic_string<Ch> &encoding = widen<Ch>("utf-8"))
41 : indent_char(indent_char)
42 , indent_count(indent_count)
43 , encoding(encoding)
47 const Ch indent_char;
48 const typename std::basic_string<Ch>::size_type indent_count;
49 const std::basic_string<Ch> encoding;
52 template <class Ch>
53 xml_writer_settings<Ch> xml_writer_make_settings(Ch indent_char, typename std::basic_string<Ch>::size_type indent_count, const Ch *encoding)
55 return xml_writer_settings<Ch>(indent_char, indent_count, encoding);
58 } } }
60 #endif