From 69261c4b5fa020ad50bcd15f3b7e3e881ad6ded7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 21 Apr 2010 23:42:07 +0200 Subject: 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. --- libxsd/xsd/cxx/tree/bits/literals.hxx | 78 ++++++ libxsd/xsd/cxx/tree/bits/literals.ixx | 270 ++++++++++++++++++++ libxsd/xsd/cxx/tree/exceptions.hxx | 2 - libxsd/xsd/cxx/tree/exceptions.ixx | 467 ---------------------------------- libxsd/xsd/cxx/tree/exceptions.txx | 172 +++++++++++++ 5 files changed, 520 insertions(+), 469 deletions(-) delete mode 100644 libxsd/xsd/cxx/tree/exceptions.ixx (limited to 'libxsd/xsd/cxx/tree') 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 const C* gmonth_prefix (); + + // Exception and diagnostics string literals. + // + template + const C* + ex_error_error (); // " error: " + + template + const C* + ex_error_warning (); // " warning: " + + template + const C* + ex_parsing_msg (); // "instance document parsing failed" + + template + const C* + ex_eel_expected (); // "expected element '" + + template + const C* + ex_uel_expected (); // "expected element '" + + template + const C* + ex_uel_instead (); // "' instead of '" + + template + const C* + ex_uel_unexpected (); // "unexpected element '" + + template + const C* + ex_eat_expected (); // "expected attribute '" + + template + const C* + ex_uen_unexpected (); // "unexpected enumerator '" + + template + const C* + ex_etc_msg (); // "expected text content" + + template + const C* + ex_nti_no_type_info (); // "no type information available for type '" + + template + const C* + ex_nei_no_element_info (); // "no parsing or serialization information + // available for element '" + template + const C* + ex_nd_type (); // "type '" + + template + const C* + ex_nd_not_derived (); // "' is not derived from '" + + template + const C* + ex_di_id (); // "ID '" + + template + const C* + ex_di_already_exist (); // "' already exist" + + template + const C* + ex_serialization_msg (); // "serialization failed" + + template + const C* + ex_npm_no_mapping (); // "no mapping provided for namespace prefix '" + + template + 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 #endif // XSD_CXX_TREE_EXCEPTIONS_HXX - -#include 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 -// 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& - operator<< (std::basic_ostream& os, const error& e) - { - return os << e.id () << ':' << e.line () << ':' << e.column () - << (e.severity () == severity::error - ? " error: " - : " warning: ") << e.message (); - } - - - // diagnostics - // - inline - std::basic_ostream& - operator<< (std::basic_ostream& os, const diagnostics& d) - { - for (diagnostics::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:: - print (std::basic_ostream& os) const - { - if (diagnostics_.empty ()) - os << "instance document parsing failed"; - else - os << diagnostics_; - } - - - // expected_element - // - template<> - inline - void expected_element:: - print (std::basic_ostream& os) const - { - os << "expected element '" - << namespace_ () << (namespace_ ().empty () ? "" : "#") - << name () << "'"; - } - - - // unexpected_element - // - template<> - inline - void unexpected_element:: - print (std::basic_ostream& 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:: - print (std::basic_ostream& os) const - { - os << "expected attribute '" - << namespace_ () << (namespace_ ().empty () ? "" : "#") - << name () << "'"; - } - - - // unexpected_enumerator - // - template<> - inline - void unexpected_enumerator:: - print (std::basic_ostream& os) const - { - os << "unexpected enumerator '" << enumerator () << "'"; - } - - - // expected_text_content - // - template<> - inline - void expected_text_content:: - print (std::basic_ostream& os) const - { - os << "expected text content"; - } - - - // no_type_info - // - template<> - inline - void no_type_info:: - print (std::basic_ostream& 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:: - print (std::basic_ostream& 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:: - print (std::basic_ostream& 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:: - print (std::basic_ostream& os) const - { - os << "ID '" << id () << "' already exist"; - } - - - // serialization - // - template<> - inline - void serialization:: - print (std::basic_ostream& os) const - { - if (diagnostics_.empty ()) - os << "serialization failed"; - else - os << diagnostics_; - } - - - // no_prefix_mapping - // - template<> - inline - void no_prefix_mapping:: - print (std::basic_ostream& os) const - { - os << "no mapping provided for namespace prefix '" - << prefix () << "'"; - } - - - // bounds - // - template<> - inline - void bounds:: - print (std::basic_ostream& 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& - operator<< (std::basic_ostream& os, const error& 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& - operator<< (std::basic_ostream& os, - const diagnostics& d) - { - for (diagnostics::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:: - print (std::basic_ostream& os) const - { - if (diagnostics_.empty ()) - os << L"instance document parsing failed"; - else - os << diagnostics_; - } - - - // expected_element - // - template<> - inline - void expected_element:: - print (std::basic_ostream& os) const - { - os << L"expected element '" - << namespace_ () << (namespace_ ().empty () ? L"" : L"#") - << name () << L"'"; - } - - - // unexpected_element - // - template<> - inline - void unexpected_element:: - print (std::basic_ostream& 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:: - print (std::basic_ostream& os) const - { - os << L"expected attribute '" - << namespace_ () << (namespace_ ().empty () ? L"" : L"#") - << name () << L"'"; - } - - - // unexpected_enumerator - // - template<> - inline - void unexpected_enumerator:: - print (std::basic_ostream& os) const - { - os << L"unexpected enumerator '" << enumerator () << L"'"; - } - - - // expected_text_content - // - template<> - inline - void expected_text_content:: - print (std::basic_ostream& os) const - { - os << L"expected text content"; - } - - - // no_type_info - // - template<> - inline - void no_type_info:: - print (std::basic_ostream& 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:: - print (std::basic_ostream& 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:: - print (std::basic_ostream& 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:: - print (std::basic_ostream& os) const - { - os << L"ID '" << id () << L"' already exist"; - } - - - // serialization - // - template<> - inline - void serialization:: - print (std::basic_ostream& os) const - { - if (diagnostics_.empty ()) - os << L"serialization failed"; - else - os << diagnostics_; - } - - - // no_prefix_mapping - // - template<> - inline - void no_prefix_mapping:: - print (std::basic_ostream& os) const - { - os << L"no mapping provided for namespace prefix '" - << prefix () << L"'"; - } - - - // bounds - // - template<> - inline - void bounds:: - print (std::basic_ostream& 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 + namespace xsd { namespace cxx @@ -33,6 +35,35 @@ namespace xsd { } + template + std::basic_ostream& + operator<< (std::basic_ostream& os, const error& e) + { + return os << e.id () << C (':') << e.line () << C (':') << e.column () + << (e.severity () == severity::error + ? bits::ex_error_error () + : bits::ex_error_warning ()) << e.message (); + } + + // diagnostics + // + template + std::basic_ostream& + operator<< (std::basic_ostream& os, const diagnostics& d) + { + for (typename diagnostics::const_iterator b (d.begin ()), i (b); + i != d.end (); + ++i) + { + if (i != b) + os << C ('\n'); + + os << *i; + } + + return os; + } + // parsing // template @@ -61,6 +92,15 @@ namespace xsd return "instance document parsing failed"; } + template + void parsing:: + print (std::basic_ostream& os) const + { + if (diagnostics_.empty ()) + os << bits::ex_parsing_msg (); + else + os << diagnostics_; + } // expected_element // @@ -85,6 +125,17 @@ namespace xsd return "expected element not encountered"; } + template + void expected_element:: + print (std::basic_ostream& os) const + { + os << bits::ex_eel_expected (); + + if (!namespace_ ().empty ()) + os << namespace_ () << C ('#'); + + os << name () << C ('\''); + } // unexpected_element // @@ -114,6 +165,34 @@ namespace xsd return "unexpected element encountered"; } + template + void unexpected_element:: + print (std::basic_ostream& os) const + { + if (!expected_name ().empty ()) + { + os << bits::ex_uel_expected (); + + if (!expected_namespace ().empty ()) + os << expected_namespace () << C ('#'); + + os << expected_name () << bits::ex_uel_instead (); + + if (!encountered_namespace ().empty ()) + os << encountered_namespace () << C ('#'); + + os << encountered_name () << C ('\''); + } + else + { + os << bits::ex_uel_unexpected (); + + 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 + void expected_attribute:: + print (std::basic_ostream& os) const + { + os << bits::ex_eat_expected (); + + if (!namespace_ ().empty ()) + os << namespace_ () << C ('#'); + + os << name () << C ('\''); + } // unexpected_enumerator // @@ -161,6 +251,12 @@ namespace xsd return "unexpected enumerator encountered"; } + template + void unexpected_enumerator:: + print (std::basic_ostream& os) const + { + os << bits::ex_uen_unexpected () << enumerator () << C ('\''); + } // expected_text_content // @@ -171,6 +267,12 @@ namespace xsd return "expected text content"; } + template + void expected_text_content:: + print (std::basic_ostream& os) const + { + os << bits::ex_etc_msg (); + } // no_type_info // @@ -196,6 +298,18 @@ namespace xsd return "no type information available for a type"; } + template + void no_type_info:: + print (std::basic_ostream& os) const + { + os << bits::ex_nti_no_type_info (); + + if (!type_namespace ().empty ()) + os << type_namespace () << C ('#'); + + os << type_name () << C ('\''); + } + // no_element_info // template @@ -221,6 +335,18 @@ namespace xsd "an element"; } + template + void no_element_info:: + print (std::basic_ostream& os) const + { + os << bits::ex_nei_no_element_info (); + + if (!element_namespace ().empty ()) + os << element_namespace () << C ('#'); + + os << element_name () << C ('\''); + } + // not_derived // template @@ -249,6 +375,22 @@ namespace xsd return "type is not derived"; } + template + void not_derived:: + print (std::basic_ostream& os) const + { + os << bits::ex_nd_type (); + + if (!derived_type_namespace ().empty ()) + os << derived_type_namespace () << C ('#'); + + os << derived_type_name () << bits::ex_nd_not_derived (); + + 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 + void duplicate_id:: + print (std::basic_ostream& os) const + { + os << bits::ex_di_id () << id () << bits::ex_di_already_exist (); + } // serialization // @@ -301,6 +449,16 @@ namespace xsd return "serialization failed"; } + template + void serialization:: + print (std::basic_ostream& os) const + { + if (diagnostics_.empty ()) + os << bits::ex_serialization_msg (); + else + os << diagnostics_; + } + // no_prefix_mapping // @@ -324,6 +482,13 @@ namespace xsd return "no mapping provided for a namespace prefix"; } + template + void no_prefix_mapping:: + print (std::basic_ostream& os) const + { + os << bits::ex_npm_no_mapping () << prefix () << C ('\''); + } + // bounds // @@ -333,6 +498,13 @@ namespace xsd { return "buffer boundary rules have been violated"; } + + template + void bounds:: + print (std::basic_ostream& os) const + { + os << bits::ex_bounds_msg (); + } } } } -- cgit v1.1