From f0510d2f90467de8e8f260b47d79a9baaf9bef17 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 17 Sep 2009 07:15:29 +0200 Subject: Start tracking XSD with git --- libxsd/xsd/cxx/xml/string.hxx | 90 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 libxsd/xsd/cxx/xml/string.hxx (limited to 'libxsd/xsd/cxx/xml/string.hxx') diff --git a/libxsd/xsd/cxx/xml/string.hxx b/libxsd/xsd/cxx/xml/string.hxx new file mode 100644 index 0000000..2d08134 --- /dev/null +++ b/libxsd/xsd/cxx/xml/string.hxx @@ -0,0 +1,90 @@ +// file : xsd/cxx/xml/string.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_XML_STRING_HXX +#define XSD_CXX_XML_STRING_HXX + +#include + +#include +#include // XMLCh + +namespace xsd +{ + namespace cxx + { + namespace xml + { + // + // + struct invalid_utf8_string {}; + struct invalid_utf16_string {}; + + + // Transcode a null-terminated string. + // + template + std::basic_string + transcode (const XMLCh* s); + + // Transcode a potentially non-null-terminated string. + // + template + std::basic_string + transcode (const XMLCh* s, std::size_t length); + + + // For VC7.1 wchar_t and XMLCh are the same type so we cannot + // overload the transcode name. You should not use these functions + // anyway and instead use the xml::string class below. + // + template + XMLCh* + transcode_to_xmlch (const C*); + + template + XMLCh* + transcode_to_xmlch (const std::basic_string& s); + + // + // + class string + { + public : + template + string (const std::basic_string& s) + : s_ (transcode_to_xmlch (s)) + { + } + + template + string (const C* s) + : s_ (transcode_to_xmlch (s)) + { + } + + const XMLCh* + c_str () const + { + return s_.get (); + } + + private: + string (const string&); + + string& + operator= (const string&); + + private: + auto_array s_; + }; + } + } +} + +#endif // XSD_CXX_XML_STRING_HXX + +#include +#include -- cgit v1.1