1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 // text_woarchive_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.
11 #include <boost/config.hpp>
12 #ifndef BOOST_NO_STD_WSTREAMBUF
15 #include <cstddef> // size_t
16 #if defined(BOOST_NO_STDC_NAMESPACE) && ! defined(__LIBCOMO__)
25 #include <boost/archive/text_woarchive.hpp>
30 //////////////////////////////////////////////////////////////////////
31 // implementation of woarchive functions
33 template<class Archive>
34 BOOST_WARCHIVE_DECL void
35 text_woarchive_impl<Archive>::save(const char *s)
37 // note: superfluous local variable fixes borland warning
38 const std::size_t size = std::strlen(s);
39 * this->This() << size;
40 this->This()->newtoken();
42 os.put(os.widen(*s++));
45 template<class Archive>
46 BOOST_WARCHIVE_DECL void
47 text_woarchive_impl<Archive>::save(const std::string &s)
49 const std::size_t size = s.size();
50 * this->This() << size;
51 this->This()->newtoken();
52 const char * cptr = s.data();
53 for(std::size_t i = size; i-- > 0;)
54 os.put(os.widen(*cptr++));
57 #ifndef BOOST_NO_INTRINSIC_WCHAR_T
58 template<class Archive>
59 BOOST_WARCHIVE_DECL void
60 text_woarchive_impl<Archive>::save(const wchar_t *ws)
62 const std::size_t size = std::wostream::traits_type::length(ws);
63 * this->This() << size;
64 this->This()->newtoken();
69 #ifndef BOOST_NO_STD_WSTRING
70 template<class Archive>
71 BOOST_WARCHIVE_DECL void
72 text_woarchive_impl<Archive>::save(const std::wstring &ws)
74 const std::size_t size = ws.length();
75 * this->This() << size;
76 this->This()->newtoken();
77 os.write(ws.data(), size);
81 } // namespace archive