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