1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 // text_oarchive_impl.ipp:
4 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
5 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // See http://www.boost.org for updates, documentation, and revision history.
12 #include <boost/config.hpp>
13 #include <cstddef> // size_t
15 #include <boost/config.hpp>
16 #if defined(BOOST_NO_STDC_NAMESPACE)
22 #ifndef BOOST_NO_CWCHAR
24 #ifdef BOOST_NO_STDC_NAMESPACE
25 namespace std{ using ::wcslen; }
29 #include <boost/archive/text_oarchive.hpp>
34 //////////////////////////////////////////////////////////////////////
35 // implementation of basic_text_oprimitive overrides for the combination
36 // of template parameters used to create a text_oprimitive
38 template<class Archive>
39 BOOST_ARCHIVE_DECL void
40 text_oarchive_impl<Archive>::save(const char * s)
42 const std::size_t len = std::ostream::traits_type::length(s);
44 this->This()->newtoken();
48 template<class Archive>
49 BOOST_ARCHIVE_DECL void
50 text_oarchive_impl<Archive>::save(const std::string &s)
52 const std::size_t size = s.size();
53 *this->This() << size;
54 this->This()->newtoken();
58 #ifndef BOOST_NO_CWCHAR
59 #ifndef BOOST_NO_INTRINSIC_WCHAR_T
60 template<class Archive>
61 BOOST_ARCHIVE_DECL void
62 text_oarchive_impl<Archive>::save(const wchar_t * ws)
64 const std::size_t l = std::wcslen(ws);
66 this->This()->newtoken();
67 os.write((const char *)ws, l * sizeof(wchar_t)/sizeof(char));
71 #ifndef BOOST_NO_STD_WSTRING
72 template<class Archive>
73 BOOST_ARCHIVE_DECL void
74 text_oarchive_impl<Archive>::save(const std::wstring &ws)
76 const std::size_t l = ws.size();
78 this->This()->newtoken();
79 os.write((const char *)(ws.data()), l * sizeof(wchar_t)/sizeof(char));
82 #endif // BOOST_NO_CWCHAR
84 template<class Archive>
86 text_oarchive_impl<Archive>::text_oarchive_impl(
90 basic_text_oprimitive<std::ostream>(
92 0 != (flags & no_codecvt)
94 basic_text_oarchive<Archive>(flags)
96 if(0 == (flags & no_header))
97 #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
100 this->basic_text_oarchive<Archive>::init();
104 template<class Archive>
105 BOOST_ARCHIVE_DECL void
106 text_oarchive_impl<Archive>::save_binary(const void *address, std::size_t count){
108 this->end_preamble();
109 #if ! defined(__MWERKS__)
110 this->basic_text_oprimitive<std::ostream>::save_binary(
112 this->basic_text_oprimitive::save_binary(
117 this->delimiter = this->eol;
120 } // namespace archive