1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2002-2006 Marcin Kalicinski
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // For more information, see www.boost.org
9 // ----------------------------------------------------------------------------
10 #ifndef BOOST_PROPERTY_TREE_DETAIL_FILE_PARSER_ERROR_HPP_INCLUDED
11 #define BOOST_PROPERTY_TREE_DETAIL_FILE_PARSER_ERROR_HPP_INCLUDED
13 #include <boost/property_tree/ptree.hpp>
16 namespace boost { namespace property_tree
20 class file_parser_error: public ptree_error
25 ///////////////////////////////////////////////////////////////////////
26 // Construction & destruction
29 file_parser_error(const std::string &msg,
30 const std::string &file,
32 ptree_error(format_what(msg, file, l)),
33 m_message(msg), m_filename(file), m_line(l)
37 ~file_parser_error() throw()
38 // gcc 3.4.2 complains about lack of throw specifier on compiler
43 ///////////////////////////////////////////////////////////////////////
46 // Get error message (without line and file - use what() to get
48 std::string message() const
54 std::string filename() const
59 // Get error line number
60 unsigned long line() const
67 std::string m_message;
68 std::string m_filename;
71 // Format error message to be returned by std::runtime_error::what()
72 static std::string format_what(const std::string &msg,
73 const std::string &file,
76 std::stringstream stream;
77 stream << (file.empty() ? "<unspecified file>" : file.c_str());
79 stream << '(' << l << ')';
80 stream << ": " << msg;