| 1 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
|---|
| 2 | // xml_woarchive.cpp: |
|---|
| 3 | |
|---|
| 4 | // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . |
|---|
| 5 | // Use, modification and distribution is subject to the Boost Software |
|---|
| 6 | // License, Version 1.0. (See 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 | #include <boost/config.hpp> |
|---|
| 12 | #ifdef BOOST_NO_STD_WSTREAMBUF |
|---|
| 13 | #error "wide char i/o not supported on this platform" |
|---|
| 14 | #else |
|---|
| 15 | |
|---|
| 16 | #define BOOST_WARCHIVE_SOURCE |
|---|
| 17 | #include <boost/archive/xml_woarchive.hpp> |
|---|
| 18 | |
|---|
| 19 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
|---|
| 20 | // implemenations of functions specific to wide char archives |
|---|
| 21 | |
|---|
| 22 | #include <boost/archive/impl/basic_xml_oarchive.ipp> |
|---|
| 23 | #include <boost/archive/impl/xml_woarchive_impl.ipp> |
|---|
| 24 | #include <boost/archive/impl/archive_pointer_oserializer.ipp> |
|---|
| 25 | |
|---|
| 26 | namespace boost { |
|---|
| 27 | namespace archive { |
|---|
| 28 | |
|---|
| 29 | BOOST_WARCHIVE_DECL(std::wostream &) |
|---|
| 30 | operator<<(std::wostream &os, const char *t){ |
|---|
| 31 | for(;;){ |
|---|
| 32 | wchar_t wc; |
|---|
| 33 | int result = std::mbtowc(&wc, t, 10 /* max number */); |
|---|
| 34 | if(0 < result) |
|---|
| 35 | os.put(wc); |
|---|
| 36 | else |
|---|
| 37 | if(0 == result) |
|---|
| 38 | break; |
|---|
| 39 | else |
|---|
| 40 | boost::throw_exception( |
|---|
| 41 | iterators::dataflow_exception( |
|---|
| 42 | iterators::dataflow_exception::invalid_conversion |
|---|
| 43 | ) |
|---|
| 44 | ); |
|---|
| 45 | } |
|---|
| 46 | return os; |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | BOOST_WARCHIVE_DECL(std::wostream &) |
|---|
| 50 | operator<<(std::wostream &os, const char t){ |
|---|
| 51 | wchar_t wc; |
|---|
| 52 | std::mbtowc(&wc, &t, 1); |
|---|
| 53 | os.put(wc); |
|---|
| 54 | return os; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | template class basic_xml_oarchive<xml_woarchive> ; |
|---|
| 58 | template class xml_woarchive_impl<xml_woarchive> ; |
|---|
| 59 | template class detail::archive_pointer_oserializer<xml_woarchive> ; |
|---|
| 60 | |
|---|
| 61 | } // namespace archive |
|---|
| 62 | } // namespace boost |
|---|
| 63 | |
|---|
| 64 | #endif // BOOST_NO_STD_WSTREAMBUF |
|---|