source: NonGTP/Boost/boost/archive/iterators/unescape.hpp @ 857

Revision 857, 2.7 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]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) && (_MSC_VER >= 1020)
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 <cassert>
20
21#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
22#include <boost/iterator/iterator_adaptor.hpp>
23//#include <boost/iterator/iterator_traits.hpp>
24#include <boost/pointee.hpp>
25
26namespace boost {
27namespace archive {
28namespace iterators {
29
30/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
31// class used by text archives to translate char strings to wchar_t
32// strings of the currently selected locale
33template<class Derived, class Base>
34class unescape
35    : public boost::iterator_adaptor<
36        unescape<Derived, Base>,
37        Base,
38        BOOST_DEDUCED_TYPENAME pointee<Base>::type,
39        single_pass_traversal_tag,
40        BOOST_DEDUCED_TYPENAME pointee<Base>::type
41    >
42{
43    friend class boost::iterator_core_access;
44    typedef BOOST_DEDUCED_TYPENAME boost::iterator_adaptor<
45        unescape<Derived, Base>,
46        Base,
47        BOOST_DEDUCED_TYPENAME pointee<Base>::type,
48        single_pass_traversal_tag,
49        BOOST_DEDUCED_TYPENAME pointee<Base>::type
50    > super_t;
51
52    typedef unescape<Derived, Base> this_t;
53    typedef BOOST_DEDUCED_TYPENAME super_t::reference reference_type;
54public:
55    // gcc 3.4.1 - linux required that this be public
56    typedef BOOST_DEDUCED_TYPENAME super_t::value_type value_type;
57private:
58
59    reference_type dereference_impl() {
60        if(! m_full){
61            m_current_value = static_cast<Derived *>(this)->drain();
62            m_full = true;
63        }
64        return m_current_value;
65    }
66
67    reference_type dereference() const {
68        return const_cast<this_t *>(this)->dereference_impl();
69    }
70
71    // value_type is const char - can't be const fix later
72    value_type m_current_value;
73    bool m_full;
74
75    void increment(){
76        ++(this->base_reference());
77        dereference_impl();
78        m_full = false;
79    };
80
81public:
82
83    unescape(Base base) :
84        super_t(base),
85        m_full(false)    {}
86
87};
88
89} // namespace iterators
90} // namespace archive
91} // namespace boost
92
93#endif // BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP
Note: See TracBrowser for help on using the repository browser.