mirror of
https://github.com/boostorg/serialization.git
synced 2026-07-21 13:33:32 +00:00
remove dependency on <codecvt>
This header seems to have errors in some environments. It has been deprecated by the C++ committe. For these reasons, we'll rely solely on Ron Garcia's code convert facet for utf.
This commit is contained in:
@@ -13,27 +13,17 @@
|
||||
#error "wide char i/o not supported on this platform"
|
||||
#endif
|
||||
|
||||
// std::codecvt_utf8 doesn't seem to work for any versions of msvc
|
||||
// use boost's utf8 codecvt facet
|
||||
#include <boost/archive/detail/decl.hpp>
|
||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||
namespace boost { namespace archive { namespace detail {
|
||||
#define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL
|
||||
#define BOOST_UTF8_END_NAMESPACE }}}
|
||||
|
||||
#if defined(_MSC_VER) || defined(BOOST_NO_CXX11_HDR_CODECVT)
|
||||
// use boost's utf8 codecvt facet
|
||||
#include <boost/archive/detail/decl.hpp>
|
||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||
namespace boost { namespace archive { namespace detail {
|
||||
#define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL
|
||||
#define BOOST_UTF8_END_NAMESPACE }}}
|
||||
#include <boost/detail/utf8_codecvt_facet.hpp>
|
||||
|
||||
#include <boost/detail/utf8_codecvt_facet.hpp>
|
||||
|
||||
#undef BOOST_UTF8_END_NAMESPACE
|
||||
#undef BOOST_UTF8_DECL
|
||||
#undef BOOST_UTF8_BEGIN_NAMESPACE
|
||||
#else
|
||||
// use the standard vendor supplied facet
|
||||
#include <codecvt>
|
||||
namespace boost { namespace archive { namespace detail {
|
||||
typedef std::codecvt_utf8<wchar_t> utf8_codecvt_facet;
|
||||
} } }
|
||||
#endif
|
||||
#undef BOOST_UTF8_END_NAMESPACE
|
||||
#undef BOOST_UTF8_DECL
|
||||
#undef BOOST_UTF8_BEGIN_NAMESPACE
|
||||
|
||||
#endif // BOOST_ARCHIVE_DETAIL_UTF8_CODECVT_FACET_HPP
|
||||
|
||||
@@ -161,13 +161,13 @@ xml_wiarchive_impl<Archive>::xml_wiarchive_impl(
|
||||
gimpl(new xml_wgrammar())
|
||||
{
|
||||
if(0 == (flags & no_codecvt)){
|
||||
std::locale l = std::locale(
|
||||
archive_locale = std::locale(
|
||||
is_.getloc(),
|
||||
new boost::archive::detail::utf8_codecvt_facet
|
||||
);
|
||||
// libstdc++ crashes without this
|
||||
is_.sync();
|
||||
is_.imbue(l);
|
||||
is_.imbue(archive_locale);
|
||||
}
|
||||
if(0 == (flags & no_header))
|
||||
init();
|
||||
|
||||
@@ -103,7 +103,6 @@ xml_woarchive_impl<Archive>::save(const char * s){
|
||||
template<class Archive>
|
||||
BOOST_WARCHIVE_DECL void
|
||||
xml_woarchive_impl<Archive>::save(const wchar_t * ws){
|
||||
os << ws;
|
||||
typedef iterators::xml_escape<const wchar_t *> xmbtows;
|
||||
std::copy(
|
||||
xmbtows(ws),
|
||||
@@ -126,12 +125,12 @@ xml_woarchive_impl<Archive>::xml_woarchive_impl(
|
||||
basic_xml_oarchive<Archive>(flags)
|
||||
{
|
||||
if(0 == (flags & no_codecvt)){
|
||||
std::locale l = std::locale(
|
||||
archive_locale = std::locale(
|
||||
os_.getloc(),
|
||||
new boost::archive::detail::utf8_codecvt_facet
|
||||
);
|
||||
os_.flush();
|
||||
os_.imbue(l);
|
||||
os_.imbue(archive_locale);
|
||||
}
|
||||
if(0 == (flags & no_header))
|
||||
this->init();
|
||||
@@ -143,7 +142,7 @@ xml_woarchive_impl<Archive>::~xml_woarchive_impl(){
|
||||
if(std::uncaught_exception())
|
||||
return;
|
||||
if(0 == (this->get_flags() & no_header)){
|
||||
save(L"</boost_serialization>\n");
|
||||
os << L"</boost_serialization>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ protected:
|
||||
friend class basic_xml_iarchive<Archive>;
|
||||
friend class load_access;
|
||||
#endif
|
||||
std::locale archive_locale;
|
||||
boost::scoped_ptr<xml_wgrammar> gimpl;
|
||||
std::wistream & get_is(){
|
||||
return is;
|
||||
|
||||
@@ -77,6 +77,14 @@ archive_exception::archive_exception(
|
||||
break;
|
||||
case input_stream_error:
|
||||
length = append(length, "input stream error");
|
||||
if(NULL != e1){
|
||||
length = append(length, "-");
|
||||
length = append(length, e1);
|
||||
}
|
||||
if(NULL != e2){
|
||||
length = append(length, "-");
|
||||
length = append(length, e2);
|
||||
}
|
||||
break;
|
||||
case invalid_class_name:
|
||||
length = append(length, "class name too long");
|
||||
@@ -105,6 +113,14 @@ archive_exception::archive_exception(
|
||||
break;
|
||||
case output_stream_error:
|
||||
length = append(length, "output stream error");
|
||||
if(NULL != e1){
|
||||
length = append(length, "-");
|
||||
length = append(length, e1);
|
||||
}
|
||||
if(NULL != e2){
|
||||
length = append(length, "-");
|
||||
length = append(length, e2);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BOOST_ASSERT(false);
|
||||
|
||||
@@ -77,10 +77,12 @@ BOOST_ARCHIVE_SIGNATURE(){
|
||||
// 13- simplified visibility, removed Borland, removed pfto
|
||||
// 14- improved visibility, refactor map/set
|
||||
// 15- corrections to optional and collection loading
|
||||
// 16- eliminated dependency on <codecvt> which is buggy in some libraries
|
||||
// and now officially deprecated in the standard
|
||||
|
||||
BOOST_SYMBOL_VISIBLE library_version_type
|
||||
BOOST_ARCHIVE_VERSION(){
|
||||
return library_version_type(15);
|
||||
return library_version_type(16);
|
||||
}
|
||||
|
||||
} // namespace archive
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
# pragma warning(disable : 4244 4511 4512)
|
||||
#endif
|
||||
|
||||
#include <cerrno> // errno
|
||||
#include <cstring> // strerror(errno)
|
||||
|
||||
// spirit stuff
|
||||
#include <boost/spirit/include/classic_operators.hpp>
|
||||
#include <boost/spirit/include/classic_actions.hpp>
|
||||
@@ -31,7 +34,6 @@
|
||||
#endif
|
||||
|
||||
// for head_iterator test
|
||||
//#include <boost/bind.hpp>
|
||||
#include <boost/function.hpp>
|
||||
|
||||
#include <boost/io/ios_state.hpp>
|
||||
@@ -188,8 +190,14 @@ bool basic_xml_grammar<CharType>::my_parse(
|
||||
for(;;){
|
||||
CharType result;
|
||||
is.get(result);
|
||||
if(is.fail())
|
||||
return false;
|
||||
if(is.fail()){
|
||||
boost::serialization::throw_exception(
|
||||
boost::archive::archive_exception(
|
||||
archive_exception::input_stream_error,
|
||||
std::strerror(errno)
|
||||
)
|
||||
);
|
||||
}
|
||||
if(is.eof())
|
||||
return false;
|
||||
arg += result;
|
||||
|
||||
+11
-15
@@ -9,18 +9,14 @@
|
||||
#error "wide char i/o not supported on this platform"
|
||||
#endif
|
||||
|
||||
// std::codecvt_utf8 doesn't seem to work for any versions of msvc
|
||||
#if defined(_MSC_VER) \
|
||||
|| defined( BOOST_NO_CXX11_HDR_CODECVT )
|
||||
// include boost implementation of utf8 codecvt facet
|
||||
# define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/archive/detail/decl.hpp>
|
||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||
namespace boost { namespace archive { namespace detail {
|
||||
#define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL
|
||||
#define BOOST_UTF8_END_NAMESPACE }}}
|
||||
#include <boost/detail/utf8_codecvt_facet.ipp>
|
||||
#undef BOOST_UTF8_END_NAMESPACE
|
||||
#undef BOOST_UTF8_DECL
|
||||
#undef BOOST_UTF8_BEGIN_NAMESPACE
|
||||
#endif
|
||||
// include boost implementation of utf8 codecvt facet
|
||||
# define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/archive/detail/decl.hpp>
|
||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||
namespace boost { namespace archive { namespace detail {
|
||||
#define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL
|
||||
#define BOOST_UTF8_END_NAMESPACE }}}
|
||||
#include <boost/detail/utf8_codecvt_facet.ipp>
|
||||
#undef BOOST_UTF8_END_NAMESPACE
|
||||
#undef BOOST_UTF8_DECL
|
||||
#undef BOOST_UTF8_BEGIN_NAMESPACE
|
||||
|
||||
+1
-5
@@ -147,11 +147,7 @@ if ! $(BOOST_ARCHIVE_LIST) {
|
||||
[ test-bsl-run test_iterators ]
|
||||
[ test-bsl-run test_iterators_base64 ]
|
||||
[ test-bsl-run test_smart_cast ]
|
||||
[ test-bsl-run test_codecvt_null
|
||||
: ../src/codecvt_null
|
||||
:
|
||||
: [ requires std_wstreambuf ]
|
||||
]
|
||||
[ test-bsl-run test_codecvt_null ]
|
||||
|
||||
#[ test-bsl-run test_z ]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user