mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-02-19 12:04:54 +00:00
Add SetListingView.
I'm having linker errors in gtest, pushing to see if this also happens on the build server.
This commit is contained in:
parent
346946340d
commit
ada0f1df50
4 changed files with 52 additions and 32 deletions
|
@ -25,9 +25,11 @@
|
|||
|
||||
namespace mchlib {
|
||||
class PathName;
|
||||
class SetListingView;
|
||||
|
||||
namespace implem {
|
||||
class DirIterator : public boost::iterator_facade<DirIterator, FileRecordData, boost::random_access_traversal_tag> {
|
||||
friend class mchlib::SetListingView;
|
||||
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;
|
||||
|
@ -66,28 +68,9 @@ namespace mchlib {
|
|||
};
|
||||
};
|
||||
|
||||
//class SetListingView {
|
||||
//public:
|
||||
// typedef DirIterator const_iterator;
|
||||
|
||||
// SetListingView ( SetListing::const_iterator parBeg, SetListing::const_iterator parVeryEnd );
|
||||
// ~SetListingView ( void ) noexcept = default;
|
||||
|
||||
// const_iterator begin ( void ) const;
|
||||
// const_iterator cbegin ( void ) const;
|
||||
// const_iterator end ( void ) const;
|
||||
// const_iterator cend ( void ) const;
|
||||
|
||||
// SetListingView
|
||||
|
||||
//private:
|
||||
// const SetListing::const_iterator m_begin;
|
||||
// const SetListing::const_iterator m_end;
|
||||
//};
|
||||
|
||||
class SetListing {
|
||||
typedef std::vector<FileRecordData> ListType;
|
||||
public:
|
||||
typedef std::vector<FileRecordData> ListType;
|
||||
typedef implem::DirIterator const_iterator;
|
||||
|
||||
explicit SetListing ( ListType&& parList, bool parSort=true );
|
||||
|
@ -98,11 +81,29 @@ namespace mchlib {
|
|||
const_iterator end ( void ) const;
|
||||
const_iterator cend ( void ) const;
|
||||
|
||||
ListType descend_copy ( const const_iterator& parItem ) const;
|
||||
//ListType descend_copy ( const const_iterator& parItem ) const;
|
||||
|
||||
private:
|
||||
ListType m_list;
|
||||
};
|
||||
|
||||
class SetListingView {
|
||||
public:
|
||||
typedef SetListing::const_iterator const_iterator;
|
||||
typedef SetListing::ListType::const_iterator list_iterator;
|
||||
|
||||
explicit SetListingView ( const const_iterator& parIter );
|
||||
~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;
|
||||
};
|
||||
} //namespace mchlib
|
||||
|
||||
#endif
|
||||
|
|
|
@ -144,6 +144,10 @@ namespace mchlib {
|
|||
}
|
||||
|
||||
auto SetListing::begin() const -> const_iterator {
|
||||
return cbegin();
|
||||
}
|
||||
|
||||
auto SetListing::cbegin() const -> const_iterator {
|
||||
std::unique_ptr<PathName> base_path;
|
||||
if (m_list.begin() != m_list.end()) {
|
||||
base_path.reset(new PathName(m_list.front().abs_path));
|
||||
|
@ -151,15 +155,23 @@ namespace mchlib {
|
|||
return const_iterator(m_list.begin(), m_list.end(), std::move(base_path));
|
||||
}
|
||||
|
||||
//auto SetListing::cbegin() const -> const_iterator {
|
||||
//}
|
||||
|
||||
//auto SetListing::end() const -> const_iterator {
|
||||
//}
|
||||
|
||||
//auto SetListing::cend() const -> const_iterator {
|
||||
//}
|
||||
|
||||
//ListType descend_copy (const const_iterator& parItem) const {
|
||||
//}
|
||||
SetListingView::SetListingView (const const_iterator& parIter) :
|
||||
m_begin(parIter.m_current),
|
||||
m_end(parIter.m_end)
|
||||
{
|
||||
}
|
||||
|
||||
auto SetListingView::cbegin() const -> const_iterator {
|
||||
std::unique_ptr<PathName> base_path;
|
||||
if (m_begin != m_end) {
|
||||
base_path.reset(new PathName(m_begin->abs_path));
|
||||
}
|
||||
return const_iterator(m_begin, m_end, std::move(base_path));
|
||||
}
|
||||
} //namespace mchlib
|
||||
|
|
|
@ -9,9 +9,9 @@ target_include_directories(${PROJECT_NAME} SYSTEM
|
|||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE gtest
|
||||
PRIVATE gtest_main
|
||||
PRIVATE ${bare_name}-if
|
||||
PRIVATE ${bare_name}-common
|
||||
PRIVATE ${bare_name}-machinery
|
||||
PRIVATE gtest
|
||||
PRIVATE gtest_main
|
||||
)
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
//TEST_F for class
|
||||
TEST(machinery, diriterator) {
|
||||
using mchlib::SetListing;
|
||||
using mchlib::SetListingView;
|
||||
using mchlib::FileRecordData;
|
||||
|
||||
FileRecordData test_data_arr[] = {
|
||||
|
@ -911,9 +912,15 @@ TEST(machinery, diriterator) {
|
|||
SetListing lst(std::move(test_data));
|
||||
|
||||
auto i = lst.begin();
|
||||
std::cout << i->abs_path << '\n';
|
||||
EXPECT_EQ("", i->abs_path);
|
||||
|
||||
++i;
|
||||
std::cout << i->abs_path << '\n';
|
||||
++i;
|
||||
std::cout << i->abs_path << '\n';
|
||||
EXPECT_EQ("BestAndBest", i->abs_path);
|
||||
|
||||
auto view = SetListingView(i);
|
||||
auto i2 = view.cbegin();
|
||||
EXPECT_EQ("BestAndBest/CD1", i2->abs_path);
|
||||
|
||||
++i2;
|
||||
EXPECT_EQ("BestAndBest/CD2", i2->abs_path);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue