mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-05 14:34:13 +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 {
|
namespace mchlib {
|
||||||
class PathName;
|
class PathName;
|
||||||
|
class SetListingView;
|
||||||
|
|
||||||
namespace implem {
|
namespace implem {
|
||||||
class DirIterator : public boost::iterator_facade<DirIterator, FileRecordData, boost::random_access_traversal_tag> {
|
class DirIterator : public boost::iterator_facade<DirIterator, FileRecordData, boost::random_access_traversal_tag> {
|
||||||
|
friend class mchlib::SetListingView;
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
typedef boost::iterator_facade<DirIterator, FileRecordData, boost::random_access_traversal_tag> base_class;
|
typedef boost::iterator_facade<DirIterator, FileRecordData, boost::random_access_traversal_tag> base_class;
|
||||||
typedef base_class::difference_type difference_type;
|
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 {
|
class SetListing {
|
||||||
typedef std::vector<FileRecordData> ListType;
|
|
||||||
public:
|
public:
|
||||||
|
typedef std::vector<FileRecordData> ListType;
|
||||||
typedef implem::DirIterator const_iterator;
|
typedef implem::DirIterator const_iterator;
|
||||||
|
|
||||||
explicit SetListing ( ListType&& parList, bool parSort=true );
|
explicit SetListing ( ListType&& parList, bool parSort=true );
|
||||||
|
@ -98,11 +81,29 @@ namespace mchlib {
|
||||||
const_iterator end ( void ) const;
|
const_iterator end ( void ) const;
|
||||||
const_iterator cend ( void ) const;
|
const_iterator cend ( void ) const;
|
||||||
|
|
||||||
ListType descend_copy ( const const_iterator& parItem ) const;
|
//ListType descend_copy ( const const_iterator& parItem ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ListType m_list;
|
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
|
} //namespace mchlib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -144,6 +144,10 @@ namespace mchlib {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto SetListing::begin() const -> const_iterator {
|
auto SetListing::begin() const -> const_iterator {
|
||||||
|
return cbegin();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto SetListing::cbegin() const -> const_iterator {
|
||||||
std::unique_ptr<PathName> base_path;
|
std::unique_ptr<PathName> base_path;
|
||||||
if (m_list.begin() != m_list.end()) {
|
if (m_list.begin() != m_list.end()) {
|
||||||
base_path.reset(new PathName(m_list.front().abs_path));
|
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));
|
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::end() const -> const_iterator {
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//auto SetListing::cend() 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
|
} //namespace mchlib
|
||||||
|
|
|
@ -9,9 +9,9 @@ target_include_directories(${PROJECT_NAME} SYSTEM
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
PRIVATE gtest
|
|
||||||
PRIVATE gtest_main
|
|
||||||
PRIVATE ${bare_name}-if
|
PRIVATE ${bare_name}-if
|
||||||
PRIVATE ${bare_name}-common
|
PRIVATE ${bare_name}-common
|
||||||
PRIVATE ${bare_name}-machinery
|
PRIVATE ${bare_name}-machinery
|
||||||
|
PRIVATE gtest
|
||||||
|
PRIVATE gtest_main
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
//TEST_F for class
|
//TEST_F for class
|
||||||
TEST(machinery, diriterator) {
|
TEST(machinery, diriterator) {
|
||||||
using mchlib::SetListing;
|
using mchlib::SetListing;
|
||||||
|
using mchlib::SetListingView;
|
||||||
using mchlib::FileRecordData;
|
using mchlib::FileRecordData;
|
||||||
|
|
||||||
FileRecordData test_data_arr[] = {
|
FileRecordData test_data_arr[] = {
|
||||||
|
@ -911,9 +912,15 @@ TEST(machinery, diriterator) {
|
||||||
SetListing lst(std::move(test_data));
|
SetListing lst(std::move(test_data));
|
||||||
|
|
||||||
auto i = lst.begin();
|
auto i = lst.begin();
|
||||||
std::cout << i->abs_path << '\n';
|
EXPECT_EQ("", i->abs_path);
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
std::cout << i->abs_path << '\n';
|
EXPECT_EQ("BestAndBest", i->abs_path);
|
||||||
++i;
|
|
||||||
std::cout << i->abs_path << '\n';
|
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
Add a link
Reference in a new issue