Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef BOOST_ARCHIVE_ITERATORS_DATAFLOW_HPP
0002 #define BOOST_ARCHIVE_ITERATORS_DATAFLOW_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 // dataflow.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/mpl/eval_if.hpp>
0022 #include <boost/mpl/if.hpp>
0023 #include <boost/mpl/apply.hpp>
0024 #include <boost/mpl/plus.hpp>
0025 #include <boost/mpl/int.hpp>
0026 
0027 #include <boost/type_traits/is_convertible.hpp>
0028 #include <boost/type_traits/is_base_and_derived.hpp>
0029 #include <boost/type_traits/is_pointer.hpp>
0030 #include <boost/iterator/iterator_adaptor.hpp>
0031 #include <boost/iterator/iterator_traits.hpp>
0032 #include <boost/static_assert.hpp>
0033 
0034 namespace boost {
0035 namespace archive {
0036 namespace iterators {
0037 
0038 // poor man's tri-state
0039 struct tri_state {
0040     enum state_enum {
0041         is_false = false,
0042         is_true = true,
0043         is_indeterminant
0044     } m_state;
0045     // convert to bool
0046     operator bool (){
0047         BOOST_ASSERT(is_indeterminant != m_state);
0048         return is_true == m_state ? true : false;
0049     }
0050     // assign from bool
0051     tri_state & operator=(bool rhs) {
0052         m_state = rhs ? is_true : is_false;
0053         return *this;
0054     }
0055     tri_state(bool rhs) :
0056         m_state(rhs ? is_true : is_false)
0057     {}
0058     tri_state(state_enum state) :
0059         m_state(state)
0060     {}
0061     bool operator==(const tri_state & rhs) const {
0062         return m_state == rhs.m_state;
0063     }
0064     bool operator!=(const tri_state & rhs) const {
0065         return m_state != rhs.m_state;
0066     }
0067 };
0068 
0069 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0070 // implement functions common to dataflow iterators
0071 template<class Derived>
0072 class dataflow {
0073     bool m_eoi;
0074 protected:
0075     // test for iterator equality
0076     tri_state equal(const Derived & rhs) const {
0077         if(m_eoi && rhs.m_eoi)
0078             return true;
0079         if(m_eoi || rhs.m_eoi)
0080             return false;
0081         return tri_state(tri_state::is_indeterminant);
0082     }
0083     void eoi(bool tf){
0084         m_eoi = tf;
0085     }
0086     bool eoi() const {
0087         return m_eoi;
0088     }
0089 public:
0090     dataflow(bool tf) :
0091         m_eoi(tf)
0092     {}
0093     dataflow() : // used for iterator end
0094         m_eoi(true)
0095     {}
0096 };
0097 
0098 } // namespace iterators
0099 } // namespace archive
0100 } // namespace boost
0101 
0102 #endif // BOOST_ARCHIVE_ITERATORS_DATAFLOW_HPP