stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork

This commit is contained in:
2026-02-24 18:38:47 +00:00
parent da8c28aaeb
commit 65cb2619a7
13106 changed files with 2484322 additions and 1804 deletions
@@ -0,0 +1,71 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// archive_serializer_map.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.
//////////////////////////////////////////////////////////////////////
// implementation of basic_text_iprimitive overrides for the combination
// of template parameters used to implement a text_iprimitive
#include <boost/config.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
#include <boost/archive/detail/basic_serializer_map.hpp>
#include <boost/serialization/singleton.hpp>
namespace boost {
namespace archive {
namespace detail {
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4511 4512)
#endif
namespace extra_detail { // anon
template<class Archive>
class map : public basic_serializer_map
{};
}
#ifdef BOOST_MSVC
# pragma warning(pop)
#endif
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL bool
archive_serializer_map<Archive>::insert(const basic_serializer * bs){
return boost::serialization::singleton<
extra_detail::map<Archive>
>::get_mutable_instance().insert(bs);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
archive_serializer_map<Archive>::erase(const basic_serializer * bs){
if(boost::serialization::singleton<
extra_detail::map<Archive>
>::is_destroyed())
return;
boost::serialization::singleton<
extra_detail::map<Archive>
>::get_mutable_instance().erase(bs);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL const basic_serializer *
archive_serializer_map<Archive>::find(
const boost::serialization::extended_type_info & eti
) {
return boost::serialization::singleton<
extra_detail::map<Archive>
>::get_const_instance().find(eti);
}
} // namespace detail
} // namespace archive
} // namespace boost
@@ -0,0 +1,134 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_binary_iarchive.ipp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to 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 <string>
#include <boost/assert.hpp>
#include <algorithm>
#include <cstring>
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::memcpy;
using ::strlen;
using ::size_t;
}
#endif
#include <boost/detail/workaround.hpp>
#include <boost/detail/endian.hpp>
#include <boost/archive/basic_binary_iarchive.hpp>
namespace boost {
namespace archive {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implementation of binary_binary_archive
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iarchive<Archive>::load_override(class_name_type & t){
std::string cn;
cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE);
load_override(cn);
if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1))
boost::serialization::throw_exception(
archive_exception(archive_exception::invalid_class_name)
);
std::memcpy(t, cn.data(), cn.size());
// borland tweak
t.t[cn.size()] = '\0';
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iarchive<Archive>::init(void){
// read signature in an archive version independent manner
std::string file_signature;
#if 0 // commented out since it interfers with derivation
BOOST_TRY {
std::size_t l;
this->This()->load(l);
if(l == std::strlen(BOOST_ARCHIVE_SIGNATURE())) {
// borland de-allocator fixup
#if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
if(NULL != file_signature.data())
#endif
file_signature.resize(l);
// note breaking a rule here - could be a problem on some platform
if(0 < l)
this->This()->load_binary(&(*file_signature.begin()), l);
}
}
BOOST_CATCH(archive_exception const &) { // catch stream_error archive exceptions
// will cause invalid_signature archive exception to be thrown below
file_signature = "";
}
BOOST_CATCH_END
#else
// https://svn.boost.org/trac/boost/ticket/7301
* this->This() >> file_signature;
#endif
if(file_signature != BOOST_ARCHIVE_SIGNATURE())
boost::serialization::throw_exception(
archive_exception(archive_exception::invalid_signature)
);
// make sure the version of the reading archive library can
// support the format of the archive being read
library_version_type input_library_version;
//* this->This() >> input_library_version;
{
int v = 0;
v = this->This()->m_sb.sbumpc();
#if defined(BOOST_LITTLE_ENDIAN)
if(v < 6){
;
}
else
if(v < 7){
// version 6 - next byte should be zero
this->This()->m_sb.sbumpc();
}
else
if(v < 8){
int x1;
// version 7 = might be followed by zero or some other byte
x1 = this->This()->m_sb.sgetc();
// it's =a zero, push it back
if(0 == x1)
this->This()->m_sb.sbumpc();
}
else{
// version 8+ followed by a zero
this->This()->m_sb.sbumpc();
}
#elif defined(BOOST_BIG_ENDIAN)
if(v == 0)
v = this->This()->m_sb.sbumpc();
#endif
input_library_version = static_cast<library_version_type>(v);
}
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
this->set_library_version(input_library_version);
#else
detail::basic_iarchive::set_library_version(input_library_version);
#endif
if(BOOST_ARCHIVE_VERSION() < input_library_version)
boost::serialization::throw_exception(
archive_exception(archive_exception::unsupported_version)
);
}
} // namespace archive
} // namespace boost
@@ -0,0 +1,171 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_binary_iprimitive.ipp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to 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 <boost/assert.hpp>
#include <cstddef> // size_t, NULL
#include <cstring> // memcpy
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::size_t;
using ::memcpy;
} // namespace std
#endif
#include <boost/serialization/throw_exception.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/basic_binary_iprimitive.hpp>
namespace boost {
namespace archive {
//////////////////////////////////////////////////////////////////////
// implementation of basic_binary_iprimitive
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iprimitive<Archive, Elem, Tr>::init()
{
// Detect attempts to pass native binary archives across
// incompatible platforms. This is not fool proof but its
// better than nothing.
unsigned char size;
this->This()->load(size);
if(sizeof(int) != size)
boost::serialization::throw_exception(
archive_exception(
archive_exception::incompatible_native_format,
"size of int"
)
);
this->This()->load(size);
if(sizeof(long) != size)
boost::serialization::throw_exception(
archive_exception(
archive_exception::incompatible_native_format,
"size of long"
)
);
this->This()->load(size);
if(sizeof(float) != size)
boost::serialization::throw_exception(
archive_exception(
archive_exception::incompatible_native_format,
"size of float"
)
);
this->This()->load(size);
if(sizeof(double) != size)
boost::serialization::throw_exception(
archive_exception(
archive_exception::incompatible_native_format,
"size of double"
)
);
// for checking endian
int i;
this->This()->load(i);
if(1 != i)
boost::serialization::throw_exception(
archive_exception(
archive_exception::incompatible_native_format,
"endian setting"
)
);
}
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iprimitive<Archive, Elem, Tr>::load(wchar_t * ws)
{
std::size_t l; // number of wchar_t !!!
this->This()->load(l);
load_binary(ws, l * sizeof(wchar_t) / sizeof(char));
ws[l] = L'\0';
}
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iprimitive<Archive, Elem, Tr>::load(std::string & s)
{
std::size_t l;
this->This()->load(l);
// borland de-allocator fixup
#if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
if(NULL != s.data())
#endif
s.resize(l);
// note breaking a rule here - could be a problem on some platform
if(0 < l)
load_binary(&(*s.begin()), l);
}
#ifndef BOOST_NO_CWCHAR
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iprimitive<Archive, Elem, Tr>::load(char * s)
{
std::size_t l;
this->This()->load(l);
load_binary(s, l);
s[l] = '\0';
}
#endif
#ifndef BOOST_NO_STD_WSTRING
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iprimitive<Archive, Elem, Tr>::load(std::wstring & ws)
{
std::size_t l;
this->This()->load(l);
// borland de-allocator fixup
#if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
if(NULL != ws.data())
#endif
ws.resize(l);
// note breaking a rule here - is could be a problem on some platform
load_binary(const_cast<wchar_t *>(ws.data()), l * sizeof(wchar_t) / sizeof(char));
}
#endif
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_binary_iprimitive<Archive, Elem, Tr>::basic_binary_iprimitive(
std::basic_streambuf<Elem, Tr> & sb,
bool no_codecvt
) :
#ifndef BOOST_NO_STD_LOCALE
m_sb(sb),
codecvt_null_facet(1),
locale_saver(m_sb),
archive_locale(sb.getloc(), & codecvt_null_facet)
{
if(! no_codecvt){
m_sb.pubsync();
m_sb.pubimbue(archive_locale);
}
}
#else
m_sb(sb)
{}
#endif
// scoped_ptr requires that g be a complete type at time of
// destruction so define destructor here rather than in the header
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_binary_iprimitive<Archive, Elem, Tr>::~basic_binary_iprimitive(){}
} // namespace archive
} // namespace boost
@@ -0,0 +1,42 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_binary_oarchive.ipp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to 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 <string>
#include <boost/assert.hpp>
#include <algorithm>
#include <cstring>
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::memcpy;
}
#endif
#include <boost/archive/basic_binary_oarchive.hpp>
namespace boost {
namespace archive {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implementation of binary_binary_oarchive
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_oarchive<Archive>::init(){
// write signature in an archive version independent manner
const std::string file_signature(BOOST_ARCHIVE_SIGNATURE());
* this->This() << file_signature;
// write library version
const library_version_type v(BOOST_ARCHIVE_VERSION());
* this->This() << v;
}
} // namespace archive
} // namespace boost
@@ -0,0 +1,124 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_binary_oprimitive.ipp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to 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 <ostream>
#include <cstddef> // NULL
#include <cstring>
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE) && ! defined(__LIBCOMO__)
namespace std{
using ::strlen;
} // namespace std
#endif
#ifndef BOOST_NO_CWCHAR
#include <cwchar>
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std{ using ::wcslen; }
#endif
#endif
#include <boost/archive/basic_binary_oprimitive.hpp>
#include <boost/core/no_exceptions_support.hpp>
namespace boost {
namespace archive {
//////////////////////////////////////////////////////////////////////
// implementation of basic_binary_oprimitive
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_oprimitive<Archive, Elem, Tr>::init()
{
// record native sizes of fundamental types
// this is to permit detection of attempts to pass
// native binary archives accross incompatible machines.
// This is not foolproof but its better than nothing.
this->This()->save(static_cast<unsigned char>(sizeof(int)));
this->This()->save(static_cast<unsigned char>(sizeof(long)));
this->This()->save(static_cast<unsigned char>(sizeof(float)));
this->This()->save(static_cast<unsigned char>(sizeof(double)));
// for checking endianness
this->This()->save(int(1));
}
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_oprimitive<Archive, Elem, Tr>::save(const char * s)
{
std::size_t l = std::strlen(s);
this->This()->save(l);
save_binary(s, l);
}
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_oprimitive<Archive, Elem, Tr>::save(const std::string &s)
{
std::size_t l = static_cast<std::size_t>(s.size());
this->This()->save(l);
save_binary(s.data(), l);
}
#ifndef BOOST_NO_CWCHAR
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_oprimitive<Archive, Elem, Tr>::save(const wchar_t * ws)
{
std::size_t l = std::wcslen(ws);
this->This()->save(l);
save_binary(ws, l * sizeof(wchar_t) / sizeof(char));
}
#endif
#ifndef BOOST_NO_STD_WSTRING
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_oprimitive<Archive, Elem, Tr>::save(const std::wstring &ws)
{
std::size_t l = ws.size();
this->This()->save(l);
save_binary(ws.data(), l * sizeof(wchar_t) / sizeof(char));
}
#endif
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_binary_oprimitive<Archive, Elem, Tr>::basic_binary_oprimitive(
std::basic_streambuf<Elem, Tr> & sb,
bool no_codecvt
) :
#ifndef BOOST_NO_STD_LOCALE
m_sb(sb),
codecvt_null_facet(1),
locale_saver(m_sb),
archive_locale(sb.getloc(), & codecvt_null_facet)
{
if(! no_codecvt){
m_sb.pubsync();
m_sb.pubimbue(archive_locale);
}
}
#else
m_sb(sb)
{}
#endif
// scoped_ptr requires that g be a complete type at time of
// destruction so define destructor here rather than in the header
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_binary_oprimitive<Archive, Elem, Tr>::~basic_binary_oprimitive(){}
} // namespace archive
} // namespace boost
@@ -0,0 +1,76 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_text_iarchive.ipp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to 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 <string>
#include <algorithm>
#include <cstring>
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::memcpy;
}
#endif
#include <boost/detail/workaround.hpp>
#include <boost/serialization/string.hpp>
#include <boost/archive/basic_text_iarchive.hpp>
namespace boost {
namespace archive {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implementation of text_text_archive
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_text_iarchive<Archive>::load_override(class_name_type & t){
std::string cn;
cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE);
load_override(cn);
if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1))
boost::serialization::throw_exception(
archive_exception(archive_exception::invalid_class_name)
);
std::memcpy(t, cn.data(), cn.size());
// borland tweak
t.t[cn.size()] = '\0';
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_text_iarchive<Archive>::init(void){
// read signature in an archive version independent manner
std::string file_signature;
* this->This() >> file_signature;
if(file_signature != BOOST_ARCHIVE_SIGNATURE())
boost::serialization::throw_exception(
archive_exception(archive_exception::invalid_signature)
);
// make sure the version of the reading archive library can
// support the format of the archive being read
library_version_type input_library_version;
* this->This() >> input_library_version;
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
this->set_library_version(input_library_version);
#else
detail::basic_iarchive::set_library_version(input_library_version);
#endif
// extra little .t is to get around borland quirk
if(BOOST_ARCHIVE_VERSION() < input_library_version)
boost::serialization::throw_exception(
archive_exception(archive_exception::unsupported_version)
);
}
} // namespace archive
} // namespace boost
@@ -0,0 +1,137 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_text_iprimitive.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 <cstddef> // size_t, NULL
#include <limits> // NULL
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::size_t;
} // namespace std
#endif
#include <boost/serialization/throw_exception.hpp>
#include <boost/archive/basic_text_iprimitive.hpp>
#include <boost/archive/iterators/remove_whitespace.hpp>
#include <boost/archive/iterators/istream_iterator.hpp>
#include <boost/archive/iterators/binary_from_base64.hpp>
#include <boost/archive/iterators/transform_width.hpp>
namespace boost {
namespace archive {
namespace detail {
template<class CharType>
static inline bool is_whitespace(CharType c);
template<>
inline bool is_whitespace(char t){
return 0 != std::isspace(t);
}
#ifndef BOOST_NO_CWCHAR
template<>
inline bool is_whitespace(wchar_t t){
return 0 != std::iswspace(t);
}
#endif
} // detail
// translate base64 text into binary and copy into buffer
// until buffer is full.
template<class IStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_text_iprimitive<IStream>::load_binary(
void *address,
std::size_t count
){
typedef typename IStream::char_type CharType;
if(0 == count)
return;
BOOST_ASSERT(
static_cast<std::size_t>((std::numeric_limits<std::streamsize>::max)())
> (count + sizeof(CharType) - 1)/sizeof(CharType)
);
if(is.fail())
boost::serialization::throw_exception(
archive_exception(archive_exception::input_stream_error)
);
// convert from base64 to binary
typedef typename
iterators::transform_width<
iterators::binary_from_base64<
iterators::remove_whitespace<
iterators::istream_iterator<CharType>
>
,typename IStream::int_type
>
,8
,6
,CharType
>
binary;
binary i = binary(iterators::istream_iterator<CharType>(is));
char * caddr = static_cast<char *>(address);
// take care that we don't increment anymore than necessary
while(count-- > 0){
*caddr++ = static_cast<char>(*i++);
}
// skip over any excess input
for(;;){
typename IStream::int_type r;
r = is.get();
if(is.eof())
break;
if(detail::is_whitespace(static_cast<CharType>(r)))
break;
}
}
template<class IStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_text_iprimitive<IStream>::basic_text_iprimitive(
IStream &is_,
bool no_codecvt
) :
is(is_),
flags_saver(is_),
precision_saver(is_),
#ifndef BOOST_NO_STD_LOCALE
codecvt_null_facet(1),
archive_locale(is.getloc(), & codecvt_null_facet),
locale_saver(is)
{
if(! no_codecvt){
is_.sync();
is_.imbue(archive_locale);
}
is_ >> std::noboolalpha;
}
#else
{}
#endif
template<class IStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_text_iprimitive<IStream>::~basic_text_iprimitive(){
}
} // namespace archive
} // namespace boost
@@ -0,0 +1,62 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_text_oarchive.ipp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to 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 <string>
#include <boost/assert.hpp>
#include <cstring>
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::memcpy;
}
#endif
#include <boost/archive/basic_text_oarchive.hpp>
namespace boost {
namespace archive {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implementation of basic_text_oarchive
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_text_oarchive<Archive>::newtoken()
{
switch(delimiter){
default:
BOOST_ASSERT(false);
break;
case eol:
this->This()->put('\n');
delimiter = space;
break;
case space:
this->This()->put(' ');
break;
case none:
delimiter = space;
break;
}
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_text_oarchive<Archive>::init(){
// write signature in an archive version independent manner
const std::string file_signature(BOOST_ARCHIVE_SIGNATURE());
* this->This() << file_signature;
// write library version
const library_version_type v(BOOST_ARCHIVE_VERSION());
* this->This() << v;
}
} // namespace archive
} // namespace boost
@@ -0,0 +1,115 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_text_oprimitive.ipp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to 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 <cstddef> // NULL
#include <algorithm> // std::copy
#include <exception> // std::uncaught_exception
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::size_t;
} // namespace std
#endif
#include <boost/archive/basic_text_oprimitive.hpp>
#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/insert_linebreaks.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/archive/iterators/ostream_iterator.hpp>
namespace boost {
namespace archive {
// translate to base64 and copy in to buffer.
template<class OStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_text_oprimitive<OStream>::save_binary(
const void *address,
std::size_t count
){
typedef typename OStream::char_type CharType;
if(0 == count)
return;
if(os.fail())
boost::serialization::throw_exception(
archive_exception(archive_exception::output_stream_error)
);
os.put('\n');
typedef
boost::archive::iterators::insert_linebreaks<
boost::archive::iterators::base64_from_binary<
boost::archive::iterators::transform_width<
const char *,
6,
8
>
>
,76
,const char // cwpro8 needs this
>
base64_text;
boost::archive::iterators::ostream_iterator<CharType> oi(os);
std::copy(
base64_text(static_cast<const char *>(address)),
base64_text(
static_cast<const char *>(address) + count
),
oi
);
std::size_t tail = count % 3;
if(tail > 0){
*oi++ = '=';
if(tail < 2)
*oi = '=';
}
}
template<class OStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_text_oprimitive<OStream>::basic_text_oprimitive(
OStream & os_,
bool no_codecvt
) :
os(os_),
flags_saver(os_),
precision_saver(os_),
#ifndef BOOST_NO_STD_LOCALE
codecvt_null_facet(1),
archive_locale(os.getloc(), & codecvt_null_facet),
locale_saver(os)
{
if(! no_codecvt){
os_.flush();
os_.imbue(archive_locale);
}
os_ << std::noboolalpha;
}
#else
{}
#endif
template<class OStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_text_oprimitive<OStream>::~basic_text_oprimitive(){
if(std::uncaught_exception())
return;
os << std::endl;
}
} //namespace boost
} //namespace archive
@@ -0,0 +1,173 @@
#ifndef BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP
#define BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_xml_grammar.hpp
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to 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.
// this module is derived from simplexml.cpp - an example shipped as part of
// the spirit parser. This example contains the following notice:
/*=============================================================================
simplexml.cpp
Spirit V1.3
URL: http://spirit.sourceforge.net/
Copyright (c) 2001, Daniel C. Nuffer
This software is provided 'as-is', without any express or implied
warranty. In no event will the copyright holder be held liable for
any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
=============================================================================*/
#include <string>
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/spirit/include/classic_rule.hpp>
#include <boost/spirit/include/classic_chset.hpp>
#include <boost/archive/basic_archive.hpp>
#include <boost/serialization/tracking.hpp>
#include <boost/serialization/version.hpp>
namespace boost {
namespace archive {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// XML grammar parsing
template<class CharType>
class basic_xml_grammar {
public:
// The following is not necessary according to DR45, but at least
// one compiler (Compaq C++ 6.5 in strict_ansi mode) chokes otherwise.
struct return_values;
friend struct return_values;
private:
typedef typename std::basic_istream<CharType> IStream;
typedef typename std::basic_string<CharType> StringType;
typedef typename boost::spirit::classic::chset<CharType> chset_t;
typedef typename boost::spirit::classic::chlit<CharType> chlit_t;
typedef typename boost::spirit::classic::scanner<
typename std::basic_string<CharType>::iterator
> scanner_t;
typedef typename boost::spirit::classic::rule<scanner_t> rule_t;
// Start grammar definition
rule_t
Reference,
Eq,
STag,
ETag,
LetterOrUnderscoreOrColon,
AttValue,
CharRef1,
CharRef2,
CharRef,
AmpRef,
LTRef,
GTRef,
AposRef,
QuoteRef,
CharData,
CharDataChars,
content,
AmpName,
LTName,
GTName,
ClassNameChar,
ClassName,
Name,
XMLDecl,
XMLDeclChars,
DocTypeDecl,
DocTypeDeclChars,
ClassIDAttribute,
ObjectIDAttribute,
ClassNameAttribute,
TrackingAttribute,
VersionAttribute,
UnusedAttribute,
Attribute,
SignatureAttribute,
SerializationWrapper,
NameHead,
NameTail,
AttributeList,
S;
// XML Character classes
chset_t
BaseChar,
Ideographic,
Char,
Letter,
Digit,
CombiningChar,
Extender,
Sch,
NameChar;
void init_chset();
bool my_parse(
IStream & is,
const rule_t &rule_,
const CharType delimiter = L'>'
) const ;
public:
struct return_values {
StringType object_name;
StringType contents;
//class_id_type class_id;
int_least16_t class_id;
//object_id_type object_id;
uint_least32_t object_id;
//version_type version;
unsigned int version;
tracking_type tracking_level;
StringType class_name;
return_values() :
version(0),
tracking_level(false)
{}
} rv;
bool parse_start_tag(IStream & is) /*const*/;
bool parse_end_tag(IStream & is) const;
bool parse_string(IStream & is, StringType & s) /*const*/;
void init(IStream & is);
bool windup(IStream & is);
basic_xml_grammar();
};
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP
@@ -0,0 +1,115 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_xml_iarchive.ipp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to 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 <boost/assert.hpp>
#include <cstddef> // NULL
#include <algorithm>
#include <boost/serialization/throw_exception.hpp>
#include <boost/archive/xml_archive_exception.hpp>
#include <boost/archive/basic_xml_iarchive.hpp>
#include <boost/serialization/tracking.hpp>
namespace boost {
namespace archive {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implementation of xml_text_archive
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_iarchive<Archive>::load_start(const char *name){
// if there's no name
if(NULL == name)
return;
bool result = this->This()->gimpl->parse_start_tag(this->This()->get_is());
if(true != result){
boost::serialization::throw_exception(
archive_exception(archive_exception::input_stream_error)
);
}
// don't check start tag at highest level
++depth;
return;
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_iarchive<Archive>::load_end(const char *name){
// if there's no name
if(NULL == name)
return;
bool result = this->This()->gimpl->parse_end_tag(this->This()->get_is());
if(true != result){
boost::serialization::throw_exception(
archive_exception(archive_exception::input_stream_error)
);
}
// don't check start tag at highest level
if(0 == --depth)
return;
if(0 == (this->get_flags() & no_xml_tag_checking)){
// double check that the tag matches what is expected - useful for debug
if(0 != name[this->This()->gimpl->rv.object_name.size()]
|| ! std::equal(
this->This()->gimpl->rv.object_name.begin(),
this->This()->gimpl->rv.object_name.end(),
name
)
){
boost::serialization::throw_exception(
xml_archive_exception(
xml_archive_exception::xml_archive_tag_mismatch,
name
)
);
}
}
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_iarchive<Archive>::load_override(object_id_type & t){
t = object_id_type(this->This()->gimpl->rv.object_id);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_iarchive<Archive>::load_override(version_type & t){
t = version_type(this->This()->gimpl->rv.version);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_iarchive<Archive>::load_override(class_id_type & t){
t = class_id_type(this->This()->gimpl->rv.class_id);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_iarchive<Archive>::load_override(tracking_type & t){
t = this->This()->gimpl->rv.tracking_level;
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_xml_iarchive<Archive>::basic_xml_iarchive(unsigned int flags) :
detail::common_iarchive<Archive>(flags),
depth(0)
{}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_xml_iarchive<Archive>::~basic_xml_iarchive(){
}
} // namespace archive
} // namespace boost
@@ -0,0 +1,272 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_xml_oarchive.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 <algorithm>
#include <cstddef> // NULL
#include <cstring>
#if defined(BOOST_NO_STDC_NAMESPACE) && ! defined(__LIBCOMO__)
namespace std{
using ::strlen;
} // namespace std
#endif
#include <boost/archive/basic_xml_archive.hpp>
#include <boost/archive/basic_xml_oarchive.hpp>
#include <boost/archive/xml_archive_exception.hpp>
#include <boost/core/no_exceptions_support.hpp>
namespace boost {
namespace archive {
namespace detail {
template<class CharType>
struct XML_name {
void operator()(CharType t) const{
const unsigned char lookup_table[] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0, // -.
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0, // 0-9
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // A-
1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1, // -Z _
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // a-
1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0, // -z
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
if((unsigned)t > 127)
return;
if(0 == lookup_table[(unsigned)t])
boost::serialization::throw_exception(
xml_archive_exception(
xml_archive_exception::xml_archive_tag_name_error
)
);
}
};
} // namespace detail
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implemenations of functions common to both types of xml output
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::write_attribute(
const char *attribute_name,
int t,
const char *conjunction
){
this->This()->put(' ');
this->This()->put(attribute_name);
this->This()->put(conjunction);
this->This()->save(t);
this->This()->put('"');
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::write_attribute(
const char *attribute_name,
const char *key
){
this->This()->put(' ');
this->This()->put(attribute_name);
this->This()->put("=\"");
this->This()->save(key);
this->This()->put('"');
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::indent(){
int i;
for(i = depth; i-- > 0;)
this->This()->put('\t');
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_start(const char *name)
{
if(NULL == name)
return;
// be sure name has no invalid characters
std::for_each(name, name + std::strlen(name), detail::XML_name<const char>());
end_preamble();
if(depth > 0){
this->This()->put('\n');
indent();
}
++depth;
this->This()->put('<');
this->This()->save(name);
pending_preamble = true;
indent_next = false;
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_end(const char *name)
{
if(NULL == name)
return;
// be sure name has no invalid characters
std::for_each(name, name + std::strlen(name), detail::XML_name<const char>());
end_preamble();
--depth;
if(indent_next){
this->This()->put('\n');
indent();
}
indent_next = true;
this->This()->put("</");
this->This()->save(name);
this->This()->put('>');
if(0 == depth)
this->This()->put('\n');
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::end_preamble(){
if(pending_preamble){
this->This()->put('>');
pending_preamble = false;
}
}
#if 0
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const object_id_type & t)
{
int i = t.t; // extra .t is for borland
write_attribute(BOOST_ARCHIVE_XML_OBJECT_ID(), i, "=\"_");
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(
const object_reference_type & t,
int
){
int i = t.t; // extra .t is for borland
write_attribute(BOOST_ARCHIVE_XML_OBJECT_REFERENCE(), i, "=\"_");
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const version_type & t)
{
int i = t.t; // extra .t is for borland
write_attribute(BOOST_ARCHIVE_XML_VERSION(), i);
}
#endif
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const object_id_type & t)
{
// borland doesn't do conversion of STRONG_TYPEDEFs very well
const unsigned int i = t;
write_attribute(BOOST_ARCHIVE_XML_OBJECT_ID(), i, "=\"_");
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(
const object_reference_type & t
){
const unsigned int i = t;
write_attribute(BOOST_ARCHIVE_XML_OBJECT_REFERENCE(), i, "=\"_");
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const version_type & t)
{
const unsigned int i = t;
write_attribute(BOOST_ARCHIVE_XML_VERSION(), i);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const class_id_type & t)
{
write_attribute(BOOST_ARCHIVE_XML_CLASS_ID(), t);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(
const class_id_reference_type & t
){
write_attribute(BOOST_ARCHIVE_XML_CLASS_ID_REFERENCE(), t);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(
const class_id_optional_type & t
){
write_attribute(BOOST_ARCHIVE_XML_CLASS_ID(), t);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const class_name_type & t)
{
const char * key = t;
if(NULL == key)
return;
write_attribute(BOOST_ARCHIVE_XML_CLASS_NAME(), key);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const tracking_type & t)
{
write_attribute(BOOST_ARCHIVE_XML_TRACKING(), t.t);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::init(){
// xml header
this->This()->put("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n");
this->This()->put("<!DOCTYPE boost_serialization>\n");
// xml document wrapper - outer root
this->This()->put("<boost_serialization");
write_attribute("signature", BOOST_ARCHIVE_SIGNATURE());
write_attribute("version", BOOST_ARCHIVE_VERSION());
this->This()->put(">\n");
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::windup(){
// xml_trailer
this->This()->put("</boost_serialization>\n");
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_xml_oarchive<Archive>::basic_xml_oarchive(unsigned int flags) :
detail::common_oarchive<Archive>(flags),
depth(0),
pending_preamble(false),
indent_next(false)
{
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_xml_oarchive<Archive>::~basic_xml_oarchive(){
}
} // namespace archive
} // namespace boost
@@ -0,0 +1,128 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// text_iarchive_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.
//////////////////////////////////////////////////////////////////////
// implementation of basic_text_iprimitive overrides for the combination
// of template parameters used to implement a text_iprimitive
#include <cstddef> // size_t, NULL
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::size_t;
} // namespace std
#endif
#include <boost/detail/workaround.hpp> // RogueWave
#include <boost/archive/text_iarchive.hpp>
namespace boost {
namespace archive {
template<class Archive>
BOOST_ARCHIVE_DECL void
text_iarchive_impl<Archive>::load(char *s)
{
std::size_t size;
* this->This() >> size;
// skip separating space
is.get();
// Works on all tested platforms
is.read(s, size);
s[size] = '\0';
}
template<class Archive>
BOOST_ARCHIVE_DECL void
text_iarchive_impl<Archive>::load(std::string &s)
{
std::size_t size;
* this->This() >> size;
// skip separating space
is.get();
// borland de-allocator fixup
#if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
if(NULL != s.data())
#endif
s.resize(size);
if(0 < size)
is.read(&(*s.begin()), size);
}
#ifndef BOOST_NO_CWCHAR
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_ARCHIVE_DECL void
text_iarchive_impl<Archive>::load(wchar_t *ws)
{
std::size_t size;
* this->This() >> size;
// skip separating space
is.get();
is.read((char *)ws, size * sizeof(wchar_t)/sizeof(char));
ws[size] = L'\0';
}
#endif // BOOST_NO_INTRINSIC_WCHAR_T
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_ARCHIVE_DECL void
text_iarchive_impl<Archive>::load(std::wstring &ws)
{
std::size_t size;
* this->This() >> size;
// borland de-allocator fixup
#if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
if(NULL != ws.data())
#endif
ws.resize(size);
// skip separating space
is.get();
is.read((char *)ws.data(), size * sizeof(wchar_t)/sizeof(char));
}
#endif // BOOST_NO_STD_WSTRING
#endif // BOOST_NO_CWCHAR
template<class Archive>
BOOST_ARCHIVE_DECL void
text_iarchive_impl<Archive>::load_override(class_name_type & t){
basic_text_iarchive<Archive>::load_override(t);
}
template<class Archive>
BOOST_ARCHIVE_DECL void
text_iarchive_impl<Archive>::init(){
basic_text_iarchive<Archive>::init();
}
template<class Archive>
BOOST_ARCHIVE_DECL
text_iarchive_impl<Archive>::text_iarchive_impl(
std::istream & is,
unsigned int flags
) :
basic_text_iprimitive<std::istream>(
is,
0 != (flags & no_codecvt)
),
basic_text_iarchive<Archive>(flags)
{
if(0 == (flags & no_header))
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
this->init();
#else
this->basic_text_iarchive<Archive>::init();
#endif
}
} // namespace archive
} // namespace boost
@@ -0,0 +1,122 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// text_oarchive_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 <string>
#include <boost/config.hpp>
#include <cstddef> // size_t
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::size_t;
} // namespace std
#endif
#ifndef BOOST_NO_CWCHAR
#include <cwchar>
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std{ using ::wcslen; }
#endif
#endif
#include <boost/archive/text_oarchive.hpp>
namespace boost {
namespace archive {
//////////////////////////////////////////////////////////////////////
// implementation of basic_text_oprimitive overrides for the combination
// of template parameters used to create a text_oprimitive
template<class Archive>
BOOST_ARCHIVE_DECL void
text_oarchive_impl<Archive>::save(const char * s)
{
const std::size_t len = std::ostream::traits_type::length(s);
*this->This() << len;
this->This()->newtoken();
os << s;
}
template<class Archive>
BOOST_ARCHIVE_DECL void
text_oarchive_impl<Archive>::save(const std::string &s)
{
const std::size_t size = s.size();
*this->This() << size;
this->This()->newtoken();
os << s;
}
#ifndef BOOST_NO_CWCHAR
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_ARCHIVE_DECL void
text_oarchive_impl<Archive>::save(const wchar_t * ws)
{
const std::size_t l = std::wcslen(ws);
* this->This() << l;
this->This()->newtoken();
os.write((const char *)ws, l * sizeof(wchar_t)/sizeof(char));
}
#endif
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_ARCHIVE_DECL void
text_oarchive_impl<Archive>::save(const std::wstring &ws)
{
const std::size_t l = ws.size();
* this->This() << l;
this->This()->newtoken();
os.write((const char *)(ws.data()), l * sizeof(wchar_t)/sizeof(char));
}
#endif
#endif // BOOST_NO_CWCHAR
template<class Archive>
BOOST_ARCHIVE_DECL
text_oarchive_impl<Archive>::text_oarchive_impl(
std::ostream & os,
unsigned int flags
) :
basic_text_oprimitive<std::ostream>(
os,
0 != (flags & no_codecvt)
),
basic_text_oarchive<Archive>(flags)
{
if(0 == (flags & no_header))
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
this->init();
#else
this->basic_text_oarchive<Archive>::init();
#endif
}
template<class Archive>
BOOST_ARCHIVE_DECL void
text_oarchive_impl<Archive>::save_binary(const void *address, std::size_t count){
put('\n');
this->end_preamble();
#if ! defined(__MWERKS__)
this->basic_text_oprimitive<std::ostream>::save_binary(
#else
this->basic_text_oprimitive::save_binary(
#endif
address,
count
);
this->delimiter = this->eol;
}
} // namespace archive
} // namespace boost
@@ -0,0 +1,118 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// text_text_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 <cstddef> // size_t, NULL
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::size_t;
} // namespace std
#endif
#include <boost/detail/workaround.hpp> // fixup for RogueWave
#ifndef BOOST_NO_STD_WSTREAMBUF
#include <boost/archive/basic_text_iprimitive.hpp>
namespace boost {
namespace archive {
//////////////////////////////////////////////////////////////////////
// implementation of wiprimtives functions
//
template<class Archive>
BOOST_WARCHIVE_DECL void
text_wiarchive_impl<Archive>::load(char *s)
{
std::size_t size;
* this->This() >> size;
// skip separating space
is.get();
while(size-- > 0){
*s++ = is.narrow(is.get(), '\0');
}
*s = '\0';
}
template<class Archive>
BOOST_WARCHIVE_DECL void
text_wiarchive_impl<Archive>::load(std::string &s)
{
std::size_t size;
* this->This() >> size;
// skip separating space
is.get();
#if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
if(NULL != s.data())
#endif
s.resize(0);
s.reserve(size);
while(size-- > 0){
int x = is.narrow(is.get(), '\0');
s += x;
}
}
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_WARCHIVE_DECL void
text_wiarchive_impl<Archive>::load(wchar_t *s)
{
std::size_t size;
* this->This() >> size;
// skip separating space
is.get();
// Works on all tested platforms
is.read(s, size);
s[size] = L'\0';
}
#endif
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_WARCHIVE_DECL void
text_wiarchive_impl<Archive>::load(std::wstring &ws)
{
std::size_t size;
* this->This() >> size;
// skip separating space
is.get();
// borland complains about resize
// borland de-allocator fixup
#if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
if(NULL != ws.data())
#endif
ws.resize(size);
// note breaking a rule here - is this a problem on some platform
is.read(const_cast<wchar_t *>(ws.data()), size);
}
#endif
template<class Archive>
BOOST_WARCHIVE_DECL
text_wiarchive_impl<Archive>::text_wiarchive_impl(
std::wistream & is,
unsigned int flags
) :
basic_text_iprimitive<std::wistream>(
is,
0 != (flags & no_codecvt)
),
basic_text_iarchive<Archive>(flags)
{
if(0 == (flags & no_header))
basic_text_iarchive<Archive>::init();
}
} // archive
} // boost
#endif // BOOST_NO_STD_WSTREAMBUF
@@ -0,0 +1,85 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// text_woarchive_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 <boost/config.hpp>
#ifndef BOOST_NO_STD_WSTREAMBUF
#include <cstring>
#include <cstddef> // size_t
#if defined(BOOST_NO_STDC_NAMESPACE) && ! defined(__LIBCOMO__)
namespace std{
using ::strlen;
using ::size_t;
} // namespace std
#endif
#include <ostream>
#include <boost/archive/text_woarchive.hpp>
namespace boost {
namespace archive {
//////////////////////////////////////////////////////////////////////
// implementation of woarchive functions
//
template<class Archive>
BOOST_WARCHIVE_DECL void
text_woarchive_impl<Archive>::save(const char *s)
{
// note: superfluous local variable fixes borland warning
const std::size_t size = std::strlen(s);
* this->This() << size;
this->This()->newtoken();
while(*s != '\0')
os.put(os.widen(*s++));
}
template<class Archive>
BOOST_WARCHIVE_DECL void
text_woarchive_impl<Archive>::save(const std::string &s)
{
const std::size_t size = s.size();
* this->This() << size;
this->This()->newtoken();
const char * cptr = s.data();
for(std::size_t i = size; i-- > 0;)
os.put(os.widen(*cptr++));
}
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_WARCHIVE_DECL void
text_woarchive_impl<Archive>::save(const wchar_t *ws)
{
const std::size_t size = std::wostream::traits_type::length(ws);
* this->This() << size;
this->This()->newtoken();
os.write(ws, size);
}
#endif
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_WARCHIVE_DECL void
text_woarchive_impl<Archive>::save(const std::wstring &ws)
{
const std::size_t size = ws.length();
* this->This() << size;
this->This()->newtoken();
os.write(ws.data(), size);
}
#endif
} // namespace archive
} // namespace boost
#endif
@@ -0,0 +1,199 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_iarchive_impl.cpp:
// (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 <boost/config.hpp>
#include <cstring> // memcpy
#include <cstddef> // NULL
#include <exception>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::memcpy;
} // namespace std
#endif
#ifndef BOOST_NO_CWCHAR
#include <cwchar> // mbstate_t and mbrtowc
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::mbstate_t;
using ::mbrtowc;
} // namespace std
#endif
#endif // BOOST_NO_CWCHAR
#include <boost/detail/workaround.hpp> // RogueWave and Dinkumware
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
#include <boost/archive/dinkumware.hpp>
#endif
#include <boost/core/no_exceptions_support.hpp>
#include <boost/archive/xml_archive_exception.hpp>
#include <boost/archive/iterators/dataflow_exception.hpp>
#include <boost/archive/basic_xml_archive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include "basic_xml_grammar.hpp"
namespace boost {
namespace archive {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implemenations of functions specific to char archives
// wide char stuff used by char archives
#ifndef BOOST_NO_CWCHAR
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_ARCHIVE_DECL void
xml_iarchive_impl<Archive>::load(std::wstring &ws){
std::string s;
bool result = gimpl->parse_string(is, s);
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 != ws.data())
#endif
ws.resize(0);
std::mbstate_t mbs = std::mbstate_t();
const char * start = s.data();
const char * end = start + s.size();
while(start < end){
wchar_t wc;
std::size_t count = std::mbrtowc(&wc, start, end - start, &mbs);
if(count == static_cast<std::size_t>(-1))
boost::serialization::throw_exception(
iterators::dataflow_exception(
iterators::dataflow_exception::invalid_conversion
)
);
if(count == static_cast<std::size_t>(-2))
continue;
start += count;
ws += wc;
}
}
#endif // BOOST_NO_STD_WSTRING
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_ARCHIVE_DECL void
xml_iarchive_impl<Archive>::load(wchar_t * ws){
std::string s;
bool result = gimpl->parse_string(is, s);
if(! result)
boost::serialization::throw_exception(
xml_archive_exception(
xml_archive_exception::xml_archive_parsing_error
)
);
std::mbstate_t mbs = std::mbstate_t();
const char * start = s.data();
const char * end = start + s.size();
while(start < end){
wchar_t wc;
std::size_t length = std::mbrtowc(&wc, start, end - start, &mbs);
if(static_cast<std::size_t>(-1) == length)
boost::serialization::throw_exception(
iterators::dataflow_exception(
iterators::dataflow_exception::invalid_conversion
)
);
if(static_cast<std::size_t>(-2) == length)
continue;
start += length;
*ws++ = wc;
}
*ws = L'\0';
}
#endif // BOOST_NO_INTRINSIC_WCHAR_T
#endif // BOOST_NO_CWCHAR
template<class Archive>
BOOST_ARCHIVE_DECL void
xml_iarchive_impl<Archive>::load(std::string &s){
bool result = gimpl->parse_string(is, s);
if(! result)
boost::serialization::throw_exception(
xml_archive_exception(xml_archive_exception::xml_archive_parsing_error)
);
}
template<class Archive>
BOOST_ARCHIVE_DECL void
xml_iarchive_impl<Archive>::load(char * s){
std::string tstring;
bool result = gimpl->parse_string(is, tstring);
if(! result)
boost::serialization::throw_exception(
xml_archive_exception(xml_archive_exception::xml_archive_parsing_error)
);
std::memcpy(s, tstring.data(), tstring.size());
s[tstring.size()] = 0;
}
template<class Archive>
BOOST_ARCHIVE_DECL void
xml_iarchive_impl<Archive>::load_override(class_name_type & t){
const std::string & s = gimpl->rv.class_name;
if(s.size() > BOOST_SERIALIZATION_MAX_KEY_SIZE - 1)
boost::serialization::throw_exception(
archive_exception(archive_exception::invalid_class_name)
);
char * tptr = t;
std::memcpy(tptr, s.data(), s.size());
tptr[s.size()] = '\0';
}
template<class Archive>
BOOST_ARCHIVE_DECL void
xml_iarchive_impl<Archive>::init(){
gimpl->init(is);
this->set_library_version(
library_version_type(gimpl->rv.version)
);
}
template<class Archive>
BOOST_ARCHIVE_DECL
xml_iarchive_impl<Archive>::xml_iarchive_impl(
std::istream &is_,
unsigned int flags
) :
basic_text_iprimitive<std::istream>(
is_,
0 != (flags & no_codecvt)
),
basic_xml_iarchive<Archive>(flags),
gimpl(new xml_grammar())
{
if(0 == (flags & no_header))
init();
}
template<class Archive>
BOOST_ARCHIVE_DECL
xml_iarchive_impl<Archive>::~xml_iarchive_impl(){
if(std::uncaught_exception())
return;
if(0 == (this->get_flags() & no_header)){
gimpl->windup(is);
}
}
} // namespace archive
} // namespace boost
@@ -0,0 +1,142 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_oarchive_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)
#include <ostream>
#include <iomanip>
#include <algorithm> // std::copy
#include <string>
#include <exception>
#include <cstring> // strlen
#include <boost/config.hpp> // msvc 6.0 needs this to suppress warnings
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::strlen;
} // namespace std
#endif
#include <boost/archive/iterators/xml_escape.hpp>
#include <boost/archive/iterators/ostream_iterator.hpp>
#ifndef BOOST_NO_CWCHAR
#include <boost/archive/wcslen.hpp>
#include <boost/archive/iterators/mb_from_wchar.hpp>
#endif
namespace boost {
namespace archive {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implemenations of functions specific to char archives
// wide char stuff used by char archives
#ifndef BOOST_NO_CWCHAR
// copy chars to output escaping to xml and translating wide chars to mb chars
template<class InputIterator>
void save_iterator(std::ostream &os, InputIterator begin, InputIterator end){
typedef boost::archive::iterators::mb_from_wchar<
boost::archive::iterators::xml_escape<InputIterator>
> translator;
std::copy(
translator(begin),
translator(end),
boost::archive::iterators::ostream_iterator<char>(os)
);
}
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_ARCHIVE_DECL void
xml_oarchive_impl<Archive>::save(const std::wstring & ws){
// at least one library doesn't typedef value_type for strings
// so rather than using string directly make a pointer iterator out of it
// save_iterator(os, ws.data(), ws.data() + std::wcslen(ws.data()));
save_iterator(os, ws.data(), ws.data() + ws.size());
}
#endif
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_ARCHIVE_DECL void
xml_oarchive_impl<Archive>::save(const wchar_t * ws){
save_iterator(os, ws, ws + std::wcslen(ws));
}
#endif
#endif // BOOST_NO_CWCHAR
template<class Archive>
BOOST_ARCHIVE_DECL void
xml_oarchive_impl<Archive>::save(const std::string & s){
// at least one library doesn't typedef value_type for strings
// so rather than using string directly make a pointer iterator out of it
typedef boost::archive::iterators::xml_escape<
const char *
> xml_escape_translator;
std::copy(
xml_escape_translator(s.data()),
xml_escape_translator(s.data()+ s.size()),
boost::archive::iterators::ostream_iterator<char>(os)
);
}
template<class Archive>
BOOST_ARCHIVE_DECL void
xml_oarchive_impl<Archive>::save(const char * s){
typedef boost::archive::iterators::xml_escape<
const char *
> xml_escape_translator;
std::copy(
xml_escape_translator(s),
xml_escape_translator(s + std::strlen(s)),
boost::archive::iterators::ostream_iterator<char>(os)
);
}
template<class Archive>
BOOST_ARCHIVE_DECL
xml_oarchive_impl<Archive>::xml_oarchive_impl(
std::ostream & os_,
unsigned int flags
) :
basic_text_oprimitive<std::ostream>(
os_,
0 != (flags & no_codecvt)
),
basic_xml_oarchive<Archive>(flags)
{
if(0 == (flags & no_header))
this->init();
}
template<class Archive>
BOOST_ARCHIVE_DECL void
xml_oarchive_impl<Archive>::save_binary(const void *address, std::size_t count){
this->end_preamble();
#if ! defined(__MWERKS__)
this->basic_text_oprimitive<std::ostream>::save_binary(
#else
this->basic_text_oprimitive::save_binary(
#endif
address,
count
);
this->indent_next = true;
}
template<class Archive>
BOOST_ARCHIVE_DECL
xml_oarchive_impl<Archive>::~xml_oarchive_impl(){
if(std::uncaught_exception())
return;
if(0 == (this->get_flags() & no_header))
this->windup();
}
} // namespace archive
} // namespace boost
@@ -0,0 +1,189 @@
/////////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 <cstring>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::memcpy;
} //std
#endif
#include <boost/config.hpp> // msvc 6.0 needs this to suppress warnings
#ifndef BOOST_NO_STD_WSTREAMBUF
#include <boost/assert.hpp>
#include <algorithm> // std::copy
#include <exception> // uncaught exception
#include <boost/detail/workaround.hpp> // Dinkumware and RogueWave
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
#include <boost/archive/dinkumware.hpp>
#endif
#include <boost/io/ios_state.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/serialization/string.hpp>
#include <boost/archive/basic_xml_archive.hpp>
#include <boost/archive/xml_wiarchive.hpp>
#include <boost/archive/xml_archive_exception.hpp>
#include <boost/archive/iterators/mb_from_wchar.hpp>
#include <boost/archive/detail/utf8_codecvt_facet.hpp>
#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<std::wstring::const_iterator>(
ws.begin()
),
iterators::mb_from_wchar<std::wstring::const_iterator>(
ws.end()
),
s
);
s[ws.size()] = 0;
}
} // anonymous
template<class Archive>
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl<Archive>::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<std::wstring::iterator>(
ws.begin()
),
iterators::mb_from_wchar<std::wstring::iterator>(
ws.end()
),
std::back_inserter(s)
);
}
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl<Archive>::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<class Archive>
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl<Archive>::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<class Archive>
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl<Archive>::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<class Archive>
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl<Archive>::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<class Archive>
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl<Archive>::init(){
gimpl->init(is);
this->set_library_version(
library_version_type(gimpl->rv.version)
);
}
template<class Archive>
BOOST_WARCHIVE_DECL
xml_wiarchive_impl<Archive>::xml_wiarchive_impl(
std::wistream &is_,
unsigned int flags
) :
basic_text_iprimitive<std::wistream>(
is_,
true // don't change the codecvt - use the one below
),
basic_xml_iarchive<Archive>(flags),
gimpl(new xml_wgrammar())
{
if(0 == (flags & no_codecvt)){
std::locale l = std::locale(
is_.getloc(),
new boost::archive::detail::utf8_codecvt_facet
);
// libstdc++ crashes without this
is_.sync();
is_.imbue(l);
}
if(0 == (flags & no_header))
init();
}
template<class Archive>
BOOST_WARCHIVE_DECL
xml_wiarchive_impl<Archive>::~xml_wiarchive_impl(){
if(std::uncaught_exception())
return;
if(0 == (this->get_flags() & no_header)){
gimpl->windup(is);
}
}
} // namespace archive
} // namespace boost
#endif // BOOST_NO_STD_WSTREAMBUF
@@ -0,0 +1,169 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_woarchive_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)
#include <boost/config.hpp>
#ifndef BOOST_NO_STD_WSTREAMBUF
#include <ostream>
#include <string>
#include <algorithm> // std::copy
#include <locale>
#include <exception>
#include <cstring> // strlen
#include <cstdlib> // mbtowc
#include <cwchar> // wcslen
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::strlen;
#if ! defined(BOOST_NO_INTRINSIC_WCHAR_T)
using ::mbtowc;
using ::wcslen;
#endif
} // namespace std
#endif
#include <boost/archive/xml_woarchive.hpp>
#include <boost/archive/detail/utf8_codecvt_facet.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/archive/iterators/xml_escape.hpp>
#include <boost/archive/iterators/wchar_from_mb.hpp>
#include <boost/archive/iterators/ostream_iterator.hpp>
#include <boost/archive/iterators/dataflow_exception.hpp>
namespace boost {
namespace archive {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implemenations of functions specific to wide char archives
// copy chars to output escaping to xml and widening characters as we go
template<class InputIterator>
void save_iterator(std::wostream &os, InputIterator begin, InputIterator end){
typedef iterators::wchar_from_mb<
iterators::xml_escape<InputIterator>
> xmbtows;
std::copy(
xmbtows(begin),
xmbtows(end),
boost::archive::iterators::ostream_iterator<wchar_t>(os)
);
}
template<class Archive>
BOOST_WARCHIVE_DECL void
xml_woarchive_impl<Archive>::save(const std::string & s){
// note: we don't use s.begin() and s.end() because dinkumware
// doesn't have string::value_type defined. So use a wrapper
// around these values to implement the definitions.
const char * begin = s.data();
const char * end = begin + s.size();
save_iterator(os, begin, end);
}
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_WARCHIVE_DECL void
xml_woarchive_impl<Archive>::save(const std::wstring & ws){
#if 0
typedef iterators::xml_escape<std::wstring::const_iterator> xmbtows;
std::copy(
xmbtows(ws.begin()),
xmbtows(ws.end()),
boost::archive::iterators::ostream_iterator<wchar_t>(os)
);
#endif
typedef iterators::xml_escape<const wchar_t *> xmbtows;
std::copy(
xmbtows(ws.data()),
xmbtows(ws.data() + ws.size()),
boost::archive::iterators::ostream_iterator<wchar_t>(os)
);
}
#endif //BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_WARCHIVE_DECL void
xml_woarchive_impl<Archive>::save(const char * s){
save_iterator(os, s, s + std::strlen(s));
}
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
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),
xmbtows(ws + std::wcslen(ws)),
boost::archive::iterators::ostream_iterator<wchar_t>(os)
);
}
#endif
template<class Archive>
BOOST_WARCHIVE_DECL
xml_woarchive_impl<Archive>::xml_woarchive_impl(
std::wostream & os_,
unsigned int flags
) :
basic_text_oprimitive<std::wostream>(
os_,
true // don't change the codecvt - use the one below
),
basic_xml_oarchive<Archive>(flags)
{
if(0 == (flags & no_codecvt)){
std::locale l = std::locale(
os_.getloc(),
new boost::archive::detail::utf8_codecvt_facet
);
os_.flush();
os_.imbue(l);
}
if(0 == (flags & no_header))
this->init();
}
template<class Archive>
BOOST_WARCHIVE_DECL
xml_woarchive_impl<Archive>::~xml_woarchive_impl(){
if(std::uncaught_exception())
return;
if(0 == (this->get_flags() & no_header)){
save(L"</boost_serialization>\n");
}
}
template<class Archive>
BOOST_WARCHIVE_DECL void
xml_woarchive_impl<Archive>::save_binary(
const void *address,
std::size_t count
){
this->end_preamble();
#if ! defined(__MWERKS__)
this->basic_text_oprimitive<std::wostream>::save_binary(
#else
this->basic_text_oprimitive::save_binary(
#endif
address,
count
);
this->indent_next = true;
}
} // namespace archive
} // namespace boost
#endif //BOOST_NO_STD_WSTREAMBUF