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_DETAIL_EXCEPTIONS_IMPLEMENTATION_HPP_INCLUDED
|
Chris@16
|
12 #define BOOST_PROPERTY_TREE_DETAIL_EXCEPTIONS_IMPLEMENTATION_HPP_INCLUDED
|
Chris@16
|
13
|
Chris@16
|
14 namespace boost { namespace property_tree
|
Chris@16
|
15 {
|
Chris@16
|
16
|
Chris@16
|
17 namespace detail
|
Chris@16
|
18 {
|
Chris@16
|
19
|
Chris@16
|
20 // Helper for preparing what string in ptree_bad_path exception
|
Chris@16
|
21 template<class P> inline
|
Chris@16
|
22 std::string prepare_bad_path_what(const std::string &what,
|
Chris@16
|
23 const P &path)
|
Chris@16
|
24 {
|
Chris@16
|
25 return what + " (" + path.dump() + ")";
|
Chris@16
|
26 }
|
Chris@16
|
27
|
Chris@16
|
28 }
|
Chris@16
|
29
|
Chris@16
|
30 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
31 // ptree_error
|
Chris@16
|
32
|
Chris@16
|
33 inline ptree_error::ptree_error(const std::string &w):
|
Chris@16
|
34 std::runtime_error(w)
|
Chris@16
|
35 {
|
Chris@16
|
36 }
|
Chris@16
|
37
|
Chris@16
|
38 inline ptree_error::~ptree_error() throw()
|
Chris@16
|
39 {
|
Chris@16
|
40 }
|
Chris@16
|
41
|
Chris@16
|
42 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
43 // ptree_bad_data
|
Chris@16
|
44
|
Chris@16
|
45 template<class D> inline
|
Chris@16
|
46 ptree_bad_data::ptree_bad_data(const std::string &w, const D &d):
|
Chris@16
|
47 ptree_error(w), m_data(d)
|
Chris@16
|
48 {
|
Chris@16
|
49 }
|
Chris@16
|
50
|
Chris@16
|
51 inline ptree_bad_data::~ptree_bad_data() throw()
|
Chris@16
|
52 {
|
Chris@16
|
53 }
|
Chris@16
|
54
|
Chris@16
|
55 template<class D> inline
|
Chris@16
|
56 D ptree_bad_data::data() const
|
Chris@16
|
57 {
|
Chris@16
|
58 return boost::any_cast<D>(m_data);
|
Chris@16
|
59 }
|
Chris@16
|
60
|
Chris@16
|
61 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
62 // ptree_bad_path
|
Chris@16
|
63
|
Chris@16
|
64 template<class P> inline
|
Chris@16
|
65 ptree_bad_path::ptree_bad_path(const std::string &w, const P &p):
|
Chris@16
|
66 ptree_error(detail::prepare_bad_path_what(w, p)), m_path(p)
|
Chris@16
|
67 {
|
Chris@16
|
68
|
Chris@16
|
69 }
|
Chris@16
|
70
|
Chris@16
|
71 inline ptree_bad_path::~ptree_bad_path() throw()
|
Chris@16
|
72 {
|
Chris@16
|
73 }
|
Chris@16
|
74
|
Chris@16
|
75 template<class P> inline
|
Chris@16
|
76 P ptree_bad_path::path() const
|
Chris@16
|
77 {
|
Chris@16
|
78 return boost::any_cast<P>(m_path);
|
Chris@16
|
79 }
|
Chris@16
|
80
|
Chris@16
|
81 }}
|
Chris@16
|
82
|
Chris@16
|
83 #endif
|