Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:16

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 
0016 namespace boost { namespace property_tree
0017 {
0018 
0019     //! File parse error
0020     class file_parser_error: public ptree_error
0021     {
0022 
0023     public:
0024 
0025         ///////////////////////////////////////////////////////////////////////
0026         // Construction & destruction
0027 
0028         // Construct error
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             // gcc 3.4.2 complains about lack of throw specifier on compiler
0039             // generated dtor
0040         {
0041         }
0042 
0043         ///////////////////////////////////////////////////////////////////////
0044         // Data access
0045 
0046         // Get error message (without line and file - use what() to get
0047         // full message)
0048         std::string message() const
0049         {
0050             return m_message;
0051         }
0052 
0053         // Get error filename
0054         std::string filename() const
0055         {
0056             return m_filename;
0057         }
0058 
0059         // Get error line number
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         // Format error message to be returned by std::runtime_error::what()
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