2016-02-09 20:35:13 +00:00
|
|
|
/* Copyright 2015, 2016, Michele Santullo
|
|
|
|
* This file is part of "dindexer".
|
|
|
|
*
|
|
|
|
* "dindexer" is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* "dindexer" is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dindexer-machinery/recorddata.hpp"
|
|
|
|
#include <vector>
|
|
|
|
#include <boost/iterator/iterator_facade.hpp>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#ifndef id040FEEC20F7B4F65A3EF67BA6460E737
|
|
|
|
#define id040FEEC20F7B4F65A3EF67BA6460E737
|
|
|
|
|
|
|
|
namespace mchlib {
|
|
|
|
class PathName;
|
2016-02-09 22:23:50 +00:00
|
|
|
class SetListingView;
|
2016-02-09 20:35:13 +00:00
|
|
|
|
|
|
|
namespace implem {
|
2016-02-12 18:55:32 +00:00
|
|
|
class DirIterator : public boost::iterator_facade<DirIterator, FileRecordData, boost::forward_traversal_tag> {
|
2016-02-09 22:23:50 +00:00
|
|
|
friend class mchlib::SetListingView;
|
2016-02-09 20:35:13 +00:00
|
|
|
friend class boost::iterator_core_access;
|
|
|
|
typedef boost::iterator_facade<DirIterator, FileRecordData, boost::random_access_traversal_tag> base_class;
|
|
|
|
typedef base_class::difference_type difference_type;
|
|
|
|
typedef base_class::reference reference;
|
|
|
|
public:
|
|
|
|
typedef std::vector<mchlib::FileRecordData>::const_iterator VecIterator;
|
|
|
|
|
|
|
|
DirIterator ( DirIterator&& parOther );
|
|
|
|
DirIterator ( VecIterator parBegin, VecIterator parEnd, std::unique_ptr<PathName>&& parBasePath );
|
|
|
|
~DirIterator ( void ) noexcept;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void increment ( void );
|
|
|
|
difference_type distance_to ( const DirIterator& parOther ) const;
|
|
|
|
bool equal ( const DirIterator& parOther ) const;
|
|
|
|
reference dereference ( void ) const;
|
|
|
|
bool is_end ( void ) const;
|
|
|
|
|
|
|
|
VecIterator m_current;
|
|
|
|
VecIterator m_end;
|
|
|
|
std::unique_ptr<PathName> m_base_path;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class SetListing {
|
2016-02-12 13:44:32 +00:00
|
|
|
friend class SetListingView;
|
2016-02-09 20:35:13 +00:00
|
|
|
public:
|
2016-02-09 22:23:50 +00:00
|
|
|
typedef std::vector<FileRecordData> ListType;
|
2016-02-09 20:35:13 +00:00
|
|
|
typedef implem::DirIterator const_iterator;
|
|
|
|
|
|
|
|
explicit SetListing ( ListType&& parList, bool parSort=true );
|
|
|
|
~SetListing ( void ) noexcept;
|
|
|
|
|
|
|
|
const_iterator begin ( void ) const;
|
|
|
|
const_iterator cbegin ( void ) const;
|
|
|
|
const_iterator end ( void ) const;
|
|
|
|
const_iterator cend ( void ) const;
|
|
|
|
|
2016-02-09 22:23:50 +00:00
|
|
|
//ListType descend_copy ( const const_iterator& parItem ) const;
|
2016-02-09 20:35:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
ListType m_list;
|
|
|
|
};
|
2016-02-09 22:23:50 +00:00
|
|
|
|
|
|
|
class SetListingView {
|
|
|
|
public:
|
|
|
|
typedef SetListing::const_iterator const_iterator;
|
|
|
|
typedef SetListing::ListType::const_iterator list_iterator;
|
|
|
|
|
|
|
|
explicit SetListingView ( const const_iterator& parIter );
|
2016-02-12 13:44:32 +00:00
|
|
|
explicit SetListingView ( const SetListing& parListing );
|
2016-02-09 22:23:50 +00:00
|
|
|
~SetListingView ( void ) noexcept = default;
|
|
|
|
|
|
|
|
const_iterator begin ( void ) const;
|
|
|
|
const_iterator cbegin ( void ) const;
|
|
|
|
const_iterator end ( void ) const;
|
|
|
|
const_iterator cend ( void ) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
list_iterator m_begin;
|
|
|
|
list_iterator m_end;
|
|
|
|
};
|
2016-02-09 20:35:13 +00:00
|
|
|
} //namespace mchlib
|
|
|
|
|
|
|
|
#endif
|