File indexing completed on 2025-01-18 09:50:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_PROPERTY_TREE_DETAIL_FILE_PARSER_ERROR_HPP_INCLUDED
0011 #define BOOST_PROPERTY_TREE_DETAIL_FILE_PARSER_ERROR_HPP_INCLUDED
0012
0013 #include <boost/property_tree/ptree.hpp>
0014 #include <string>
0015
0016 namespace boost { namespace property_tree
0017 {
0018
0019
0020 class file_parser_error: public ptree_error
0021 {
0022
0023 public:
0024
0025
0026
0027
0028
0029 file_parser_error(const std::string &msg,
0030 const std::string &file,
0031 unsigned long l) :
0032 ptree_error(format_what(msg, file, l)),
0033 m_message(msg), m_filename(file), m_line(l)
0034 {
0035 }
0036
0037 ~file_parser_error() throw() BOOST_OVERRIDE
0038
0039
0040 {
0041 }
0042
0043
0044
0045
0046
0047
0048 std::string message() const
0049 {
0050 return m_message;
0051 }
0052
0053
0054 std::string filename() const
0055 {
0056 return m_filename;
0057 }
0058
0059
0060 unsigned long line() const
0061 {
0062 return m_line;
0063 }
0064
0065 private:
0066
0067 std::string m_message;
0068 std::string m_filename;
0069 unsigned long m_line;
0070
0071
0072 static std::string format_what(const std::string &msg,
0073 const std::string &file,
0074 unsigned long l)
0075 {
0076 std::stringstream stream;
0077 stream << (file.empty() ? "<unspecified file>" : file.c_str());
0078 if (l > 0)
0079 stream << '(' << l << ')';
0080 stream << ": " << msg;
0081 return stream.str();
0082 }
0083
0084 };
0085
0086 } }
0087
0088 #endif