model_cell_range

Defined in header: <ixion/model_cell_range.hpp>

class model_cell_range

STL-compliant range over the cells of a sheet (or sub-range). Returned by model_context::iterate_cells. Supports range-for and STL/range algorithms via its nested const_iterator.

The caller has to ensure that the model content does not change for the duration of the iteration.

Public Functions

model_cell_range()

Construct an empty range.

model_cell_range(const model_cell_range&) = delete
model_cell_range(model_cell_range &&other)

Move constructor.

~model_cell_range()
model_cell_range &operator=(const model_cell_range&) = delete
model_cell_range &operator=(model_cell_range &&other)

Move assignment.

const_iterator begin() const

Get an iterator to the first cell of the range.

sentinel end() const

Get the sentinel marking the end of the range.

const_iterator cbegin() const

Get an iterator to the first cell of the range.

sentinel cend() const

Get the sentinel marking the end of the range.

Friends

friend class detail::model_context_impl
struct cell

One cell yielded by the iteration: its position within the sheet, its type and its value. Empty cells are yielded too, with the empty type and no meaningful value.

Public Types

using value_type = std::variant<bool, double, std::string_view, const formula_cell*>

Type of the stored value. A formula cell is represented by a pointer to its formula_cell instance, which remains valid as long as the cell stays in the model.

Public Functions

cell()

Construct an empty cell at the top-left position.

cell(row_t _row, col_t _col)

Construct an empty cell.

cell(row_t _row, col_t _col, bool _b)

Construct a boolean cell.

cell(row_t _row, col_t _col, const char *_s)

Construct a string cell from a null-terminated string.

cell(row_t _row, col_t _col, std::string_view _s)

Construct a string cell.

cell(row_t _row, col_t _col, double _v)

Construct a numeric cell.

cell(row_t _row, col_t _col, const formula_cell *_f)

Construct a formula cell.

bool operator==(const cell &other) const

Compare the position, type and value of two cells.

Public Members

row_t row

0-based row position of the cell.

col_t col

0-based column position of the cell.

cell_t type

Type of the cell.

value_type value

Value of the cell.

class const_iterator

Move-only input iterator over the cells of a model_cell_range. The end of the range is marked by a sentinel rather than another iterator.

Public Types

using iterator_category = std::input_iterator_tag

Iterator category, which is input iterator.

using value_type = cell

Type of the values the iterator yields.

using difference_type = std::ptrdiff_t

Type of the difference between two iterators.

using reference = const cell&

Reference type of the yielded values.

using pointer = const cell*

Pointer type of the yielded values.

Public Functions

const_iterator()

Construct an iterator at the end position.

const_iterator(const_iterator &&other)

Move constructor.

const_iterator &operator=(const_iterator &&other)

Move assignment.

~const_iterator()
const_iterator &operator++()

Advance to the next cell.

void operator++(int)

Advance to the next cell. Nothing is returned, as the iterator is move-only.

reference operator*() const

Get the current cell.

pointer operator->() const

Get a pointer to the current cell.

bool operator==(const const_iterator &r) const

Compare the positions of two iterators.

bool operator==(sentinel) const

Check whether the iterator has reached the end of the range.

struct sentinel

End sentinel to allow const_iterator to remain move-only while still satisfying std::sentinel_for etc.