VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /usr/include/boost/gil/io/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/include/boost/gil/io/scanline_read_iterator.hpp
//
// Copyright 2007-2008 Christian Henning
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#ifndef BOOST_GIL_IO_SCANLINE_READ_ITERATOR_HPP
#define BOOST_GIL_IO_SCANLINE_READ_ITERATOR_HPP

#include <boost/gil/io/error.hpp>
#include <boost/gil/io/typedefs.hpp>

#include <boost/iterator/iterator_facade.hpp>

#include <iterator>
#include <memory>
#include <vector>

namespace boost { namespace gil {

#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(push)
#pragma warning(disable:4512) //assignment operator could not be generated
#endif

/// Input iterator to read images.
template< typename Reader >
class scanline_read_iterator : public boost::iterator_facade< scanline_read_iterator< Reader >
                                                            , byte_t*
                                                            , std::input_iterator_tag
                                                            >
{
private:

    using base_t = boost::iterator_facade
        <
            scanline_read_iterator<Reader>,
            byte_t*,
            std::input_iterator_tag
        >;


public:

    scanline_read_iterator( Reader& reader
                          , int     pos = 0
                          )
    : _pos( pos )
    , _read_scanline( true )
    , _skip_scanline( true )
    , _reader( reader )
    {
        _buffer = std::make_shared<  buffer_t >( buffer_t( _reader._scanline_length ));
        _buffer_start = &_buffer->front();
    }

private:
    friend class boost::iterator_core_access;

    void increment()
    {
        if( _skip_scanline == true )
        {
            _reader.skip( _buffer_start
                        , _pos
                        );
        }

        ++_pos;

        _skip_scanline = true;
        _read_scanline = true;
    }

    bool equal( const scanline_read_iterator& rhs ) const
    {
        return _pos == rhs._pos;
    }

    typename base_t::reference dereference() const
    {
        if( _read_scanline == true )
        {
            _reader.read( _buffer_start
                        , _pos
                        );
        }

        _skip_scanline = false;
        _read_scanline = false;

        return _buffer_start;
    }

private:
    Reader& _reader;

    mutable int _pos;

    mutable bool _read_scanline;
    mutable bool _skip_scanline;

    using buffer_t = std::vector<byte_t>;
    using buffer_ptr_t = std::shared_ptr<buffer_t>;

    buffer_ptr_t _buffer;
    mutable byte_t* _buffer_start;
};

#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif

} // namespace gil
} // namespace boost

#endif

VaKeR 2022