Chris@16
|
1 // ----------------------------------------------------------------------------
|
Chris@16
|
2 // Copyright (C) 2002-2006 Marcin Kalicinski
|
Chris@16
|
3 // Copyright (C) 2009 Sebastian Redl
|
Chris@16
|
4 //
|
Chris@16
|
5 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
6 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 //
|
Chris@16
|
9 // For more information, see www.boost.org
|
Chris@16
|
10 // ----------------------------------------------------------------------------
|
Chris@16
|
11 #ifndef BOOST_PROPERTY_TREE_PTREE_FWD_HPP_INCLUDED
|
Chris@16
|
12 #define BOOST_PROPERTY_TREE_PTREE_FWD_HPP_INCLUDED
|
Chris@16
|
13
|
Chris@16
|
14 #include <boost/config.hpp>
|
Chris@16
|
15 #include <boost/optional/optional_fwd.hpp>
|
Chris@16
|
16 #include <boost/throw_exception.hpp>
|
Chris@16
|
17 #include <functional> // for std::less
|
Chris@16
|
18 #include <memory> // for std::allocator
|
Chris@16
|
19 #include <string>
|
Chris@16
|
20
|
Chris@16
|
21 namespace boost { namespace property_tree
|
Chris@16
|
22 {
|
Chris@16
|
23 namespace detail {
|
Chris@16
|
24 template <typename T> struct less_nocase;
|
Chris@16
|
25 }
|
Chris@16
|
26
|
Chris@16
|
27 // Classes
|
Chris@16
|
28
|
Chris@16
|
29 template < class Key, class Data, class KeyCompare = std::less<Key> >
|
Chris@16
|
30 class basic_ptree;
|
Chris@16
|
31
|
Chris@16
|
32 template <typename T>
|
Chris@16
|
33 struct id_translator;
|
Chris@16
|
34
|
Chris@16
|
35 template <typename String, typename Translator>
|
Chris@16
|
36 class string_path;
|
Chris@16
|
37
|
Chris@16
|
38 // Texas-style concepts for documentation only.
|
Chris@16
|
39 #if 0
|
Chris@16
|
40 concept PropertyTreePath<class Path> {
|
Chris@16
|
41 // The key type for which this path works.
|
Chris@16
|
42 typename key_type;
|
Chris@16
|
43 // Return the key that the first segment of the path names.
|
Chris@16
|
44 // Split the head off the state.
|
Chris@16
|
45 key_type Path::reduce();
|
Chris@16
|
46
|
Chris@16
|
47 // Return true if the path is empty.
|
Chris@16
|
48 bool Path::empty() const;
|
Chris@16
|
49
|
Chris@16
|
50 // Return true if the path contains a single element.
|
Chris@16
|
51 bool Path::single() const;
|
Chris@16
|
52
|
Chris@16
|
53 // Dump as a std::string, for exception messages.
|
Chris@16
|
54 std::string Path::dump() const;
|
Chris@16
|
55 }
|
Chris@16
|
56 concept PropertyTreeKey<class Key> {
|
Chris@16
|
57 PropertyTreePath path;
|
Chris@16
|
58 requires SameType<Key, PropertyTreePath<path>::key_type>;
|
Chris@16
|
59 }
|
Chris@16
|
60 concept PropertyTreeTranslator<class Tr> {
|
Chris@16
|
61 typename internal_type;
|
Chris@16
|
62 typename external_type;
|
Chris@16
|
63
|
Chris@16
|
64 boost::optional<external_type> Tr::get_value(internal_type);
|
Chris@16
|
65 boost::optional<internal_type> Tr::put_value(external_type);
|
Chris@16
|
66 }
|
Chris@16
|
67 #endif
|
Chris@16
|
68 /// If you want to use a custom key type, specialize this struct for it
|
Chris@16
|
69 /// and give it a 'type' typedef that specifies your path type. The path
|
Chris@16
|
70 /// type must conform to the Path concept described in the documentation.
|
Chris@16
|
71 /// This is already specialized for std::basic_string.
|
Chris@16
|
72 template <typename Key>
|
Chris@16
|
73 struct path_of;
|
Chris@16
|
74
|
Chris@16
|
75 /// Specialize this struct to specify a default translator between the data
|
Chris@16
|
76 /// in a tree whose data_type is Internal, and the external data_type
|
Chris@16
|
77 /// specified in a get_value, get, put_value or put operation.
|
Chris@16
|
78 /// This is already specialized for Internal being std::basic_string.
|
Chris@16
|
79 template <typename Internal, typename External>
|
Chris@16
|
80 struct translator_between;
|
Chris@16
|
81
|
Chris@16
|
82 class ptree_error;
|
Chris@16
|
83 class ptree_bad_data;
|
Chris@16
|
84 class ptree_bad_path;
|
Chris@16
|
85
|
Chris@16
|
86 // Typedefs
|
Chris@16
|
87
|
Chris@16
|
88 /** Implements a path using a std::string as the key. */
|
Chris@16
|
89 typedef string_path<std::string, id_translator<std::string> > path;
|
Chris@16
|
90
|
Chris@16
|
91 /**
|
Chris@16
|
92 * A property tree with std::string for key and data, and default
|
Chris@16
|
93 * comparison.
|
Chris@16
|
94 */
|
Chris@16
|
95 typedef basic_ptree<std::string, std::string> ptree;
|
Chris@16
|
96
|
Chris@16
|
97 /**
|
Chris@16
|
98 * A property tree with std::string for key and data, and case-insensitive
|
Chris@16
|
99 * comparison.
|
Chris@16
|
100 */
|
Chris@16
|
101 typedef basic_ptree<std::string, std::string,
|
Chris@16
|
102 detail::less_nocase<std::string> >
|
Chris@16
|
103 iptree;
|
Chris@16
|
104
|
Chris@16
|
105 #ifndef BOOST_NO_STD_WSTRING
|
Chris@16
|
106 /** Implements a path using a std::wstring as the key. */
|
Chris@16
|
107 typedef string_path<std::wstring, id_translator<std::wstring> > wpath;
|
Chris@16
|
108
|
Chris@16
|
109 /**
|
Chris@16
|
110 * A property tree with std::wstring for key and data, and default
|
Chris@16
|
111 * comparison.
|
Chris@16
|
112 * @note The type only exists if the platform supports @c wchar_t.
|
Chris@16
|
113 */
|
Chris@16
|
114 typedef basic_ptree<std::wstring, std::wstring> wptree;
|
Chris@16
|
115
|
Chris@16
|
116 /**
|
Chris@16
|
117 * A property tree with std::wstring for key and data, and case-insensitive
|
Chris@16
|
118 * comparison.
|
Chris@16
|
119 * @note The type only exists if the platform supports @c wchar_t.
|
Chris@16
|
120 */
|
Chris@16
|
121 typedef basic_ptree<std::wstring, std::wstring,
|
Chris@16
|
122 detail::less_nocase<std::wstring> >
|
Chris@16
|
123 wiptree;
|
Chris@16
|
124 #endif
|
Chris@16
|
125
|
Chris@16
|
126 // Free functions
|
Chris@16
|
127
|
Chris@16
|
128 /**
|
Chris@16
|
129 * Swap two property tree instances.
|
Chris@16
|
130 */
|
Chris@16
|
131 template<class K, class D, class C>
|
Chris@16
|
132 void swap(basic_ptree<K, D, C> &pt1,
|
Chris@16
|
133 basic_ptree<K, D, C> &pt2);
|
Chris@16
|
134
|
Chris@16
|
135 } }
|
Chris@16
|
136
|
Chris@16
|
137
|
Chris@16
|
138 #if !defined(BOOST_PROPERTY_TREE_DOXYGEN_INVOKED)
|
Chris@16
|
139 // Throwing macro to avoid no return warnings portably
|
Chris@16
|
140 # define BOOST_PROPERTY_TREE_THROW(e) BOOST_THROW_EXCEPTION(e)
|
Chris@16
|
141 #endif
|
Chris@16
|
142
|
Chris@16
|
143 #endif
|