Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:33:00

0001 #ifndef BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP
0002 #define BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP
0003 
0004 // MS compatible compilers support #pragma once
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008 
0009 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0010 // escape.hpp
0011 
0012 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
0013 // Use, modification and distribution is subject to the Boost Software
0014 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0015 // http://www.boost.org/LICENSE_1_0.txt)
0016 
0017 //  See http://www.boost.org for updates, documentation, and revision history.
0018 
0019 #include <boost/assert.hpp>
0020 #include <cstddef> // NULL
0021 
0022 #include <boost/iterator/iterator_adaptor.hpp>
0023 #include <boost/iterator/iterator_traits.hpp>
0024 
0025 namespace boost {
0026 namespace archive {
0027 namespace iterators {
0028 
0029 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0030 // insert escapes into text
0031 
0032 template<class Derived, class Base>
0033 class escape :
0034     public boost::iterator_adaptor<
0035         Derived,
0036         Base,
0037         typename boost::iterator_value<Base>::type,
0038         single_pass_traversal_tag,
0039         typename boost::iterator_value<Base>::type
0040     >
0041 {
0042     typedef typename boost::iterator_value<Base>::type base_value_type;
0043     typedef typename boost::iterator_reference<Base>::type reference_type;
0044     friend class boost::iterator_core_access;
0045 
0046     typedef typename boost::iterator_adaptor<
0047         Derived,
0048         Base,
0049         base_value_type,
0050         single_pass_traversal_tag,
0051         base_value_type
0052     > super_t;
0053 
0054     typedef escape<Derived, Base> this_t;
0055 
0056     void dereference_impl() {
0057         m_current_value = static_cast<Derived *>(this)->fill(m_bnext, m_bend);
0058         m_full = true;
0059     }
0060 
0061     //Access the value referred to
0062     reference_type dereference() const {
0063         if(!m_full)
0064             const_cast<this_t *>(this)->dereference_impl();
0065         return m_current_value;
0066     }
0067 
0068     bool equal(const this_t & rhs) const {
0069         if(m_full){
0070             if(! rhs.m_full)
0071                 const_cast<this_t *>(& rhs)->dereference_impl();
0072         }
0073         else{
0074             if(rhs.m_full)
0075                 const_cast<this_t *>(this)->dereference_impl();
0076         }
0077         if(m_bnext != rhs.m_bnext)
0078             return false;
0079         if(this->base_reference() != rhs.base_reference())
0080             return false;
0081         return true;
0082     }
0083 
0084    void increment(){
0085         if(m_bnext != NULL && ++m_bnext < m_bend){
0086             m_current_value = *m_bnext;
0087             return;
0088         }
0089         ++(this->base_reference());
0090         m_bnext = NULL;
0091         m_bend = NULL;
0092         m_full = false;
0093     }
0094 
0095     // buffer to handle pending characters
0096     const base_value_type *m_bnext;
0097     const base_value_type *m_bend;
0098     bool m_full;
0099     base_value_type m_current_value;
0100 public:
0101     escape(Base base) :
0102         super_t(base),
0103         m_bnext(NULL),
0104         m_bend(NULL),
0105         m_full(false),
0106         m_current_value(0)
0107     {
0108     }
0109 };
0110 
0111 } // namespace iterators
0112 } // namespace archive
0113 } // namespace boost
0114 
0115 #endif // BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP