##// END OF EJS Templates
Adds operators for DataSourceItem
Alexandre Leroux -
r348:ea1f3730c1b2
parent child
Show More
@@ -83,6 +83,9 public:
83
83
84 DataSourceItemType type() const noexcept;
84 DataSourceItemType type() const noexcept;
85
85
86 bool operator==(const DataSourceItem &other);
87 bool operator!=(const DataSourceItem &other);
88
86 private:
89 private:
87 class DataSourceItemPrivate;
90 class DataSourceItemPrivate;
88 spimpl::unique_impl_ptr<DataSourceItemPrivate> impl;
91 spimpl::unique_impl_ptr<DataSourceItemPrivate> impl;
@@ -117,3 +117,24 DataSourceItemType DataSourceItem::type() const noexcept
117 {
117 {
118 return impl->m_Type;
118 return impl->m_Type;
119 }
119 }
120
121 bool DataSourceItem::operator==(const DataSourceItem &other)
122 {
123 // Compares items' attributes
124 if (std::tie(impl->m_Type, impl->m_Data) == std::tie(other.impl->m_Type, other.impl->m_Data)) {
125 // Compares contents of items' children
126 return std::equal(std::cbegin(impl->m_Children), std::cend(impl->m_Children),
127 std::cbegin(other.impl->m_Children),
128 [](const auto &itemChild, const auto &otherChild) {
129 return *itemChild == *otherChild;
130 });
131 }
132 else {
133 return false;
134 }
135 }
136
137 bool DataSourceItem::operator!=(const DataSourceItem &other)
138 {
139 return !(*this == other);
140 }
General Comments 0
You need to be logged in to leave comments. Login now