12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #ifndef BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP
- #define BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1020)
- # pragma once
- #endif
- #include <cassert>
- #include <boost/config.hpp>
- #include <boost/iterator/iterator_adaptor.hpp>
- #include <boost/pointee.hpp>
- namespace boost {
- namespace archive {
- namespace iterators {
- template<class Derived, class Base>
- class unescape
- : public boost::iterator_adaptor<
- unescape<Derived, Base>,
- Base,
- BOOST_DEDUCED_TYPENAME pointee<Base>::type,
- single_pass_traversal_tag,
- BOOST_DEDUCED_TYPENAME pointee<Base>::type
- >
- {
- friend class boost::iterator_core_access;
- typedef BOOST_DEDUCED_TYPENAME boost::iterator_adaptor<
- unescape<Derived, Base>,
- Base,
- BOOST_DEDUCED_TYPENAME pointee<Base>::type,
- single_pass_traversal_tag,
- BOOST_DEDUCED_TYPENAME pointee<Base>::type
- > super_t;
- typedef unescape<Derived, Base> this_t;
- typedef BOOST_DEDUCED_TYPENAME super_t::reference reference_type;
- public:
-
- typedef BOOST_DEDUCED_TYPENAME super_t::value_type value_type;
- private:
- reference_type dereference_impl() {
- if(! m_full){
- m_current_value = static_cast<Derived *>(this)->drain();
- m_full = true;
- }
- return m_current_value;
- }
- reference_type dereference() const {
- return const_cast<this_t *>(this)->dereference_impl();
- }
-
- value_type m_current_value;
- bool m_full;
- void increment(){
- ++(this->base_reference());
- dereference_impl();
- m_full = false;
- };
- public:
- unescape(Base base) :
- super_t(base),
- m_full(false)
- {}
- };
- }
- }
- }
- #endif
|