// file : xsd/cxx/parser/exceptions.hxx // author : Boris Kolpackov // copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_PARSER_EXCEPTIONS_HXX #define XSD_CXX_PARSER_EXCEPTIONS_HXX #include #include #include #include // xsd::cxx::exception #include namespace xsd { namespace cxx { namespace parser { // // template struct exception: xsd::cxx::exception { friend std::basic_ostream& operator<< (std::basic_ostream& os, const exception& e) { e.print (os); return os; } protected: virtual void print (std::basic_ostream&) const = 0; }; // // struct severity { enum value { warning, error }; severity (value v) : v_ (v) {} operator value () const { return v_; } private: value v_; }; template struct error { error (cxx::parser::severity, const std::basic_string& id, unsigned long line, unsigned long column, const std::basic_string& message); cxx::parser::severity severity () const { return severity_; } const std::basic_string& id () const { return id_; } unsigned long line () const { return line_; } unsigned long column () const { return column_; } const std::basic_string& message () const { return message_; } private: cxx::parser::severity severity_; std::basic_string id_; unsigned long line_; unsigned long column_; std::basic_string message_; }; // See exceptions.ixx for operator<< (error). // // template struct diagnostics: std::vector > { }; // See exceptions.ixx for operator<< (diagnostics). // // template struct parsing: exception { virtual ~parsing () throw (); parsing (); parsing (const cxx::parser::diagnostics&); const cxx::parser::diagnostics& diagnostics () const { return diagnostics_; } virtual const char* what () const throw (); protected: virtual void print (std::basic_ostream&) const; private: cxx::parser::diagnostics diagnostics_; }; } } } #include #endif // XSD_CXX_PARSER_EXCEPTIONS_HXX #include