diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-12-08 16:18:01 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-12-08 16:18:01 +0200 |
commit | 1ca6396a3dd284241de11bcaa210ad5836e8e5a8 (patch) | |
tree | 465c19f0d668a91bb556d748911847acfb80cb09 /libxsd/xsd/cxx/xml/char-lcp.txx | |
parent | d71611d5fb575078bdf573c35257bb86bb7054e0 (diff) |
Multiple object model character encodings support
Also add support for ISO-8859-1.
Diffstat (limited to 'libxsd/xsd/cxx/xml/char-lcp.txx')
-rw-r--r-- | libxsd/xsd/cxx/xml/char-lcp.txx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/libxsd/xsd/cxx/xml/char-lcp.txx b/libxsd/xsd/cxx/xml/char-lcp.txx new file mode 100644 index 0000000..01bb36e --- /dev/null +++ b/libxsd/xsd/cxx/xml/char-lcp.txx @@ -0,0 +1,55 @@ +// file : xsd/cxx/xml/char-lcp.txx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <cstring> // std::memcpy + +#include <xercesc/util/XMLString.hpp> + +#include <xsd/cxx/auto-array.hxx> +#include <xsd/cxx/xml/std-memory-manager.hxx> + +namespace xsd +{ + namespace cxx + { + namespace xml + { + template <typename C> + std::basic_string<C> char_lcp_transcoder<C>:: + to (const XMLCh* s) + { + std_memory_manager mm; + auto_array<C, std_memory_manager> r ( + xercesc::XMLString::transcode (s, &mm), mm); + return std::basic_string<C> (r.get ()); + } + + template <typename C> + std::basic_string<C> char_lcp_transcoder<C>:: + to (const XMLCh* s, std::size_t len) + { + auto_array<XMLCh> tmp (new XMLCh[len + 1]); + std::memcpy (tmp.get (), s, len * sizeof (XMLCh)); + tmp[len] = XMLCh (0); + + std_memory_manager mm; + auto_array<C, std_memory_manager> r ( + xercesc::XMLString::transcode (tmp.get (), &mm), mm); + + tmp.reset (); + + return std::basic_string<C> (r.get ()); + } + + template <typename C> + XMLCh* char_lcp_transcoder<C>:: + from (const C* s) + { + std_memory_manager mm; + return xercesc::XMLString::transcode (s, &mm); + } + } + } +} |