1/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 2// text_iarchive_impl.ipp: 3 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) 8 9// See http://www.boost.org for updates, documentation, and revision history. 10 11////////////////////////////////////////////////////////////////////// 12// implementation of basic_text_iprimitive overrides for the combination 13// of template parameters used to implement a text_iprimitive 14 15#include <cstddef> // size_t, NULL 16#include <boost/config.hpp> 17#if defined(BOOST_NO_STDC_NAMESPACE) 18namespace std{ 19 using ::size_t; 20} // namespace std 21#endif 22 23#include <boost/detail/workaround.hpp> // RogueWave 24 25#include <boost/archive/text_iarchive.hpp> 26 27namespace boost { 28namespace archive { 29 30template<class Archive> 31BOOST_ARCHIVE_DECL void 32text_iarchive_impl<Archive>::load(char *s) 33{ 34 std::size_t size; 35 * this->This() >> size; 36 // skip separating space 37 is.get(); 38 // Works on all tested platforms 39 is.read(s, size); 40 s[size] = '\0'; 41} 42 43template<class Archive> 44BOOST_ARCHIVE_DECL void 45text_iarchive_impl<Archive>::load(std::string &s) 46{ 47 std::size_t size; 48 * this->This() >> size; 49 // skip separating space 50 is.get(); 51 // borland de-allocator fixup 52 #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) 53 if(NULL != s.data()) 54 #endif 55 s.resize(size); 56 if(0 < size) 57 is.read(&(*s.begin()), size); 58} 59 60#ifndef BOOST_NO_CWCHAR 61#ifndef BOOST_NO_INTRINSIC_WCHAR_T 62template<class Archive> 63BOOST_ARCHIVE_DECL void 64text_iarchive_impl<Archive>::load(wchar_t *ws) 65{ 66 std::size_t size; 67 * this->This() >> size; 68 // skip separating space 69 is.get(); 70 is.read((char *)ws, size * sizeof(wchar_t)/sizeof(char)); 71 ws[size] = L'\0'; 72} 73#endif // BOOST_NO_INTRINSIC_WCHAR_T 74 75#ifndef BOOST_NO_STD_WSTRING 76template<class Archive> 77BOOST_ARCHIVE_DECL void 78text_iarchive_impl<Archive>::load(std::wstring &ws) 79{ 80 std::size_t size; 81 * this->This() >> size; 82 // borland de-allocator fixup 83 #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) 84 if(NULL != ws.data()) 85 #endif 86 ws.resize(size); 87 // skip separating space 88 is.get(); 89 is.read((char *)ws.data(), size * sizeof(wchar_t)/sizeof(char)); 90} 91 92#endif // BOOST_NO_STD_WSTRING 93#endif // BOOST_NO_CWCHAR 94 95template<class Archive> 96BOOST_ARCHIVE_DECL void 97text_iarchive_impl<Archive>::load_override(class_name_type & t){ 98 basic_text_iarchive<Archive>::load_override(t); 99} 100 101template<class Archive> 102BOOST_ARCHIVE_DECL void 103text_iarchive_impl<Archive>::init(){ 104 basic_text_iarchive<Archive>::init(); 105} 106 107template<class Archive> 108BOOST_ARCHIVE_DECL 109text_iarchive_impl<Archive>::text_iarchive_impl( 110 std::istream & is, 111 unsigned int flags 112) : 113 basic_text_iprimitive<std::istream>( 114 is, 115 0 != (flags & no_codecvt) 116 ), 117 basic_text_iarchive<Archive>(flags) 118{} 119 120} // namespace archive 121} // namespace boost 122