aboutsummaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/xml/char-iso8859-1.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-12-08 16:18:01 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-12-08 16:18:01 +0200
commit1ca6396a3dd284241de11bcaa210ad5836e8e5a8 (patch)
tree465c19f0d668a91bb556d748911847acfb80cb09 /libxsd/xsd/cxx/xml/char-iso8859-1.hxx
parentd71611d5fb575078bdf573c35257bb86bb7054e0 (diff)
Multiple object model character encodings support
Also add support for ISO-8859-1.
Diffstat (limited to 'libxsd/xsd/cxx/xml/char-iso8859-1.hxx')
-rw-r--r--libxsd/xsd/cxx/xml/char-iso8859-1.hxx72
1 files changed, 72 insertions, 0 deletions
diff --git a/libxsd/xsd/cxx/xml/char-iso8859-1.hxx b/libxsd/xsd/cxx/xml/char-iso8859-1.hxx
new file mode 100644
index 0000000..38b633f
--- /dev/null
+++ b/libxsd/xsd/cxx/xml/char-iso8859-1.hxx
@@ -0,0 +1,72 @@
+// file : xsd/cxx/xml/char-iso8859-1.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_XML_TRANSCODER
+#define XSD_CXX_XML_TRANSCODER
+#define XSD_CXX_XML_TRANSCODER_CHAR_ISO8859_1
+
+#include <string>
+#include <cstddef> // std::size_t
+
+#include <xercesc/util/XercesDefs.hpp> // XMLCh
+
+#include <xsd/cxx/xml/exceptions.hxx> // invalid_utf16_string
+
+namespace xsd
+{
+ namespace cxx
+ {
+ namespace xml
+ {
+ struct iso8859_1_unrepresentable {};
+
+ // UTF-16 to/from ISO-8859-1 transcoder.
+ //
+ template <typename C>
+ struct char_iso8859_1_transcoder
+ {
+ static std::basic_string<C>
+ to (const XMLCh* s, std::size_t length);
+
+ static XMLCh*
+ from (const C* s, std::size_t length);
+
+ // Get/set a replacement for unrepresentable characters. If set to
+ // 0 (the default value), throw iso8859_1_unrepresentable instead.
+ //
+ static C
+ unrep_char ()
+ {
+ return unrep_char_;
+ }
+
+ static void
+ unrep_char (C c)
+ {
+ unrep_char_ = c;
+ }
+
+ private:
+ static C unrep_char_;
+ };
+
+ typedef char_iso8859_1_transcoder<char> char_transcoder;
+ }
+ }
+}
+
+#include <xsd/cxx/xml/char-iso8859-1.txx>
+
+#else
+# ifndef XSD_CXX_XML_TRANSCODER_CHAR_ISO8859_1
+ //
+ // If you get this error, it usually means that either you compiled
+ // your schemas with different --char-encoding values or you included
+ // some of the libxsd headers (e.g., xsd/cxx/xml/string.hxx) directly
+ // without first including the correct xsd/cxx/xml/char-*.hxx header.
+ //
+# error conflicting character encoding detected
+# endif
+#endif // XSD_CXX_XML_TRANSCODER