]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/src/codecvt_null.cpp
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
4 // Copyright (c) 2004 Robert Ramey, Indiana University (garcia@osl.iu.edu)
5 // Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
6 // Use, modification and distribution is subject to the Boost Software
7 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 #define BOOST_WARCHIVE_SOURCE
11 #include <boost/serialization/config.hpp>
12 #include <boost/archive/codecvt_null.hpp>
14 // codecvt implementation for passing wchar_t objects to char output
15 // without any translation whatever. Used to implement binary output
16 // of wchar_t objects.
21 std::codecvt_base::result
22 codecvt_null
<wchar_t>::do_out(
23 std::mbstate_t & /*state*/,
24 const wchar_t * first1
,
25 const wchar_t * last1
,
26 const wchar_t * & next1
,
31 while(first1
!= last1
){
32 // Per std::22.2.1.5.2/2, we can store no more that
33 // last2-first2 characters. If we need to more encode
34 // next internal char type, return 'partial'.
35 if(static_cast<int>(sizeof(wchar_t)) > (last2
- first2
)){
38 return std::codecvt_base::partial
;
40 * reinterpret_cast<wchar_t *>(first2
) = * first1
++;
41 first2
+= sizeof(wchar_t);
46 return std::codecvt_base::ok
;
49 std::codecvt_base::result
50 codecvt_null
<wchar_t>::do_in(
51 std::mbstate_t & /*state*/,
59 // Process input characters until we've run of them,
60 // or the number of remaining characters is not
61 // enough to construct another output character,
62 // or we've run out of place for output characters.
63 while(first2
!= last2
){
64 // Have we converted all input characters?
65 // Return with 'ok', if so.
68 // Do we have less input characters than needed
69 // for a single output character?
70 if(static_cast<int>(sizeof(wchar_t)) > (last1
- first1
)){
73 return std::codecvt_base::partial
;
75 *first2
++ = * reinterpret_cast<const wchar_t *>(first1
);
76 first1
+= sizeof(wchar_t);
80 return std::codecvt_base::ok
;
83 } // namespace archive