/////////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 // NULL #include // std::copy #include // std::uncaught_exception #include #if defined(BOOST_NO_STDC_NAMESPACE) namespace std{ using ::size_t; } // namespace std #endif #include #include #include #include #include namespace lslboost { namespace archive { // translate to base64 and copy in to buffer. template BOOST_ARCHIVE_OR_WARCHIVE_DECL void basic_text_oprimitive::save_binary( const void *address, std::size_t count ){ typedef typename OStream::char_type CharType; if(0 == count) return; if(os.fail()) lslboost::serialization::throw_exception( archive_exception(archive_exception::output_stream_error) ); os.put('\n'); typedef lslboost::archive::iterators::insert_linebreaks< lslboost::archive::iterators::base64_from_binary< lslboost::archive::iterators::transform_width< const char *, 6, 8 > > ,76 ,const char // cwpro8 needs this > base64_text; lslboost::archive::iterators::ostream_iterator oi(os); std::copy( base64_text(static_cast(address)), base64_text( static_cast(address) + count ), oi ); std::size_t tail = count % 3; if(tail > 0){ *oi++ = '='; if(tail < 2) *oi = '='; } } template BOOST_ARCHIVE_OR_WARCHIVE_DECL basic_text_oprimitive::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 BOOST_ARCHIVE_OR_WARCHIVE_DECL basic_text_oprimitive::~basic_text_oprimitive(){ if(std::uncaught_exception()) return; os << std::endl; } } //namespace lslboost } //namespace archive