annotate DEPENDENCIES/generic/include/boost/archive/iterators/insert_linebreaks.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 #ifndef BOOST_ARCHIVE_ITERATORS_INSERT_LINEBREAKS_HPP
Chris@16 2 #define BOOST_ARCHIVE_ITERATORS_INSERT_LINEBREAKS_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 // insert_linebreaks.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@101 21 #include <boost/config.hpp>
Chris@16 22 #if defined(BOOST_NO_STDC_NAMESPACE)
Chris@16 23 namespace std{ using ::memcpy; }
Chris@16 24 #endif
Chris@16 25
Chris@16 26 #include <boost/serialization/pfto.hpp>
Chris@16 27
Chris@16 28 #include <boost/iterator/iterator_adaptor.hpp>
Chris@16 29 #include <boost/iterator/iterator_traits.hpp>
Chris@16 30
Chris@16 31 namespace boost {
Chris@16 32 namespace archive {
Chris@16 33 namespace iterators {
Chris@16 34
Chris@16 35 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
Chris@16 36 // insert line break every N characters
Chris@16 37 template<
Chris@16 38 class Base,
Chris@16 39 int N,
Chris@101 40 class CharType = typename boost::iterator_value<Base>::type
Chris@16 41 >
Chris@16 42 class insert_linebreaks :
Chris@16 43 public iterator_adaptor<
Chris@16 44 insert_linebreaks<Base, N, CharType>,
Chris@16 45 Base,
Chris@16 46 CharType,
Chris@16 47 single_pass_traversal_tag,
Chris@16 48 CharType
Chris@16 49 >
Chris@16 50 {
Chris@16 51 private:
Chris@16 52 friend class boost::iterator_core_access;
Chris@16 53 typedef iterator_adaptor<
Chris@16 54 insert_linebreaks<Base, N, CharType>,
Chris@16 55 Base,
Chris@16 56 CharType,
Chris@16 57 single_pass_traversal_tag,
Chris@16 58 CharType
Chris@16 59 > super_t;
Chris@16 60
Chris@16 61 bool equal(const insert_linebreaks<Base, N, CharType> & rhs) const {
Chris@16 62 return
Chris@16 63 // m_count == rhs.m_count
Chris@16 64 // && base_reference() == rhs.base_reference()
Chris@16 65 this->base_reference() == rhs.base_reference()
Chris@16 66 ;
Chris@16 67 }
Chris@16 68
Chris@16 69 void increment() {
Chris@16 70 if(m_count == N){
Chris@16 71 m_count = 0;
Chris@16 72 return;
Chris@16 73 }
Chris@16 74 ++m_count;
Chris@16 75 ++(this->base_reference());
Chris@16 76 }
Chris@16 77 CharType dereference() const {
Chris@16 78 if(m_count == N)
Chris@16 79 return '\n';
Chris@16 80 return * (this->base_reference());
Chris@16 81 }
Chris@16 82 unsigned int m_count;
Chris@16 83 public:
Chris@16 84 // make composible buy using templated constructor
Chris@16 85 template<class T>
Chris@16 86 insert_linebreaks(BOOST_PFTO_WRAPPER(T) start) :
Chris@16 87 super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))),
Chris@16 88 m_count(0)
Chris@16 89 {}
Chris@16 90 // intel 7.1 doesn't like default copy constructor
Chris@16 91 insert_linebreaks(const insert_linebreaks & rhs) :
Chris@16 92 super_t(rhs.base_reference()),
Chris@16 93 m_count(rhs.m_count)
Chris@16 94 {}
Chris@16 95 };
Chris@16 96
Chris@16 97 } // namespace iterators
Chris@16 98 } // namespace archive
Chris@16 99 } // namespace boost
Chris@16 100
Chris@16 101 #endif // BOOST_ARCHIVE_ITERATORS_INSERT_LINEBREAKS_HPP