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
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/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
0039 struct tri_state {
0040 enum state_enum {
0041 is_false = false,
0042 is_true = true,
0043 is_indeterminant
0044 } m_state;
0045
0046 operator bool (){
0047 BOOST_ASSERT(is_indeterminant != m_state);
0048 return is_true == m_state ? true : false;
0049 }
0050
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
0070
0071 template<class Derived>
0072 class dataflow {
0073 bool m_eoi;
0074 protected:
0075
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() :
0094 m_eoi(true)
0095 {}
0096 };
0097
0098 }
0099 }
0100 }
0101
0102 #endif