Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:28

0001 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0002 // text_oarchive_impl.ipp:
0003 
0004 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
0005 // Distributed under the Boost Software License, Version 1.0. (See
0006 // accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 //  See http://www.boost.org for updates, documentation, and revision history.
0010 
0011 #include <string>
0012 #include <boost/config.hpp>
0013 #include <cstddef> // size_t
0014 
0015 #include <boost/config.hpp>
0016 #if defined(BOOST_NO_STDC_NAMESPACE)
0017 namespace std{ 
0018     using ::size_t; 
0019 } // namespace std
0020 #endif
0021 
0022 #ifndef BOOST_NO_CWCHAR
0023 #include <cwchar>
0024 #ifdef BOOST_NO_STDC_NAMESPACE
0025 namespace std{ using ::wcslen; }
0026 #endif
0027 #endif
0028 
0029 #include <boost/archive/text_oarchive.hpp>
0030 
0031 namespace boost { 
0032 namespace archive {
0033 
0034 //////////////////////////////////////////////////////////////////////
0035 // implementation of basic_text_oprimitive overrides for the combination
0036 // of template parameters used to create a text_oprimitive
0037 
0038 template<class Archive>
0039 BOOST_ARCHIVE_DECL void
0040 text_oarchive_impl<Archive>::save(const char * s)
0041 {
0042     const std::size_t len = std::ostream::traits_type::length(s);
0043     *this->This() << len;
0044     this->This()->newtoken();
0045     os << s;
0046 }
0047 
0048 template<class Archive>
0049 BOOST_ARCHIVE_DECL void
0050 text_oarchive_impl<Archive>::save(const std::string &s)
0051 {
0052     const std::size_t size = s.size();
0053     *this->This() << size;
0054     this->This()->newtoken();
0055     os << s;
0056 }
0057 
0058 #ifndef BOOST_NO_CWCHAR
0059 #ifndef BOOST_NO_INTRINSIC_WCHAR_T
0060 template<class Archive>
0061 BOOST_ARCHIVE_DECL void
0062 text_oarchive_impl<Archive>::save(const wchar_t * ws)
0063 {
0064     const std::size_t l = std::wcslen(ws);
0065     * this->This() << l;
0066     this->This()->newtoken();
0067     os.write((const char *)ws, l * sizeof(wchar_t)/sizeof(char));
0068 }
0069 #endif
0070 
0071 #ifndef BOOST_NO_STD_WSTRING
0072 template<class Archive>
0073 BOOST_ARCHIVE_DECL void
0074 text_oarchive_impl<Archive>::save(const std::wstring &ws)
0075 {
0076     const std::size_t l = ws.size();
0077     * this->This() << l;
0078     this->This()->newtoken();
0079     os.write((const char *)(ws.data()), l * sizeof(wchar_t)/sizeof(char));
0080 }
0081 #endif
0082 #endif // BOOST_NO_CWCHAR
0083 
0084 template<class Archive>
0085 BOOST_ARCHIVE_DECL 
0086 text_oarchive_impl<Archive>::text_oarchive_impl(
0087     std::ostream & os, 
0088     unsigned int flags
0089 ) :
0090     basic_text_oprimitive<std::ostream>(
0091         os, 
0092         0 != (flags & no_codecvt)
0093     ),
0094     basic_text_oarchive<Archive>(flags)
0095 {
0096 }
0097 
0098 template<class Archive>
0099 BOOST_ARCHIVE_DECL void
0100 text_oarchive_impl<Archive>::save_binary(const void *address, std::size_t count){
0101     put('\n');
0102     this->end_preamble();
0103     #if ! defined(__MWERKS__)
0104     this->basic_text_oprimitive<std::ostream>::save_binary(
0105     #else
0106     this->basic_text_oprimitive::save_binary(
0107     #endif
0108         address, 
0109         count
0110     );
0111     this->delimiter = this->eol;
0112 }
0113 
0114 } // namespace archive
0115 } // namespace boost
0116