Chris@16: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 Chris@16: // text_woarchive_impl.ipp: Chris@16: Chris@16: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // See http://www.boost.org for updates, documentation, and revision history. Chris@16: Chris@16: #include Chris@16: #ifndef BOOST_NO_STD_WSTREAMBUF Chris@16: Chris@16: #include Chris@16: #include // size_t Chris@16: #if defined(BOOST_NO_STDC_NAMESPACE) && ! defined(__LIBCOMO__) Chris@16: namespace std{ Chris@16: using ::strlen; Chris@16: using ::size_t; Chris@16: } // namespace std Chris@16: #endif Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace archive { Chris@16: Chris@16: ////////////////////////////////////////////////////////////////////// Chris@16: // implementation of woarchive functions Chris@16: // Chris@16: template Chris@16: BOOST_WARCHIVE_DECL(void) Chris@16: text_woarchive_impl::save(const char *s) Chris@16: { Chris@16: // note: superfluous local variable fixes borland warning Chris@16: const std::size_t size = std::strlen(s); Chris@16: * this->This() << size; Chris@16: this->This()->newtoken(); Chris@16: while(*s != '\0') Chris@16: os.put(os.widen(*s++)); Chris@16: } Chris@16: Chris@16: template Chris@16: BOOST_WARCHIVE_DECL(void) Chris@16: text_woarchive_impl::save(const std::string &s) Chris@16: { Chris@16: const std::size_t size = s.size(); Chris@16: * this->This() << size; Chris@16: this->This()->newtoken(); Chris@16: const char * cptr = s.data(); Chris@16: for(std::size_t i = size; i-- > 0;) Chris@16: os.put(os.widen(*cptr++)); Chris@16: } Chris@16: Chris@16: #ifndef BOOST_NO_INTRINSIC_WCHAR_T Chris@16: template Chris@16: BOOST_WARCHIVE_DECL(void) Chris@16: text_woarchive_impl::save(const wchar_t *ws) Chris@16: { Chris@16: const std::size_t size = std::wostream::traits_type::length(ws); Chris@16: * this->This() << size; Chris@16: this->This()->newtoken(); Chris@16: os.write(ws, size); Chris@16: } Chris@16: #endif Chris@16: Chris@16: #ifndef BOOST_NO_STD_WSTRING Chris@16: template Chris@16: BOOST_WARCHIVE_DECL(void) Chris@16: text_woarchive_impl::save(const std::wstring &ws) Chris@16: { Chris@16: const std::size_t size = ws.length(); Chris@16: * this->This() << size; Chris@16: this->This()->newtoken(); Chris@16: os.write(ws.data(), size); Chris@16: } Chris@16: #endif Chris@16: Chris@16: } // namespace archive Chris@16: } // namespace boost Chris@16: Chris@16: #endif Chris@16: