Back to home page

EIC code displayed by LXR

 
 

    


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 // 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 // insert_linebreaks.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 
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 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0034 // insert line break every N characters
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 //            m_count == rhs.m_count
0062 //            && base_reference() == rhs.base_reference()
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     // make composable by using templated constructor
0083     template<class T>
0084     insert_linebreaks(T  start) :
0085         super_t(Base(static_cast< T >(start))),
0086         m_count(0)
0087     {}
0088     // intel 7.1 doesn't like default copy constructor
0089     insert_linebreaks(const insert_linebreaks & rhs) :
0090         super_t(rhs.base_reference()),
0091         m_count(rhs.m_count)
0092     {}
0093 };
0094 
0095 } // namespace iterators
0096 } // namespace archive
0097 } // namespace boost
0098 
0099 #endif // BOOST_ARCHIVE_ITERATORS_INSERT_LINEBREAKS_HPP