]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/property_tree/include/boost/property_tree/detail/xml_parser_writer_settings.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / property_tree / include / boost / property_tree / detail / xml_parser_writer_settings.hpp
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
13
14 #include <string>
15 #include <boost/property_tree/detail/ptree_utils.hpp>
16
17 namespace boost { namespace property_tree { namespace xml_parser
18 {
19
20 // Naively convert narrow string to another character type
21 template<class Str>
22 Str widen(const char *text)
23 {
24 typedef typename Str::value_type Ch;
25 Str result;
26 while (*text)
27 {
28 result += Ch(*text);
29 ++text;
30 }
31 return result;
32 }
33
34 //! Xml writer settings. The default settings lead to no pretty printing.
35 template<class Str>
36 class xml_writer_settings
37 {
38 typedef typename Str::value_type Ch;
39 public:
40 xml_writer_settings(Ch inchar = Ch(' '),
41 typename Str::size_type incount = 0,
42 const Str &enc = widen<Str>("utf-8"))
43 : indent_char(inchar)
44 , indent_count(incount)
45 , encoding(enc)
46 {
47 }
48
49 Ch indent_char;
50 typename Str::size_type indent_count;
51 Str encoding;
52 };
53
54 template <class Str>
55 xml_writer_settings<Str> xml_writer_make_settings(typename Str::value_type indent_char = (typename Str::value_type)(' '),
56 typename Str::size_type indent_count = 0,
57 const Str &encoding = widen<Str>("utf-8"))
58 {
59 return xml_writer_settings<Str>(indent_char, indent_count, encoding);
60 }
61
62 } } }
63
64 #endif