File indexing completed on 2025-07-14 08:45:39
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 #include <sstream>
0016
0017 namespace boost { namespace property_tree
0018 {
0019
0020
0021 class file_parser_error: public ptree_error
0022 {
0023
0024 public:
0025
0026
0027
0028
0029
0030 file_parser_error(const std::string &msg,
0031 const std::string &file,
0032 unsigned long l) :
0033 ptree_error(format_what(msg, file, l)),
0034 m_message(msg), m_filename(file), m_line(l)
0035 {
0036 }
0037
0038
0039
0040
0041
0042
0043 std::string message() const
0044 {
0045 return m_message;
0046 }
0047
0048
0049 std::string filename() const
0050 {
0051 return m_filename;
0052 }
0053
0054
0055 unsigned long line() const
0056 {
0057 return m_line;
0058 }
0059
0060 private:
0061
0062 std::string m_message;
0063 std::string m_filename;
0064 unsigned long m_line;
0065
0066
0067 static std::string format_what(const std::string &msg,
0068 const std::string &file,
0069 unsigned long l)
0070 {
0071 std::stringstream stream;
0072 stream << (file.empty() ? "<unspecified file>" : file.c_str());
0073 if (l > 0)
0074 stream << '(' << l << ')';
0075 stream << ": " << msg;
0076 return stream.str();
0077 }
0078
0079 };
0080
0081 } }
0082
0083 #endif