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
|
Chris@16
|
12 #ifndef BOOST_PROPERTY_TREE_EXCEPTIONS_HPP_INCLUDED
|
Chris@16
|
13 #define BOOST_PROPERTY_TREE_EXCEPTIONS_HPP_INCLUDED
|
Chris@16
|
14
|
Chris@16
|
15 #include <boost/property_tree/ptree_fwd.hpp>
|
Chris@16
|
16
|
Chris@16
|
17 #include <boost/any.hpp>
|
Chris@16
|
18 #include <string>
|
Chris@16
|
19 #include <stdexcept>
|
Chris@16
|
20
|
Chris@16
|
21 namespace boost { namespace property_tree
|
Chris@16
|
22 {
|
Chris@16
|
23
|
Chris@16
|
24 /// Base class for all property tree errors. Derives from
|
Chris@16
|
25 /// @c std::runtime_error. Call member function @c what to get human
|
Chris@16
|
26 /// readable message associated with the error.
|
Chris@16
|
27 class ptree_error : public std::runtime_error
|
Chris@16
|
28 {
|
Chris@16
|
29 public:
|
Chris@16
|
30 /// Instantiate a ptree_error instance with the given message.
|
Chris@16
|
31 /// @param what The message to associate with this error.
|
Chris@16
|
32 ptree_error(const std::string &what);
|
Chris@16
|
33
|
Chris@16
|
34 ~ptree_error() throw();
|
Chris@16
|
35 };
|
Chris@16
|
36
|
Chris@16
|
37
|
Chris@16
|
38 /// Error indicating that translation from given value to the property tree
|
Chris@16
|
39 /// data_type (or vice versa) failed. Derives from ptree_error.
|
Chris@16
|
40 class ptree_bad_data : public ptree_error
|
Chris@16
|
41 {
|
Chris@16
|
42 public:
|
Chris@16
|
43 /// Instantiate a ptree_bad_data instance with the given message and
|
Chris@16
|
44 /// data.
|
Chris@16
|
45 /// @param what The message to associate with this error.
|
Chris@16
|
46 /// @param data The value associated with this error that was the source
|
Chris@16
|
47 /// of the translation failure.
|
Chris@16
|
48 template<class T> ptree_bad_data(const std::string &what,
|
Chris@16
|
49 const T &data);
|
Chris@16
|
50
|
Chris@16
|
51 ~ptree_bad_data() throw();
|
Chris@16
|
52
|
Chris@16
|
53 /// Retrieve the data associated with this error. This is the source
|
Chris@16
|
54 /// value that failed to be translated. You need to explicitly
|
Chris@16
|
55 /// specify its type.
|
Chris@16
|
56 template<class T> T data() const;
|
Chris@16
|
57 private:
|
Chris@16
|
58 boost::any m_data;
|
Chris@16
|
59 };
|
Chris@16
|
60
|
Chris@16
|
61
|
Chris@16
|
62 /// Error indicating that specified path does not exist. Derives from
|
Chris@16
|
63 /// ptree_error.
|
Chris@16
|
64 class ptree_bad_path : public ptree_error
|
Chris@16
|
65 {
|
Chris@16
|
66 public:
|
Chris@16
|
67 /// Instantiate a ptree_bad_path with the given message and path data.
|
Chris@16
|
68 /// @param what The message to associate with this error.
|
Chris@16
|
69 /// @param path The path that could not be found in the property_tree.
|
Chris@16
|
70 template<class T> ptree_bad_path(const std::string &what,
|
Chris@16
|
71 const T &path);
|
Chris@16
|
72
|
Chris@16
|
73 ~ptree_bad_path() throw();
|
Chris@16
|
74
|
Chris@16
|
75 /// Retrieve the invalid path. You need to explicitly specify the
|
Chris@16
|
76 /// type of path.
|
Chris@16
|
77 template<class T> T path() const;
|
Chris@16
|
78 private:
|
Chris@16
|
79 boost::any m_path;
|
Chris@16
|
80 };
|
Chris@16
|
81
|
Chris@16
|
82 }}
|
Chris@16
|
83
|
Chris@16
|
84 #include <boost/property_tree/detail/exception_implementation.hpp>
|
Chris@16
|
85
|
Chris@16
|
86 #endif
|