27#ifndef CELLITERATORS_H
28#define CELLITERATORS_H
35 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
47 return operator++(), ret;
53 const auto *
const prev = m_ptr;
55 wxASSERT(prev != m_ptr);
60 return m_ptr == o.m_ptr;
63 return m_ptr != o.m_ptr;
65 constexpr operator bool()
const {
return m_ptr; }
66 constexpr operator Cell *()
const {
return m_ptr; }
67 constexpr Cell *operator->()
const {
return m_ptr; }
71 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
79 static constexpr iterator end() {
return {}; }
84template <
typename Cell>
86 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
97 return operator++(), ret;
104 const auto *
const prev = m_ptr;
106 wxASSERT(prev != m_ptr);
111 {
return m_ptr == o.m_ptr; }
113 {
return m_ptr != o.m_ptr; }
114 constexpr operator bool()
const {
return m_ptr; }
115 constexpr operator Cell*()
const {
return m_ptr; }
116 constexpr Cell *operator->()
const {
return m_ptr; }
121 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
129 static constexpr iterator end() {
return {}; }
139 enum class Advance { Always, OnlyIfNull };
140 const Cell *m_parentCell = {};
141 Cell *m_innerCell = {};
143 size_t m_endIndex = 0;
145 static size_t GetInnerCellCount(
const Cell *cell);
146 static Cell *GetInnerCell(
const Cell *cell,
size_t index);
150 m_parentCell(parentCell),
151 m_endIndex(parentCell ? GetInnerCellCount(parentCell) : 0)
153 FindFirstInnerCell();
160 return operator++(), ret;
165 AdvanceLoop(Advance::Always);
169 {
return m_innerCell == o.m_innerCell; }
171 {
return m_innerCell != o.m_innerCell; }
172 operator bool()
const {
return m_innerCell; }
173 operator Cell*()
const {
return m_innerCell; }
174 Cell *operator->()
const {
return m_innerCell; }
177 void FindFirstInnerCell();
178 void AdvanceLoop(Advance mode);
181inline void InnerCellIterator::FindFirstInnerCell()
185 m_innerCell = GetInnerCell(m_parentCell, 0);
186 AdvanceLoop(Advance::OnlyIfNull);
190inline void InnerCellIterator::AdvanceLoop(Advance mode)
192 const Cell *prev = m_innerCell;
193 if (mode == Advance::OnlyIfNull && prev)
198 if (m_index == m_endIndex)
200 m_innerCell =
nullptr;
203 m_innerCell = GetInnerCell(m_parentCell, m_index);
204 wxASSERT(!prev || prev != m_innerCell);
217 iterator begin()
const {
return m_iter; }
218 static iterator end() {
return {}; }
Definition: CellIterators.h:120
Definition: CellIterators.h:85
Definition: CellIterators.h:70
Definition: CellIterators.h:34
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:701
Cell * GetNext() const
Get the next cell in the list.
Definition: Cell.h:694
Definition: CellIterators.h:210
Iterates the inner cells of a cell.
Definition: CellIterators.h:138