27#ifndef CELLITERATORS_H
28#define CELLITERATORS_H
36 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
40 using iterator_category = std::forward_iterator_tag;
42 using difference_type = std::ptrdiff_t;
54 return operator++(), ret;
60 const auto *
const prev = m_ptr;
62 wxASSERT(prev != m_ptr);
67 return m_ptr == o.m_ptr;
70 return m_ptr != o.m_ptr;
72 constexpr operator bool()
const {
return m_ptr; }
73 constexpr operator Cell *()
const {
return m_ptr; }
74 constexpr Cell *operator->()
const {
return m_ptr; }
78 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
86 static constexpr iterator end() {
return {}; }
91template <
typename Cell>
93 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
97 using iterator_category = std::forward_iterator_tag;
99 using difference_type = std::ptrdiff_t;
110 return operator++(), ret;
117 const auto *
const prev = m_ptr;
119 wxASSERT(prev != m_ptr);
124 {
return m_ptr == o.m_ptr; }
126 {
return m_ptr != o.m_ptr; }
127 constexpr operator bool()
const {
return m_ptr; }
128 constexpr operator Cell*()
const {
return m_ptr; }
129 constexpr Cell *operator->()
const {
return m_ptr; }
134 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
142 static constexpr iterator end() {
return {}; }
152 enum class Advance { Always, OnlyIfNull };
153 const Cell *m_parentCell = {};
154 Cell *m_innerCell = {};
156 size_t m_endIndex = 0;
158 static size_t GetInnerCellCount(
const Cell *cell);
159 static Cell *GetInnerCell(
const Cell *cell,
size_t index);
161 using iterator_category = std::forward_iterator_tag;
163 using difference_type = std::ptrdiff_t;
169 m_parentCell(parentCell),
170 m_endIndex(parentCell ? GetInnerCellCount(parentCell) : 0)
172 FindFirstInnerCell();
179 return operator++(), ret;
184 AdvanceLoop(Advance::Always);
188 {
return m_innerCell == o.m_innerCell; }
190 {
return m_innerCell != o.m_innerCell; }
191 operator bool()
const {
return m_innerCell; }
192 operator Cell*()
const {
return m_innerCell; }
193 Cell *operator->()
const {
return m_innerCell; }
196 void FindFirstInnerCell();
197 void AdvanceLoop(Advance mode);
200inline void InnerCellIterator::FindFirstInnerCell()
204 m_innerCell = GetInnerCell(m_parentCell, 0);
205 AdvanceLoop(Advance::OnlyIfNull);
209inline void InnerCellIterator::AdvanceLoop(Advance mode)
211 const Cell *prev = m_innerCell;
212 if (mode == Advance::OnlyIfNull && prev)
217 if (m_index == m_endIndex)
219 m_innerCell =
nullptr;
222 m_innerCell = GetInnerCell(m_parentCell, m_index);
223 wxASSERT(!prev || prev != m_innerCell);
236 iterator begin()
const {
return m_iter; }
237 static iterator end() {
return {}; }
Definition: CellIterators.h:133
Definition: CellIterators.h:92
Definition: CellIterators.h:77
Definition: CellIterators.h:35
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:142
Cell * GetNextToDraw() const
Get the next cell that needs to be drawn.
Definition: Cell.h:741
Cell * GetNext() const
Get the next cell in the list.
Definition: Cell.h:734
Definition: CellIterators.h:229
Iterates the inner cells of a cell.
Definition: CellIterators.h:151