File indexing completed on 2025-01-18 09:28:29
0001 #ifndef BOOST_ARCHIVE_ITERATORS_INSERT_LINEBREAKS_HPP
0002 #define BOOST_ARCHIVE_ITERATORS_INSERT_LINEBREAKS_HPP
0003
0004
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include <boost/assert.hpp>
0020
0021 #include <boost/config.hpp>
0022 #if defined(BOOST_NO_STDC_NAMESPACE)
0023 namespace std{ using ::memcpy; }
0024 #endif
0025
0026 #include <boost/iterator/iterator_adaptor.hpp>
0027 #include <boost/iterator/iterator_traits.hpp>
0028
0029 namespace boost {
0030 namespace archive {
0031 namespace iterators {
0032
0033
0034
0035 template<
0036 class Base,
0037 int N,
0038 class CharType = typename boost::iterator_value<Base>::type
0039 >
0040 class insert_linebreaks :
0041 public iterator_adaptor<
0042 insert_linebreaks<Base, N, CharType>,
0043 Base,
0044 CharType,
0045 single_pass_traversal_tag,
0046 CharType
0047 >
0048 {
0049 private:
0050 friend class boost::iterator_core_access;
0051 typedef iterator_adaptor<
0052 insert_linebreaks<Base, N, CharType>,
0053 Base,
0054 CharType,
0055 single_pass_traversal_tag,
0056 CharType
0057 > super_t;
0058
0059 bool equal(const insert_linebreaks<Base, N, CharType> & rhs) const {
0060 return
0061
0062
0063 this->base_reference() == rhs.base_reference()
0064 ;
0065 }
0066
0067 void increment() {
0068 if(m_count == N){
0069 m_count = 0;
0070 return;
0071 }
0072 ++m_count;
0073 ++(this->base_reference());
0074 }
0075 CharType dereference() const {
0076 if(m_count == N)
0077 return '\n';
0078 return * (this->base_reference());
0079 }
0080 unsigned int m_count;
0081 public:
0082
0083 template<class T>
0084 insert_linebreaks(T start) :
0085 super_t(Base(static_cast< T >(start))),
0086 m_count(0)
0087 {}
0088
0089 insert_linebreaks(const insert_linebreaks & rhs) :
0090 super_t(rhs.base_reference()),
0091 m_count(rhs.m_count)
0092 {}
0093 };
0094
0095 }
0096 }
0097 }
0098
0099 #endif