Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-14 08:45:39

0001 // ----------------------------------------------------------------------------
0002 // Copyright (C) 2002-2006 Marcin Kalicinski
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. 
0005 // (See accompanying file LICENSE_1_0.txt or copy at 
0006 // http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 // For more information, see www.boost.org
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     //! File parse error
0021     class file_parser_error: public ptree_error
0022     {
0023 
0024     public:
0025 
0026         ///////////////////////////////////////////////////////////////////////
0027         // Construction
0028 
0029         // Construct error
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         // Data access
0040 
0041         // Get error message (without line and file - use what() to get
0042         // full message)
0043         std::string message() const
0044         {
0045             return m_message;
0046         }
0047 
0048         // Get error filename
0049         std::string filename() const
0050         {
0051             return m_filename;
0052         }
0053 
0054         // Get error line number
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         // Format error message to be returned by std::runtime_error::what()
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