| 1 | // file : xsd/cxx/parser/schema-exceptions.ixx |
|---|
| 2 | // author : Boris Kolpackov <boris@codesynthesis.com> |
|---|
| 3 | // copyright : Copyright (c) 2005-2008 Code Synthesis Tools CC |
|---|
| 4 | // license : GNU GPL v2 + exceptions; see accompanying LICENSE file |
|---|
| 5 | |
|---|
| 6 | #if defined(XSD_CXX_PARSER_USE_CHAR) || !defined(XSD_CXX_PARSER_USE_WCHAR) |
|---|
| 7 | |
|---|
| 8 | #ifndef XSD_CXX_PARSER_SCHEMA_EXCEPTIONS_IXX_CHAR |
|---|
| 9 | #define XSD_CXX_PARSER_SCHEMA_EXCEPTIONS_IXX_CHAR |
|---|
| 10 | |
|---|
| 11 | namespace xsd |
|---|
| 12 | { |
|---|
| 13 | namespace cxx |
|---|
| 14 | { |
|---|
| 15 | namespace parser |
|---|
| 16 | { |
|---|
| 17 | // expected_element |
|---|
| 18 | // |
|---|
| 19 | template<> |
|---|
| 20 | inline |
|---|
| 21 | std::basic_string<char> expected_element<char>:: |
|---|
| 22 | message () const |
|---|
| 23 | { |
|---|
| 24 | std::basic_string<char> r ("expected element '"); |
|---|
| 25 | r += expected_namespace_; |
|---|
| 26 | r += expected_namespace_.empty () ? "" : "#"; |
|---|
| 27 | r += expected_name_; |
|---|
| 28 | r += "'"; |
|---|
| 29 | |
|---|
| 30 | if (!encountered_name_.empty ()) |
|---|
| 31 | { |
|---|
| 32 | r += " instead of '"; |
|---|
| 33 | r += encountered_namespace_; |
|---|
| 34 | r += encountered_namespace_.empty () ? "" : "#"; |
|---|
| 35 | r += encountered_name_; |
|---|
| 36 | r += "'"; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | return r; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | // unexpected_element |
|---|
| 43 | // |
|---|
| 44 | template<> |
|---|
| 45 | inline |
|---|
| 46 | std::basic_string<char> unexpected_element<char>:: |
|---|
| 47 | message () const |
|---|
| 48 | { |
|---|
| 49 | std::basic_string<char> r ("unexpected element '"); |
|---|
| 50 | r += encountered_namespace_; |
|---|
| 51 | r += encountered_namespace_.empty () ? "" : "#"; |
|---|
| 52 | r += encountered_name_; |
|---|
| 53 | r += "'"; |
|---|
| 54 | return r; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | // dynamic_type |
|---|
| 58 | // |
|---|
| 59 | template<> |
|---|
| 60 | inline |
|---|
| 61 | std::basic_string<char> dynamic_type<char>:: |
|---|
| 62 | message () const |
|---|
| 63 | { |
|---|
| 64 | std::basic_string<char> r ("invalid xsi:type '"); |
|---|
| 65 | r += type_; |
|---|
| 66 | r += "'"; |
|---|
| 67 | return r; |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | #endif // XSD_CXX_PARSER_SCHEMA_EXCEPTIONS_IXX_CHAR |
|---|
| 74 | #endif // XSD_CXX_PARSER_USE_CHAR |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | #if defined(XSD_CXX_PARSER_USE_WCHAR) || !defined(XSD_CXX_PARSER_USE_CHAR) |
|---|
| 78 | |
|---|
| 79 | #ifndef XSD_CXX_PARSER_SCHEMA_EXCEPTIONS_IXX_WCHAR |
|---|
| 80 | #define XSD_CXX_PARSER_SCHEMA_EXCEPTIONS_IXX_WCHAR |
|---|
| 81 | |
|---|
| 82 | namespace xsd |
|---|
| 83 | { |
|---|
| 84 | namespace cxx |
|---|
| 85 | { |
|---|
| 86 | namespace parser |
|---|
| 87 | { |
|---|
| 88 | // expected_element |
|---|
| 89 | // |
|---|
| 90 | template<> |
|---|
| 91 | inline |
|---|
| 92 | std::basic_string<wchar_t> expected_element<wchar_t>:: |
|---|
| 93 | message () const |
|---|
| 94 | { |
|---|
| 95 | std::basic_string<wchar_t> r (L"expected element '"); |
|---|
| 96 | r += expected_namespace_; |
|---|
| 97 | r += expected_namespace_.empty () ? L"" : L"#"; |
|---|
| 98 | r += expected_name_; |
|---|
| 99 | r += L"'"; |
|---|
| 100 | |
|---|
| 101 | if (!encountered_name_.empty ()) |
|---|
| 102 | { |
|---|
| 103 | r += L" instead of '"; |
|---|
| 104 | r += encountered_namespace_; |
|---|
| 105 | r += encountered_namespace_.empty () ? L"" : L"#"; |
|---|
| 106 | r += encountered_name_; |
|---|
| 107 | r += L"'"; |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | return r; |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | // unexpected_element |
|---|
| 114 | // |
|---|
| 115 | template<> |
|---|
| 116 | inline |
|---|
| 117 | std::basic_string<wchar_t> unexpected_element<wchar_t>:: |
|---|
| 118 | message () const |
|---|
| 119 | { |
|---|
| 120 | std::basic_string<wchar_t> r (L"unexpected element '"); |
|---|
| 121 | r += encountered_namespace_; |
|---|
| 122 | r += encountered_namespace_.empty () ? L"" : L"#"; |
|---|
| 123 | r += encountered_name_; |
|---|
| 124 | r += L"'"; |
|---|
| 125 | return r; |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | // dynamic_type |
|---|
| 129 | // |
|---|
| 130 | template<> |
|---|
| 131 | inline |
|---|
| 132 | std::basic_string<wchar_t> dynamic_type<wchar_t>:: |
|---|
| 133 | message () const |
|---|
| 134 | { |
|---|
| 135 | std::basic_string<wchar_t> r (L"invalid xsi:type '"); |
|---|
| 136 | r += type_; |
|---|
| 137 | r += L"'"; |
|---|
| 138 | return r; |
|---|
| 139 | } |
|---|
| 140 | } |
|---|
| 141 | } |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | #endif // XSD_CXX_PARSER_SCHEMA_EXCEPTIONS_IXX_WCHAR |
|---|
| 145 | #endif // XSD_CXX_PARSER_USE_WCHAR |
|---|