Chris@16: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 Chris@16: // text_text_wiarchive_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 // size_t, NULL Chris@16: Chris@16: #include Chris@16: #if defined(BOOST_NO_STDC_NAMESPACE) Chris@16: namespace std{ Chris@16: using ::size_t; Chris@16: } // namespace std Chris@16: #endif Chris@16: Chris@16: #include // fixup for RogueWave Chris@16: Chris@16: #ifndef BOOST_NO_STD_WSTREAMBUF Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace archive { Chris@16: Chris@16: ////////////////////////////////////////////////////////////////////// Chris@16: // implementation of wiprimtives functions Chris@16: // Chris@16: template Chris@16: BOOST_WARCHIVE_DECL(void) Chris@16: text_wiarchive_impl::load(char *s) Chris@16: { Chris@16: std::size_t size; Chris@16: * this->This() >> size; Chris@16: // skip separating space Chris@16: is.get(); Chris@16: while(size-- > 0){ Chris@16: *s++ = is.narrow(is.get(), '\0'); Chris@16: } Chris@16: *s = '\0'; Chris@16: } Chris@16: Chris@16: template Chris@16: BOOST_WARCHIVE_DECL(void) Chris@16: text_wiarchive_impl::load(std::string &s) Chris@16: { Chris@16: std::size_t size; Chris@16: * this->This() >> size; Chris@16: // skip separating space Chris@16: is.get(); Chris@16: #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) Chris@16: if(NULL != s.data()) Chris@16: #endif Chris@16: s.resize(0); Chris@16: s.reserve(size); Chris@16: while(size-- > 0){ Chris@16: int x = is.narrow(is.get(), '\0'); Chris@16: s += x; Chris@16: } Chris@16: } Chris@16: Chris@16: #ifndef BOOST_NO_INTRINSIC_WCHAR_T Chris@16: template Chris@16: BOOST_WARCHIVE_DECL(void) Chris@16: text_wiarchive_impl::load(wchar_t *s) Chris@16: { Chris@16: std::size_t size; Chris@16: * this->This() >> size; Chris@16: // skip separating space Chris@16: is.get(); Chris@16: // Works on all tested platforms Chris@16: is.read(s, size); Chris@16: s[size] = L'\0'; 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_wiarchive_impl::load(std::wstring &ws) Chris@16: { Chris@16: std::size_t size; Chris@16: * this->This() >> size; Chris@16: // skip separating space Chris@16: is.get(); Chris@16: // borland complains about resize Chris@16: // borland de-allocator fixup Chris@16: #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) Chris@16: if(NULL != ws.data()) Chris@16: #endif Chris@16: ws.resize(size); Chris@16: // note breaking a rule here - is this a problem on some platform Chris@16: is.read(const_cast(ws.data()), size); Chris@16: } Chris@16: #endif Chris@16: Chris@16: template Chris@16: BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY()) Chris@16: text_wiarchive_impl::text_wiarchive_impl( Chris@16: std::wistream & is, Chris@16: unsigned int flags Chris@16: ) : Chris@16: basic_text_iprimitive( Chris@16: is, Chris@16: 0 != (flags & no_codecvt) Chris@16: ), Chris@16: basic_text_iarchive(flags) Chris@16: { Chris@16: if(0 == (flags & no_header)) Chris@16: basic_text_iarchive::init(); Chris@16: } Chris@16: Chris@16: } // archive Chris@16: } // boost Chris@16: Chris@16: #endif // BOOST_NO_STD_WSTREAMBUF