aboutsummaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/parser/exceptions.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-09-17 07:15:29 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-09-17 07:15:29 +0200
commitf0510d2f90467de8e8f260b47d79a9baaf9bef17 (patch)
tree0b9929946f06a9cbe9b9e8f2a7600dae4e048f79 /libxsd/xsd/cxx/parser/exceptions.hxx
Start tracking XSD with git
Diffstat (limited to 'libxsd/xsd/cxx/parser/exceptions.hxx')
-rw-r--r--libxsd/xsd/cxx/parser/exceptions.hxx153
1 files changed, 153 insertions, 0 deletions
diff --git a/libxsd/xsd/cxx/parser/exceptions.hxx b/libxsd/xsd/cxx/parser/exceptions.hxx
new file mode 100644
index 0000000..a19fb7d
--- /dev/null
+++ b/libxsd/xsd/cxx/parser/exceptions.hxx
@@ -0,0 +1,153 @@
+// file : xsd/cxx/parser/exceptions.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// 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 <string>
+#include <vector>
+#include <ostream>
+
+#include <xsd/cxx/exceptions.hxx> // xsd::cxx::exception
+#include <xsd/cxx/ro-string.hxx>
+
+namespace xsd
+{
+ namespace cxx
+ {
+ namespace parser
+ {
+ //
+ //
+ template <typename C>
+ struct exception: xsd::cxx::exception
+ {
+ friend
+ std::basic_ostream<C>&
+ operator<< (std::basic_ostream<C>& os, const exception& e)
+ {
+ e.print (os);
+ return os;
+ }
+
+ protected:
+ virtual void
+ print (std::basic_ostream<C>&) const = 0;
+ };
+
+
+ //
+ //
+ struct severity
+ {
+ enum value
+ {
+ warning,
+ error
+ };
+
+ severity (value v) : v_ (v) {}
+ operator value () const { return v_; }
+
+ private:
+ value v_;
+ };
+
+ template <typename C>
+ struct error
+ {
+ error (cxx::parser::severity,
+ const std::basic_string<C>& id,
+ unsigned long line,
+ unsigned long column,
+ const std::basic_string<C>& message);
+
+ cxx::parser::severity
+ severity () const
+ {
+ return severity_;
+ }
+
+ const std::basic_string<C>&
+ id () const
+ {
+ return id_;
+ }
+
+ unsigned long
+ line () const
+ {
+ return line_;
+ }
+
+ unsigned long
+ column () const
+ {
+ return column_;
+ }
+
+ const std::basic_string<C>&
+ message () const
+ {
+ return message_;
+ }
+
+ private:
+ cxx::parser::severity severity_;
+ std::basic_string<C> id_;
+ unsigned long line_;
+ unsigned long column_;
+ std::basic_string<C> message_;
+ };
+
+ // See exceptions.ixx for operator<< (error).
+
+
+ //
+ //
+ template <typename C>
+ struct diagnostics: std::vector<error<C> >
+ {
+ };
+
+ // See exceptions.ixx for operator<< (diagnostics).
+
+ //
+ //
+ template <typename C>
+ struct parsing: exception<C>
+ {
+ virtual
+ ~parsing () throw ();
+
+ parsing ();
+
+ parsing (const cxx::parser::diagnostics<C>&);
+
+ const cxx::parser::diagnostics<C>&
+ diagnostics () const
+ {
+ return diagnostics_;
+ }
+
+ virtual const char*
+ what () const throw ();
+
+ protected:
+ virtual void
+ print (std::basic_ostream<C>&) const;
+
+ private:
+ cxx::parser::diagnostics<C> diagnostics_;
+ };
+ }
+ }
+}
+
+#include <xsd/cxx/parser/exceptions.txx>
+
+#endif // XSD_CXX_PARSER_EXCEPTIONS_HXX
+
+#include <xsd/cxx/parser/exceptions.ixx>