/usr/include/boost/archive/impl
Edit: /usr/include/boost/archive/impl/xml_wiarchive_impl.ipp (5245B)
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_wiarchive_impl.ipp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::memcpy;
} //std
#endif
#include // msvc 6.0 needs this to suppress warnings
#ifndef BOOST_NO_STD_WSTREAMBUF
#include
#include // std::copy
#include // Dinkumware and RogueWave
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "basic_xml_grammar.hpp"
namespace boost {
namespace archive {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implemenations of functions specific to wide char archives
namespace { // anonymous
void copy_to_ptr(char * s, const std::wstring & ws){
std::copy(
iterators::mb_from_wchar(
ws.begin()
),
iterators::mb_from_wchar(
ws.end()
),
s
);
s[ws.size()] = 0;
}
} // anonymous
template
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl::load(std::string & s){
std::wstring ws;
bool result = gimpl->parse_string(is, ws);
if(! result)
boost::serialization::throw_exception(
xml_archive_exception(xml_archive_exception::xml_archive_parsing_error)
);
#if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
if(NULL != s.data())
#endif
s.resize(0);
s.reserve(ws.size());
std::copy(
iterators::mb_from_wchar(
ws.begin()
),
iterators::mb_from_wchar(
ws.end()
),
std::back_inserter(s)
);
}
#ifndef BOOST_NO_STD_WSTRING
template
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl::load(std::wstring & ws){
bool result = gimpl->parse_string(is, ws);
if(! result)
boost::serialization::throw_exception(
xml_archive_exception(xml_archive_exception::xml_archive_parsing_error)
);
}
#endif
template
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl::load(char * s){
std::wstring ws;
bool result = gimpl->parse_string(is, ws);
if(! result)
boost::serialization::throw_exception(
xml_archive_exception(xml_archive_exception::xml_archive_parsing_error)
);
copy_to_ptr(s, ws);
}
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl::load(wchar_t * ws){
std::wstring twstring;
bool result = gimpl->parse_string(is, twstring);
if(! result)
boost::serialization::throw_exception(
xml_archive_exception(xml_archive_exception::xml_archive_parsing_error)
);
std::memcpy(ws, twstring.c_str(), twstring.size());
ws[twstring.size()] = L'\0';
}
#endif
template
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl::load_override(class_name_type & t){
const std::wstring & ws = gimpl->rv.class_name;
if(ws.size() > BOOST_SERIALIZATION_MAX_KEY_SIZE - 1)
boost::serialization::throw_exception(
archive_exception(archive_exception::invalid_class_name)
);
copy_to_ptr(t, ws);
}
template
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl::init(){
gimpl->init(is);
this->set_library_version(
boost::serialization::library_version_type(gimpl->rv.version)
);
}
template
BOOST_WARCHIVE_DECL
xml_wiarchive_impl::xml_wiarchive_impl(
std::wistream &is_,
unsigned int flags
) :
basic_text_iprimitive(
is_,
true // don't change the codecvt - use the one below
),
basic_xml_iarchive(flags),
gimpl(new xml_wgrammar())
{
if(0 == (flags & no_codecvt)){
archive_locale = std::locale(
is_.getloc(),
new boost::archive::detail::utf8_codecvt_facet
);
// libstdc++ crashes without this
is_.sync();
is_.imbue(archive_locale);
}
}
template
BOOST_WARCHIVE_DECL
xml_wiarchive_impl::~xml_wiarchive_impl(){
if(boost::core::uncaught_exceptions() > 0)
return;
if(0 == (this->get_flags() & no_header)){
gimpl->windup(is);
}
}
} // namespace archive
} // namespace boost
#endif // BOOST_NO_STD_WSTREAMBUF