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_text_wiarchive_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 <cstddef> // size_t, NULL
0012 
0013 #include <boost/config.hpp>
0014 #if defined(BOOST_NO_STDC_NAMESPACE)
0015 namespace std{ 
0016     using ::size_t; 
0017 } // namespace std
0018 #endif
0019 
0020 #include <boost/detail/workaround.hpp>  // fixup for RogueWave
0021 
0022 #ifndef BOOST_NO_STD_WSTREAMBUF
0023 #include <boost/archive/basic_text_iprimitive.hpp>
0024 
0025 namespace boost { 
0026 namespace archive {
0027 
0028 //////////////////////////////////////////////////////////////////////
0029 // implementation of wiprimtives functions
0030 //
0031 template<class Archive>
0032 BOOST_WARCHIVE_DECL void
0033 text_wiarchive_impl<Archive>::load(char *s)
0034 {
0035     std::size_t size;
0036     * this->This() >> size;
0037     // skip separating space
0038     is.get();
0039     while(size-- > 0){
0040         *s++ = is.narrow(is.get(), '\0');
0041     }
0042     *s = '\0';
0043 }
0044 
0045 template<class Archive>
0046 BOOST_WARCHIVE_DECL void
0047 text_wiarchive_impl<Archive>::load(std::string &s)
0048 {
0049     std::size_t size;
0050     * this->This() >> size;
0051     // skip separating space
0052     is.get();
0053     #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
0054     if(NULL != s.data())
0055     #endif
0056         s.resize(0);
0057     s.reserve(size);
0058     while(size-- > 0){
0059         char x = is.narrow(is.get(), '\0');
0060         s += x;
0061     }
0062 }
0063 
0064 #ifndef BOOST_NO_INTRINSIC_WCHAR_T
0065 template<class Archive>
0066 BOOST_WARCHIVE_DECL void
0067 text_wiarchive_impl<Archive>::load(wchar_t *s)
0068 {
0069     std::size_t size;
0070     * this->This() >> size;
0071     // skip separating space
0072     is.get();
0073     // Works on all tested platforms
0074     is.read(s, size);
0075     s[size] = L'\0';
0076 }
0077 #endif
0078 
0079 #ifndef BOOST_NO_STD_WSTRING
0080 template<class Archive>
0081 BOOST_WARCHIVE_DECL void
0082 text_wiarchive_impl<Archive>::load(std::wstring &ws)
0083 {
0084     std::size_t size;
0085     * this->This() >> size;
0086     // skip separating space
0087     is.get();
0088     // borland complains about resize
0089     // borland de-allocator fixup
0090     #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
0091     if(NULL != ws.data())
0092     #endif
0093         ws.resize(size);
0094     // note breaking a rule here - is this a problem on some platform
0095     is.read(const_cast<wchar_t *>(ws.data()), size);
0096 }
0097 #endif
0098 
0099 template<class Archive>
0100 BOOST_WARCHIVE_DECL 
0101 text_wiarchive_impl<Archive>::text_wiarchive_impl(
0102     std::wistream & is, 
0103     unsigned int flags
0104 ) :
0105     basic_text_iprimitive<std::wistream>(
0106         is, 
0107         0 != (flags & no_codecvt)
0108     ),
0109     basic_text_iarchive<Archive>(flags)
0110 {
0111 }
0112 
0113 } // archive
0114 } // boost
0115 
0116 #endif // BOOST_NO_STD_WSTREAMBUF