annotate DEPENDENCIES/generic/include/boost/archive/iterators/escape.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 #ifndef BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP
Chris@16 2 #define BOOST_ARCHIVE_ITERATORS_ESCAPE_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 // escape.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 #include <cstddef> // NULL
Chris@16 21
Chris@16 22 #include <boost/iterator/iterator_adaptor.hpp>
Chris@16 23 #include <boost/iterator/iterator_traits.hpp>
Chris@16 24
Chris@16 25 namespace boost {
Chris@16 26 namespace archive {
Chris@16 27 namespace iterators {
Chris@16 28
Chris@16 29 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
Chris@16 30 // insert escapes into text
Chris@16 31
Chris@16 32 template<class Derived, class Base>
Chris@16 33 class escape :
Chris@16 34 public boost::iterator_adaptor<
Chris@16 35 Derived,
Chris@16 36 Base,
Chris@101 37 typename boost::iterator_value<Base>::type,
Chris@16 38 single_pass_traversal_tag,
Chris@101 39 typename boost::iterator_value<Base>::type
Chris@16 40 >
Chris@16 41 {
Chris@101 42 typedef typename boost::iterator_value<Base>::type base_value_type;
Chris@101 43 typedef typename boost::iterator_reference<Base>::type reference_type;
Chris@16 44 friend class boost::iterator_core_access;
Chris@16 45
Chris@101 46 typedef typename boost::iterator_adaptor<
Chris@16 47 Derived,
Chris@16 48 Base,
Chris@16 49 base_value_type,
Chris@16 50 single_pass_traversal_tag,
Chris@16 51 base_value_type
Chris@16 52 > super_t;
Chris@16 53
Chris@16 54 typedef escape<Derived, Base> this_t;
Chris@16 55
Chris@16 56 void dereference_impl() {
Chris@16 57 m_current_value = static_cast<Derived *>(this)->fill(m_bnext, m_bend);
Chris@16 58 m_full = true;
Chris@16 59 }
Chris@16 60
Chris@16 61 //Access the value referred to
Chris@16 62 reference_type dereference() const {
Chris@16 63 if(!m_full)
Chris@16 64 const_cast<this_t *>(this)->dereference_impl();
Chris@16 65 return m_current_value;
Chris@16 66 }
Chris@16 67
Chris@16 68 bool equal(const this_t & rhs) const {
Chris@16 69 if(m_full){
Chris@16 70 if(! rhs.m_full)
Chris@16 71 const_cast<this_t *>(& rhs)->dereference_impl();
Chris@16 72 }
Chris@16 73 else{
Chris@16 74 if(rhs.m_full)
Chris@16 75 const_cast<this_t *>(this)->dereference_impl();
Chris@16 76 }
Chris@16 77 if(m_bnext != rhs.m_bnext)
Chris@16 78 return false;
Chris@16 79 if(this->base_reference() != rhs.base_reference())
Chris@16 80 return false;
Chris@16 81 return true;
Chris@16 82 }
Chris@16 83
Chris@16 84 void increment(){
Chris@16 85 if(++m_bnext < m_bend){
Chris@16 86 m_current_value = *m_bnext;
Chris@16 87 return;
Chris@16 88 }
Chris@16 89 ++(this->base_reference());
Chris@16 90 m_bnext = NULL;
Chris@16 91 m_bend = NULL;
Chris@16 92 m_full = false;
Chris@16 93 }
Chris@16 94
Chris@16 95 // buffer to handle pending characters
Chris@16 96 const base_value_type *m_bnext;
Chris@16 97 const base_value_type *m_bend;
Chris@16 98 bool m_full;
Chris@16 99 base_value_type m_current_value;
Chris@16 100 public:
Chris@16 101 escape(Base base) :
Chris@16 102 super_t(base),
Chris@16 103 m_bnext(NULL),
Chris@16 104 m_bend(NULL),
Chris@16 105 m_full(false)
Chris@16 106 {
Chris@16 107 }
Chris@16 108 };
Chris@16 109
Chris@16 110 } // namespace iterators
Chris@16 111 } // namespace archive
Chris@16 112 } // namespace boost
Chris@16 113
Chris@16 114 #endif // BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP