cell_access

Defined in header: <ixion/cell_access.hpp>

class cell_access

This class provides a read-only access to a single cell. It’s more efficient to use this class if you need to make multiple successive queries to the same cell.

Note that an instance of this class will get invalidated when the content of ixion::model_context is modified.

Public Functions

cell_access(cell_access &&other)

Move constructor. The moved-from instance no longer refers to a cell.

cell_access &operator=(cell_access &&other)

Move assignment. The moved-from instance no longer refers to a cell.

~cell_access()
cell_t get_type() const

Get the type of the cell. A formula cell is reported as a formula cell regardless of its result.

Returns:

Type of the cell.

cell_value_t get_value_type() const

Get the type of the value the cell holds. Unlike get_type(), a formula cell is classified by the type of its result, which may be an error.

Returns:

Type of the cell value.

const formula_cell *get_formula_cell() const

Get the formula cell.

Returns:

Pointer to the formula cell, or nullptr if the cell is not a formula cell.

formula_result get_formula_result() const

Get the cached result of the formula cell. For a grouped formula cell, the result is the single value assigned to the position of the cell within its group.

Note

A non-grouped formula cell whose result is a matrix gets the matrix back as is.

Throws:

general_error – If the cell is not a formula cell.

Returns:

Cached result of the formula cell.

double get_numeric_value() const

Get a numeric representation of the cell value. A boolean cell yields 1 or 0, and a string or empty cell yields 0. For a formula cell, this is the numeric value of its result.

Note

When the result is a matrix, the value of one element is returned: the element at the cell’s position within its group for a grouped formula cell, or the top-left element for a non-grouped formula cell.

Throws:

formula_error – If the cell is a formula cell whose result is an error or cannot be converted to a number.

Returns:

Numeric representation of the cell value.

bool get_boolean_value() const

Get a boolean representation of the cell value. A numeric value, or the numeric result of a formula cell, is true when it is not zero. A string or empty cell is false.

Throws:

formula_error – If the cell is a formula cell whose result is an error or cannot be converted to a number.

Returns:

Boolean representation of the cell value.

std::string_view get_string_value() const

Get the string value of the cell. A string cell yields its text whether the string is stored inline or by its identifier in the indexed string pool, and a formula cell yields its string result.

Note

When the result is a matrix, the value of one element is returned: the element at the cell’s position within its group for a grouped formula cell, or the top-left element for a non-grouped formula cell.

Throws:

formula_error – If the cell is a formula cell whose result is an error or not a string.

Returns:

String value of the cell, or an empty view if the cell is neither a string cell nor a formula cell.

string_id_t get_string_identifier() const

Get the string identifier of the cell. Only a cell whose string was set by its identifier, via the string_id_t overload of model_context::set_string_cell(), has one.

Returns:

String identifier of the cell, or empty_string_id.

formula_error_t get_error_value() const

Get the error value of the cell. Only a formula cell whose result is an error has one.

Returns:

Error value of the cell, or formula_error_t::no_error if the cell is not a formula cell or its result is not an error.