| 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) |
| 18 | namespace 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 | |
| 27 | namespace boost { |
| 28 | namespace archive { |
| 29 | |
| 30 | template<class Archive> |
| 31 | BOOST_ARCHIVE_DECL void |
| 32 | text_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: s, n: size); |
| 40 | s[size] = '\0'; |
| 41 | } |
| 42 | |
| 43 | template<class Archive> |
| 44 | BOOST_ARCHIVE_DECL void |
| 45 | text_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(n: size); |
| 56 | if(0 < size) |
| 57 | is.read(s: &(*s.begin()), n: size); |
| 58 | } |
| 59 | |
| 60 | #ifndef BOOST_NO_CWCHAR |
| 61 | #ifndef BOOST_NO_INTRINSIC_WCHAR_T |
| 62 | template<class Archive> |
| 63 | BOOST_ARCHIVE_DECL void |
| 64 | text_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(s: (char *)ws, n: 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 |
| 76 | template<class Archive> |
| 77 | BOOST_ARCHIVE_DECL void |
| 78 | text_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(n: size); |
| 87 | // skip separating space |
| 88 | is.get(); |
| 89 | is.read(s: (char *)ws.data(), n: size * sizeof(wchar_t)/sizeof(char)); |
| 90 | } |
| 91 | |
| 92 | #endif // BOOST_NO_STD_WSTRING |
| 93 | #endif // BOOST_NO_CWCHAR |
| 94 | |
| 95 | template<class Archive> |
| 96 | BOOST_ARCHIVE_DECL void |
| 97 | text_iarchive_impl<Archive>::load_override(class_name_type & t){ |
| 98 | basic_text_iarchive<Archive>::load_override(t); |
| 99 | } |
| 100 | |
| 101 | template<class Archive> |
| 102 | BOOST_ARCHIVE_DECL void |
| 103 | text_iarchive_impl<Archive>::init(){ |
| 104 | basic_text_iarchive<Archive>::init(); |
| 105 | } |
| 106 | |
| 107 | template<class Archive> |
| 108 | BOOST_ARCHIVE_DECL |
| 109 | text_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 | |