]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/include/boost/archive/iterators/unescape.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / serialization / include / boost / archive / iterators / unescape.hpp
1 #ifndef BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP
2 #define BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP
3
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER)
6 # pragma once
7 #endif
8
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // unescape.hpp
11
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
16
17 // See http://www.boost.org for updates, documentation, and revision history.
18
19 #include <boost/assert.hpp>
20
21 #include <boost/iterator/iterator_adaptor.hpp>
22 #include <boost/pointee.hpp>
23
24 namespace boost {
25 namespace archive {
26 namespace iterators {
27
28 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
29 // class used by text archives to translate char strings to wchar_t
30 // strings of the currently selected locale
31 template<class Derived, class Base>
32 class unescape
33 : public boost::iterator_adaptor<
34 unescape<Derived, Base>,
35 Base,
36 typename pointee<Base>::type,
37 single_pass_traversal_tag,
38 typename pointee<Base>::type
39 >
40 {
41 friend class boost::iterator_core_access;
42 typedef typename boost::iterator_adaptor<
43 unescape<Derived, Base>,
44 Base,
45 typename pointee<Base>::type,
46 single_pass_traversal_tag,
47 typename pointee<Base>::type
48 > super_t;
49
50 typedef unescape<Derived, Base> this_t;
51 public:
52 typedef typename this_t::value_type value_type;
53 typedef typename this_t::reference reference;
54 private:
55 value_type dereference_impl() {
56 if(! m_full){
57 m_current_value = static_cast<Derived *>(this)->drain();
58 m_full = true;
59 }
60 return m_current_value;
61 }
62
63 reference dereference() const {
64 return const_cast<this_t *>(this)->dereference_impl();
65 }
66
67 value_type m_current_value;
68 bool m_full;
69
70 void increment(){
71 ++(this->base_reference());
72 dereference_impl();
73 m_full = false;
74 };
75
76 public:
77
78 unescape(Base base) :
79 super_t(base),
80 m_full(false)
81 {}
82
83 };
84
85 } // namespace iterators
86 } // namespace archive
87 } // namespace boost
88
89 #endif // BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP