1 #ifndef BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP
2 #define BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP
4 // MS compatible compilers support #pragma once
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
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)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 #include <boost/assert.hpp>
20 #include <cstddef> // NULL
22 #include <boost/iterator/iterator_adaptor.hpp>
23 #include <boost/iterator/iterator_traits.hpp>
29 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
30 // insert escapes into text
32 template<class Derived, class Base>
34 public boost::iterator_adaptor<
37 typename boost::iterator_value<Base>::type,
38 single_pass_traversal_tag,
39 typename boost::iterator_value<Base>::type
42 typedef typename boost::iterator_value<Base>::type base_value_type;
43 typedef typename boost::iterator_reference<Base>::type reference_type;
44 friend class boost::iterator_core_access;
46 typedef typename boost::iterator_adaptor<
50 single_pass_traversal_tag,
54 typedef escape<Derived, Base> this_t;
56 void dereference_impl() {
57 m_current_value = static_cast<Derived *>(this)->fill(m_bnext, m_bend);
61 //Access the value referred to
62 reference_type dereference() const {
64 const_cast<this_t *>(this)->dereference_impl();
65 return m_current_value;
68 bool equal(const this_t & rhs) const {
71 const_cast<this_t *>(& rhs)->dereference_impl();
75 const_cast<this_t *>(this)->dereference_impl();
77 if(m_bnext != rhs.m_bnext)
79 if(this->base_reference() != rhs.base_reference())
85 if(++m_bnext < m_bend){
86 m_current_value = *m_bnext;
89 ++(this->base_reference());
95 // buffer to handle pending characters
96 const base_value_type *m_bnext;
97 const base_value_type *m_bend;
99 base_value_type m_current_value;
110 } // namespace iterators
111 } // namespace archive
114 #endif // BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP