diff options
Diffstat (limited to 'src/third_party/boost-1.60.0/boost/archive/impl/basic_text_oprimitive.ipp')
-rw-r--r-- | src/third_party/boost-1.60.0/boost/archive/impl/basic_text_oprimitive.ipp | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/src/third_party/boost-1.60.0/boost/archive/impl/basic_text_oprimitive.ipp b/src/third_party/boost-1.60.0/boost/archive/impl/basic_text_oprimitive.ipp new file mode 100644 index 00000000000..f2b0a10a60f --- /dev/null +++ b/src/third_party/boost-1.60.0/boost/archive/impl/basic_text_oprimitive.ipp @@ -0,0 +1,113 @@ +/////////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 <boost/archive/basic_text_oprimitive.hpp> +#include <boost/archive/codecvt_null.hpp> +#include <boost/archive/add_facet.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 +) : +#ifndef BOOST_NO_STD_LOCALE + os(os_), + flags_saver(os_), + precision_saver(os_), + locale_saver(* os_.rdbuf()) +{ + if(! no_codecvt){ + archive_locale.reset( + add_facet( + std::locale::classic(), + new boost::archive::codecvt_null<typename OStream::char_type> + ) + ); + //os.imbue(* archive_locale); + } + os << std::noboolalpha; +} +#else + os(os_), + flags_saver(os_), + precision_saver(os_) +{} +#endif + +template<class OStream> +BOOST_ARCHIVE_OR_WARCHIVE_DECL +basic_text_oprimitive<OStream>::~basic_text_oprimitive(){ + os << std::endl; +} + +} //namespace boost +} //namespace archive |