summaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/parser/exceptions.ixx
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.ixx
Start tracking XSD with git
Diffstat (limited to 'libxsd/xsd/cxx/parser/exceptions.ixx')
-rw-r--r--libxsd/xsd/cxx/parser/exceptions.ixx129
1 files changed, 129 insertions, 0 deletions
diff --git a/libxsd/xsd/cxx/parser/exceptions.ixx b/libxsd/xsd/cxx/parser/exceptions.ixx
new file mode 100644
index 0000000..b583ed0
--- /dev/null
+++ b/libxsd/xsd/cxx/parser/exceptions.ixx
@@ -0,0 +1,129 @@
+// file : xsd/cxx/parser/exceptions.ixx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#if defined(XSD_CXX_PARSER_USE_CHAR) || !defined(XSD_CXX_PARSER_USE_WCHAR)
+
+#ifndef XSD_CXX_PARSER_EXCEPTIONS_IXX_CHAR
+#define XSD_CXX_PARSER_EXCEPTIONS_IXX_CHAR
+
+namespace xsd
+{
+ namespace cxx
+ {
+ namespace parser
+ {
+ // error
+ //
+ inline
+ std::basic_ostream<char>&
+ operator<< (std::basic_ostream<char>& os, const error<char>& e)
+ {
+ return os << e.id () << ':' << e.line () << ':' << e.column ()
+ << (e.severity () == severity::error
+ ? " error: "
+ : " warning: ") << e.message ();
+ }
+
+
+ // diagnostics
+ //
+ inline
+ std::basic_ostream<char>&
+ operator<< (std::basic_ostream<char>& os, const diagnostics<char>& d)
+ {
+ for (diagnostics<char>::const_iterator b (d.begin ()), i (b);
+ i != d.end ();
+ ++i)
+ {
+ if (i != b)
+ os << "\n";
+
+ os << *i;
+ }
+
+ return os;
+ }
+
+ // parsing
+ //
+ template<>
+ inline
+ void parsing<char>::
+ print (std::basic_ostream<char>& os) const
+ {
+ if (diagnostics_.empty ())
+ os << "instance document parsing failed";
+ else
+ os << diagnostics_;
+ }
+ }
+ }
+}
+
+#endif // XSD_CXX_PARSER_EXCEPTIONS_IXX_CHAR
+#endif // XSD_CXX_PARSER_USE_CHAR
+
+
+#if defined(XSD_CXX_PARSER_USE_WCHAR) || !defined(XSD_CXX_PARSER_USE_CHAR)
+
+#ifndef XSD_CXX_PARSER_EXCEPTIONS_IXX_WCHAR
+#define XSD_CXX_PARSER_EXCEPTIONS_IXX_WCHAR
+
+namespace xsd
+{
+ namespace cxx
+ {
+ namespace parser
+ {
+ // error
+ //
+ inline
+ std::basic_ostream<wchar_t>&
+ operator<< (std::basic_ostream<wchar_t>& os, const error<wchar_t>& e)
+ {
+ return os << e.id () << L':' << e.line () << L':' << e.column ()
+ << (e.severity () == severity::error
+ ? L" error: "
+ : L" warning: ") << e.message ();
+ }
+
+ // diagnostics
+ //
+ inline
+ std::basic_ostream<wchar_t>&
+ operator<< (std::basic_ostream<wchar_t>& os,
+ const diagnostics<wchar_t>& d)
+ {
+ for (diagnostics<wchar_t>::const_iterator b (d.begin ()), i (b);
+ i != d.end ();
+ ++i)
+ {
+ if (i != b)
+ os << L"\n";
+
+ os << *i;
+ }
+
+ return os;
+ }
+
+ // parsing
+ //
+ template<>
+ inline
+ void parsing<wchar_t>::
+ print (std::basic_ostream<wchar_t>& os) const
+ {
+ if (diagnostics_.empty ())
+ os << L"instance document parsing failed";
+ else
+ os << diagnostics_;
+ }
+ }
+ }
+}
+
+#endif // XSD_CXX_PARSER_EXCEPTIONS_IXX_WCHAR
+#endif // XSD_CXX_PARSER_USE_WCHAR