diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-04-21 23:42:07 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-04-21 23:42:07 +0200 |
commit | 69261c4b5fa020ad50bcd15f3b7e3e881ad6ded7 (patch) | |
tree | fdf69126584f6c6404704bdea92815380d616d97 /libxsd/xsd | |
parent | 5a5a9927f7c0746cec19bf3f1f789de6d4d1410a (diff) |
Work around the GCC visibility and specialization issue
If a template has any specializations, it is considered as defined
by GCC and any attempt to later set a visibility attribute via
explicit instantiation has no effect.
Diffstat (limited to 'libxsd/xsd')
-rw-r--r-- | libxsd/xsd/cxx/tree/bits/literals.hxx | 78 | ||||
-rw-r--r-- | libxsd/xsd/cxx/tree/bits/literals.ixx | 270 | ||||
-rw-r--r-- | libxsd/xsd/cxx/tree/exceptions.hxx | 2 | ||||
-rw-r--r-- | libxsd/xsd/cxx/tree/exceptions.ixx | 467 | ||||
-rw-r--r-- | libxsd/xsd/cxx/tree/exceptions.txx | 172 |
5 files changed, 520 insertions, 469 deletions
diff --git a/libxsd/xsd/cxx/tree/bits/literals.hxx b/libxsd/xsd/cxx/tree/bits/literals.hxx index 6fe6ddd..49ac0ca 100644 --- a/libxsd/xsd/cxx/tree/bits/literals.hxx +++ b/libxsd/xsd/cxx/tree/bits/literals.hxx @@ -173,6 +173,84 @@ namespace xsd template <typename C> const C* gmonth_prefix (); + + // Exception and diagnostics string literals. + // + template <typename C> + const C* + ex_error_error (); // " error: " + + template <typename C> + const C* + ex_error_warning (); // " warning: " + + template <typename C> + const C* + ex_parsing_msg (); // "instance document parsing failed" + + template <typename C> + const C* + ex_eel_expected (); // "expected element '" + + template <typename C> + const C* + ex_uel_expected (); // "expected element '" + + template <typename C> + const C* + ex_uel_instead (); // "' instead of '" + + template <typename C> + const C* + ex_uel_unexpected (); // "unexpected element '" + + template <typename C> + const C* + ex_eat_expected (); // "expected attribute '" + + template <typename C> + const C* + ex_uen_unexpected (); // "unexpected enumerator '" + + template <typename C> + const C* + ex_etc_msg (); // "expected text content" + + template <typename C> + const C* + ex_nti_no_type_info (); // "no type information available for type '" + + template <typename C> + const C* + ex_nei_no_element_info (); // "no parsing or serialization information + // available for element '" + template <typename C> + const C* + ex_nd_type (); // "type '" + + template <typename C> + const C* + ex_nd_not_derived (); // "' is not derived from '" + + template <typename C> + const C* + ex_di_id (); // "ID '" + + template <typename C> + const C* + ex_di_already_exist (); // "' already exist" + + template <typename C> + const C* + ex_serialization_msg (); // "serialization failed" + + template <typename C> + const C* + ex_npm_no_mapping (); // "no mapping provided for namespace prefix '" + + template <typename C> + const C* + ex_bounds_msg (); // "buffer boundary rules have been violated" } } } diff --git a/libxsd/xsd/cxx/tree/bits/literals.ixx b/libxsd/xsd/cxx/tree/bits/literals.ixx index bd6fd30..e11bcac 100644 --- a/libxsd/xsd/cxx/tree/bits/literals.ixx +++ b/libxsd/xsd/cxx/tree/bits/literals.ixx @@ -306,6 +306,141 @@ namespace xsd { return "--"; } + + // + // + template <> + inline const char* + ex_error_error () + { + return " error: "; + } + + template <> + inline const char* + ex_error_warning () + { + return " warning: "; + } + + template <> + inline const char* + ex_parsing_msg () + { + return "instance document parsing failed"; + } + + template <> + inline const char* + ex_eel_expected () + { + return "expected element '"; + } + + template <> + inline const char* + ex_uel_expected () + { + return "expected element '"; + } + + template <> + inline const char* + ex_uel_instead () + { + return "' instead of '"; + } + + template <> + inline const char* + ex_uel_unexpected () + { + return "unexpected element '"; + } + + template <> + inline const char* + ex_eat_expected () + { + return "expected attribute '"; + } + + template <> + inline const char* + ex_uen_unexpected () + { + return "unexpected enumerator '"; + } + + template <> + inline const char* + ex_etc_msg () + { + return "expected text content"; + } + + template <> + inline const char* + ex_nti_no_type_info () + { + return "no type information available for type '"; + } + + template <> + inline const char* + ex_nei_no_element_info () + { + return "no parsing or serialization information available for " + "element '"; + } + template <> + inline const char* + ex_nd_type () + { + return "type '"; + } + + template <> + inline const char* + ex_nd_not_derived () + { + return "' is not derived from '"; + } + + template <> + inline const char* + ex_di_id () + { + return "ID '"; + } + + template <> + inline const char* + ex_di_already_exist () + { + return "' already exist"; + } + + template <> + inline const char* + ex_serialization_msg () + { + return "serialization failed"; + } + + template <> + inline const char* + ex_npm_no_mapping () + { + return "no mapping provided for namespace prefix '"; + } + + template <> + inline const char* + ex_bounds_msg () + { + return "buffer boundary rules have been violated"; + } } } } @@ -597,6 +732,141 @@ namespace xsd { return L"--"; } + + // + // + template <> + inline const wchar_t* + ex_error_error () + { + return L" error: "; + } + + template <> + inline const wchar_t* + ex_error_warning () + { + return L" warning: "; + } + + template <> + inline const wchar_t* + ex_parsing_msg () + { + return L"instance document parsing failed"; + } + + template <> + inline const wchar_t* + ex_eel_expected () + { + return L"expected element '"; + } + + template <> + inline const wchar_t* + ex_uel_expected () + { + return L"expected element '"; + } + + template <> + inline const wchar_t* + ex_uel_instead () + { + return L"' instead of '"; + } + + template <> + inline const wchar_t* + ex_uel_unexpected () + { + return L"unexpected element '"; + } + + template <> + inline const wchar_t* + ex_eat_expected () + { + return L"expected attribute '"; + } + + template <> + inline const wchar_t* + ex_uen_unexpected () + { + return L"unexpected enumerator '"; + } + + template <> + inline const wchar_t* + ex_etc_msg () + { + return L"expected text content"; + } + + template <> + inline const wchar_t* + ex_nti_no_type_info () + { + return L"no type information available for type '"; + } + + template <> + inline const wchar_t* + ex_nei_no_element_info () + { + return L"no parsing or serialization information available for " + L"element '"; + } + template <> + inline const wchar_t* + ex_nd_type () + { + return L"type '"; + } + + template <> + inline const wchar_t* + ex_nd_not_derived () + { + return L"' is not derived from '"; + } + + template <> + inline const wchar_t* + ex_di_id () + { + return L"ID '"; + } + + template <> + inline const wchar_t* + ex_di_already_exist () + { + return L"' already exist"; + } + + template <> + inline const wchar_t* + ex_serialization_msg () + { + return L"serialization failed"; + } + + template <> + inline const wchar_t* + ex_npm_no_mapping () + { + return L"no mapping provided for namespace prefix '"; + } + + template <> + inline const wchar_t* + ex_bounds_msg () + { + return L"buffer boundary rules have been violated"; + } } } } diff --git a/libxsd/xsd/cxx/tree/exceptions.hxx b/libxsd/xsd/cxx/tree/exceptions.hxx index 1c8c927..f6ddb15 100644 --- a/libxsd/xsd/cxx/tree/exceptions.hxx +++ b/libxsd/xsd/cxx/tree/exceptions.hxx @@ -1032,5 +1032,3 @@ namespace xsd #include <xsd/cxx/tree/exceptions.txx> #endif // XSD_CXX_TREE_EXCEPTIONS_HXX - -#include <xsd/cxx/tree/exceptions.ixx> diff --git a/libxsd/xsd/cxx/tree/exceptions.ixx b/libxsd/xsd/cxx/tree/exceptions.ixx deleted file mode 100644 index af27186..0000000 --- a/libxsd/xsd/cxx/tree/exceptions.ixx +++ /dev/null @@ -1,467 +0,0 @@ -// file : xsd/cxx/tree/exceptions.ixx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#if defined(XSD_CXX_TREE_USE_CHAR) || !defined(XSD_CXX_TREE_USE_WCHAR) - -#ifndef XSD_CXX_TREE_EXCEPTIONS_IXX_CHAR -#define XSD_CXX_TREE_EXCEPTIONS_IXX_CHAR - -namespace xsd -{ - namespace cxx - { - namespace tree - { - - // 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_; - } - - - // expected_element - // - template<> - inline - void expected_element<char>:: - print (std::basic_ostream<char>& os) const - { - os << "expected element '" - << namespace_ () << (namespace_ ().empty () ? "" : "#") - << name () << "'"; - } - - - // unexpected_element - // - template<> - inline - void unexpected_element<char>:: - print (std::basic_ostream<char>& os) const - { - if (!expected_name ().empty ()) - { - os << "expected element '" - << expected_namespace () - << (expected_namespace ().empty () ? "" : "#") - << expected_name () - << "' instead of '" - << encountered_namespace () - << (encountered_namespace ().empty () ? "" : "#") - << encountered_name () << "'"; - } - else - { - os << "unexpected element '" - << encountered_namespace () - << (encountered_namespace ().empty () ? "" : "#") - << encountered_name () << "'"; - } - } - - - // expected_attribute - // - template<> - inline - void expected_attribute<char>:: - print (std::basic_ostream<char>& os) const - { - os << "expected attribute '" - << namespace_ () << (namespace_ ().empty () ? "" : "#") - << name () << "'"; - } - - - // unexpected_enumerator - // - template<> - inline - void unexpected_enumerator<char>:: - print (std::basic_ostream<char>& os) const - { - os << "unexpected enumerator '" << enumerator () << "'"; - } - - - // expected_text_content - // - template<> - inline - void expected_text_content<char>:: - print (std::basic_ostream<char>& os) const - { - os << "expected text content"; - } - - - // no_type_info - // - template<> - inline - void no_type_info<char>:: - print (std::basic_ostream<char>& os) const - { - os << "no type information available for type '" - << type_namespace () << (type_namespace ().empty () ? "" : "#") - << type_name () << "'"; - } - - // no_element_info - // - template<> - inline - void no_element_info<char>:: - print (std::basic_ostream<char>& os) const - { - os << "no parsing or serialization information available for " - << "element '" << element_namespace () - << (element_namespace ().empty () ? "" : "#") - << element_name () << "'"; - } - - // not_derived - // - template<> - inline - void not_derived<char>:: - print (std::basic_ostream<char>& os) const - { - os << "type '" - << derived_type_namespace () - << (derived_type_namespace ().empty () ? "" : "#") - << derived_type_name () - << "' is not derived from '" - << base_type_namespace () - << (base_type_namespace ().empty () ? "" : "#") - << base_type_name () << "'"; - } - - - // duplicate_id - // - template<> - inline - void duplicate_id<char>:: - print (std::basic_ostream<char>& os) const - { - os << "ID '" << id () << "' already exist"; - } - - - // serialization - // - template<> - inline - void serialization<char>:: - print (std::basic_ostream<char>& os) const - { - if (diagnostics_.empty ()) - os << "serialization failed"; - else - os << diagnostics_; - } - - - // no_prefix_mapping - // - template<> - inline - void no_prefix_mapping<char>:: - print (std::basic_ostream<char>& os) const - { - os << "no mapping provided for namespace prefix '" - << prefix () << "'"; - } - - - // bounds - // - template<> - inline - void bounds<char>:: - print (std::basic_ostream<char>& os) const - { - os << "buffer boundary rules have been violated"; - } - } - } -} - -#endif // XSD_CXX_TREE_EXCEPTIONS_IXX_CHAR -#endif // XSD_CXX_TREE_USE_CHAR - - -#if defined(XSD_CXX_TREE_USE_WCHAR) || !defined(XSD_CXX_TREE_USE_CHAR) - -#ifndef XSD_CXX_TREE_EXCEPTIONS_IXX_WCHAR -#define XSD_CXX_TREE_EXCEPTIONS_IXX_WCHAR - -namespace xsd -{ - namespace cxx - { - namespace tree - { - // 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_; - } - - - // expected_element - // - template<> - inline - void expected_element<wchar_t>:: - print (std::basic_ostream<wchar_t>& os) const - { - os << L"expected element '" - << namespace_ () << (namespace_ ().empty () ? L"" : L"#") - << name () << L"'"; - } - - - // unexpected_element - // - template<> - inline - void unexpected_element<wchar_t>:: - print (std::basic_ostream<wchar_t>& os) const - { - if (!expected_name ().empty ()) - { - os << L"expected element '" - << expected_namespace () - << (expected_namespace ().empty () ? L"" : L"#") - << expected_name () - << L"' instead of '" - << encountered_namespace () - << (encountered_namespace ().empty () ? L"" : L"#") - << encountered_name () << L"'"; - } - else - { - os << L"unexpected element '" - << encountered_namespace () - << (encountered_namespace ().empty () ? L"" : L"#") - << encountered_name () << L"'"; - } - } - - - // expected_attribute - // - template<> - inline - void expected_attribute<wchar_t>:: - print (std::basic_ostream<wchar_t>& os) const - { - os << L"expected attribute '" - << namespace_ () << (namespace_ ().empty () ? L"" : L"#") - << name () << L"'"; - } - - - // unexpected_enumerator - // - template<> - inline - void unexpected_enumerator<wchar_t>:: - print (std::basic_ostream<wchar_t>& os) const - { - os << L"unexpected enumerator '" << enumerator () << L"'"; - } - - - // expected_text_content - // - template<> - inline - void expected_text_content<wchar_t>:: - print (std::basic_ostream<wchar_t>& os) const - { - os << L"expected text content"; - } - - - // no_type_info - // - template<> - inline - void no_type_info<wchar_t>:: - print (std::basic_ostream<wchar_t>& os) const - { - os << L"no type information available for type '" - << type_namespace () << (type_namespace ().empty () ? L"" : L"#") - << type_name () << L"'"; - } - - // no_element_info - // - template<> - inline - void no_element_info<wchar_t>:: - print (std::basic_ostream<wchar_t>& os) const - { - os << L"no parsing or serialization information available for " - << L"element '" << element_namespace () - << (element_namespace ().empty () ? L"" : L"#") - << element_name () << L"'"; - } - - // not_derived - // - template<> - inline - void not_derived<wchar_t>:: - print (std::basic_ostream<wchar_t>& os) const - { - os << L"type '" - << derived_type_namespace () - << (derived_type_namespace ().empty () ? L"" : L"#") - << derived_type_name () - << L"' is not derived from '" - << base_type_namespace () - << (base_type_namespace ().empty () ? L"" : L"#") - << base_type_name () << L"'"; - } - - - // duplicate_id - // - template<> - inline - void duplicate_id<wchar_t>:: - print (std::basic_ostream<wchar_t>& os) const - { - os << L"ID '" << id () << L"' already exist"; - } - - - // serialization - // - template<> - inline - void serialization<wchar_t>:: - print (std::basic_ostream<wchar_t>& os) const - { - if (diagnostics_.empty ()) - os << L"serialization failed"; - else - os << diagnostics_; - } - - - // no_prefix_mapping - // - template<> - inline - void no_prefix_mapping<wchar_t>:: - print (std::basic_ostream<wchar_t>& os) const - { - os << L"no mapping provided for namespace prefix '" - << prefix () << L"'"; - } - - - // bounds - // - template<> - inline - void bounds<wchar_t>:: - print (std::basic_ostream<wchar_t>& os) const - { - os << L"buffer boundary rules have been violated"; - } - } - } -} - -#endif // XSD_CXX_TREE_EXCEPTIONS_IXX_WCHAR -#endif // XSD_CXX_TREE_USE_WCHAR diff --git a/libxsd/xsd/cxx/tree/exceptions.txx b/libxsd/xsd/cxx/tree/exceptions.txx index 256f5f7..8262fce 100644 --- a/libxsd/xsd/cxx/tree/exceptions.txx +++ b/libxsd/xsd/cxx/tree/exceptions.txx @@ -3,6 +3,8 @@ // copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#include <xsd/cxx/tree/bits/literals.hxx> + namespace xsd { namespace cxx @@ -33,6 +35,35 @@ namespace xsd { } + template <typename C> + std::basic_ostream<C>& + operator<< (std::basic_ostream<C>& os, const error<C>& e) + { + return os << e.id () << C (':') << e.line () << C (':') << e.column () + << (e.severity () == severity::error + ? bits::ex_error_error<C> () + : bits::ex_error_warning<C> ()) << e.message (); + } + + // diagnostics + // + template <typename C> + std::basic_ostream<C>& + operator<< (std::basic_ostream<C>& os, const diagnostics<C>& d) + { + for (typename diagnostics<C>::const_iterator b (d.begin ()), i (b); + i != d.end (); + ++i) + { + if (i != b) + os << C ('\n'); + + os << *i; + } + + return os; + } + // parsing // template <typename C> @@ -61,6 +92,15 @@ namespace xsd return "instance document parsing failed"; } + template <typename C> + void parsing<C>:: + print (std::basic_ostream<C>& os) const + { + if (diagnostics_.empty ()) + os << bits::ex_parsing_msg<C> (); + else + os << diagnostics_; + } // expected_element // @@ -85,6 +125,17 @@ namespace xsd return "expected element not encountered"; } + template <typename C> + void expected_element<C>:: + print (std::basic_ostream<C>& os) const + { + os << bits::ex_eel_expected<C> (); + + if (!namespace_ ().empty ()) + os << namespace_ () << C ('#'); + + os << name () << C ('\''); + } // unexpected_element // @@ -114,6 +165,34 @@ namespace xsd return "unexpected element encountered"; } + template <typename C> + void unexpected_element<C>:: + print (std::basic_ostream<C>& os) const + { + if (!expected_name ().empty ()) + { + os << bits::ex_uel_expected<C> (); + + if (!expected_namespace ().empty ()) + os << expected_namespace () << C ('#'); + + os << expected_name () << bits::ex_uel_instead<C> (); + + if (!encountered_namespace ().empty ()) + os << encountered_namespace () << C ('#'); + + os << encountered_name () << C ('\''); + } + else + { + os << bits::ex_uel_unexpected<C> (); + + if (!encountered_namespace ().empty ()) + os << encountered_namespace () << C ('#'); + + os << encountered_name () << C ('\''); + } + } // expected_attribute // @@ -138,6 +217,17 @@ namespace xsd return "expected attribute not encountered"; } + template <typename C> + void expected_attribute<C>:: + print (std::basic_ostream<C>& os) const + { + os << bits::ex_eat_expected<C> (); + + if (!namespace_ ().empty ()) + os << namespace_ () << C ('#'); + + os << name () << C ('\''); + } // unexpected_enumerator // @@ -161,6 +251,12 @@ namespace xsd return "unexpected enumerator encountered"; } + template <typename C> + void unexpected_enumerator<C>:: + print (std::basic_ostream<C>& os) const + { + os << bits::ex_uen_unexpected<C> () << enumerator () << C ('\''); + } // expected_text_content // @@ -171,6 +267,12 @@ namespace xsd return "expected text content"; } + template <typename C> + void expected_text_content<C>:: + print (std::basic_ostream<C>& os) const + { + os << bits::ex_etc_msg<C> (); + } // no_type_info // @@ -196,6 +298,18 @@ namespace xsd return "no type information available for a type"; } + template <typename C> + void no_type_info<C>:: + print (std::basic_ostream<C>& os) const + { + os << bits::ex_nti_no_type_info<C> (); + + if (!type_namespace ().empty ()) + os << type_namespace () << C ('#'); + + os << type_name () << C ('\''); + } + // no_element_info // template <typename C> @@ -221,6 +335,18 @@ namespace xsd "an element"; } + template <typename C> + void no_element_info<C>:: + print (std::basic_ostream<C>& os) const + { + os << bits::ex_nei_no_element_info<C> (); + + if (!element_namespace ().empty ()) + os << element_namespace () << C ('#'); + + os << element_name () << C ('\''); + } + // not_derived // template <typename C> @@ -249,6 +375,22 @@ namespace xsd return "type is not derived"; } + template <typename C> + void not_derived<C>:: + print (std::basic_ostream<C>& os) const + { + os << bits::ex_nd_type<C> (); + + if (!derived_type_namespace ().empty ()) + os << derived_type_namespace () << C ('#'); + + os << derived_type_name () << bits::ex_nd_not_derived<C> (); + + if (!base_type_namespace ().empty ()) + os << base_type_namespace () << C ('#'); + + os << base_type_name () << C ('\''); + } // duplicate_id // @@ -272,6 +414,12 @@ namespace xsd return "ID already exist"; } + template <typename C> + void duplicate_id<C>:: + print (std::basic_ostream<C>& os) const + { + os << bits::ex_di_id<C> () << id () << bits::ex_di_already_exist<C> (); + } // serialization // @@ -301,6 +449,16 @@ namespace xsd return "serialization failed"; } + template <typename C> + void serialization<C>:: + print (std::basic_ostream<C>& os) const + { + if (diagnostics_.empty ()) + os << bits::ex_serialization_msg<C> (); + else + os << diagnostics_; + } + // no_prefix_mapping // @@ -324,6 +482,13 @@ namespace xsd return "no mapping provided for a namespace prefix"; } + template <typename C> + void no_prefix_mapping<C>:: + print (std::basic_ostream<C>& os) const + { + os << bits::ex_npm_no_mapping<C> () << prefix () << C ('\''); + } + // bounds // @@ -333,6 +498,13 @@ namespace xsd { return "buffer boundary rules have been violated"; } + + template <typename C> + void bounds<C>:: + print (std::basic_ostream<C>& os) const + { + os << bits::ex_bounds_msg<C> (); + } } } } |