aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/boost/libs/serialization/src/codecvt_null.cpp
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/restricted/boost/libs/serialization/src/codecvt_null.cpp
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/restricted/boost/libs/serialization/src/codecvt_null.cpp')
-rw-r--r--contrib/restricted/boost/libs/serialization/src/codecvt_null.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/contrib/restricted/boost/libs/serialization/src/codecvt_null.cpp b/contrib/restricted/boost/libs/serialization/src/codecvt_null.cpp
new file mode 100644
index 0000000000..624afc2161
--- /dev/null
+++ b/contrib/restricted/boost/libs/serialization/src/codecvt_null.cpp
@@ -0,0 +1,84 @@
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// codecvt_null.cpp
+
+// Copyright (c) 2004 Robert Ramey, Indiana University (garcia@osl.iu.edu)
+// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
+// Use, modification and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_WARCHIVE_SOURCE
+#include <boost/serialization/config.hpp>
+#include <boost/archive/codecvt_null.hpp>
+
+// codecvt implementation for passing wchar_t objects to char output
+// without any translation whatever. Used to implement binary output
+// of wchar_t objects.
+
+namespace boost {
+namespace archive {
+
+std::codecvt_base::result
+codecvt_null<wchar_t>::do_out(
+ std::mbstate_t & /*state*/,
+ const wchar_t * first1,
+ const wchar_t * last1,
+ const wchar_t * & next1,
+ char * first2,
+ char * last2,
+ char * & next2
+) const {
+ while(first1 != last1){
+ // Per std::22.2.1.5.2/2, we can store no more that
+ // last2-first2 characters. If we need to more encode
+ // next internal char type, return 'partial'.
+ if(static_cast<int>(sizeof(wchar_t)) > (last2 - first2)){
+ next1 = first1;
+ next2 = first2;
+ return std::codecvt_base::partial;
+ }
+ * reinterpret_cast<wchar_t *>(first2) = * first1++;
+ first2 += sizeof(wchar_t);
+
+ }
+ next1 = first1;
+ next2 = first2;
+ return std::codecvt_base::ok;
+}
+
+std::codecvt_base::result
+codecvt_null<wchar_t>::do_in(
+ std::mbstate_t & /*state*/,
+ const char * first1,
+ const char * last1,
+ const char * & next1,
+ wchar_t * first2,
+ wchar_t * last2,
+ wchar_t * & next2
+) const {
+ // Process input characters until we've run of them,
+ // or the number of remaining characters is not
+ // enough to construct another output character,
+ // or we've run out of place for output characters.
+ while(first2 != last2){
+ // Have we converted all input characters?
+ // Return with 'ok', if so.
+ if (first1 == last1)
+ break;
+ // Do we have less input characters than needed
+ // for a single output character?
+ if(static_cast<int>(sizeof(wchar_t)) > (last1 - first1)){
+ next1 = first1;
+ next2 = first2;
+ return std::codecvt_base::partial;
+ }
+ *first2++ = * reinterpret_cast<const wchar_t *>(first1);
+ first1 += sizeof(wchar_t);
+ }
+ next1 = first1;
+ next2 = first2;
+ return std::codecvt_base::ok;
+}
+
+} // namespace archive
+} // namespace boost