Model Context

class

This class stores all data relevant to current session. You can think of this like a document model for each formula calculation run. Note that only those methods called from the formula interpreter are specified in the interface; this explains why accessors for the most part only have the ‘get’ method not paired with its ‘set’ counterpart.

Inherits from ixion::iface::formula_model_access

Public Types

typedef

Public Functions

ixion::model_context::model_context()
virtual ixion::model_context::~model_context()
virtual const config &ixion::model_context::get_config() const
virtual cell_listener_tracker &ixion::model_context::get_cell_listener_tracker()
virtual bool ixion::model_context::is_empty(const abs_address_t &addr) const
virtual celltype_t ixion::model_context::get_celltype(const abs_address_t &addr) const
virtual double ixion::model_context::get_numeric_value(const abs_address_t &addr) const

Get a numeric representation of the cell value at specified position. If the cell at the specified position is a formula cell and its result has not yet been computed, it will block until the result becomes available. Call this only during formula (re-)calculation.

Return
numeric representation of the cell value.
Parameters
  • addr: position of the cell.

virtual string_id_t ixion::model_context::get_string_identifier(const abs_address_t &addr) const
virtual string_id_t ixion::model_context::get_string_identifier(const char *p, size_t n) const
virtual const formula_cell *ixion::model_context::get_formula_cell(const abs_address_t &addr) const
virtual formula_cell *ixion::model_context::get_formula_cell(const abs_address_t &addr)
virtual const formula_cell *ixion::model_context::get_named_expression(const std::string &name) const
virtual const std::string *ixion::model_context::get_named_expression_name(const formula_cell *expr) const
virtual double ixion::model_context::count_range(const abs_range_t &range, const values_t &values_type) const
virtual matrix ixion::model_context::get_range_value(const abs_range_t &range) const

Obtain range value in matrix form. Multi-sheet ranges are not supported. If the specified range consists of multiple sheets, it throws an exception.

Return
range value represented as matrix.
Parameters
  • range: absolute, single-sheet range address. Multi-sheet ranges are not allowed.

virtual std::unique_ptr<iface::session_handler> ixion::model_context::create_session_handler()

Session handler instance receives various events from the formula interpretation run, in order to respond to those events. This is optional; the model context implementation is not required to provide a handler.

Return
a new session handler instance. It may be nullptr.

virtual iface::table_handler *ixion::model_context::get_table_handler()

Table interface provides access to all table ranges stored in the document model. A table is a 2-dimensional range of cells that include named columns. It is used when resolving a table reference that refers to a cell or a range of cells by the table name and/or column name.

Return
non-NULL pointer to the table storage inside the model, or NULL if no table is present or supported by the model implementation.

virtual const iface::table_handler *ixion::model_context::get_table_handler() const
virtual const formula_tokens_t *ixion::model_context::get_formula_tokens(sheet_t sheet, size_t identifier) const
virtual const formula_tokens_t *ixion::model_context::get_shared_formula_tokens(sheet_t sheet, size_t identifier) const
virtual abs_range_t ixion::model_context::get_shared_formula_range(sheet_t sheet, size_t identifier) const
virtual string_id_t ixion::model_context::append_string(const char *p, size_t n)
virtual string_id_t ixion::model_context::add_string(const char *p, size_t n)
virtual const std::string *ixion::model_context::get_string(string_id_t identifier) const
virtual sheet_t ixion::model_context::get_sheet_index(const char *p, size_t n) const

Get the index of sheet from sheet name.

Return
sheet index
Parameters
  • p: pointer to the first character of the sheet name string.
  • n: length of the sheet name string.

virtual std::string ixion::model_context::get_sheet_name(sheet_t sheet) const
double ixion::model_context::get_numeric_value_nowait(const abs_address_t &addr) const
string_id_t ixion::model_context::get_string_identifier_nowait(const abs_address_t &addr) const
size_t ixion::model_context::add_formula_tokens(sheet_t sheet, formula_tokens_t *p)
void ixion::model_context::set_shared_formula_range(sheet_t sheet, size_t identifier, const abs_range_t &range)
size_t ixion::model_context::set_formula_tokens_shared(sheet_t sheet, size_t identifier)
void ixion::model_context::remove_formula_tokens(sheet_t sheet, size_t identifier)
void ixion::model_context::set_shared_formula(const abs_address_t &addr, size_t si, const char *p_formula, size_t n_formula, const char *p_range, size_t n_range, const formula_name_resolver &resolver)
void ixion::model_context::set_shared_formula(const abs_address_t &addr, size_t si, const char *p_formula, size_t n_formula, const formula_name_resolver &resolver)
void ixion::model_context::erase_cell(const abs_address_t &addr)
void ixion::model_context::set_numeric_cell(const abs_address_t &addr, double val)
void ixion::model_context::set_boolean_cell(const abs_address_t &adr, bool val)
void ixion::model_context::set_string_cell(const abs_address_t &addr, const char *p, size_t n)
void ixion::model_context::set_string_cell(const abs_address_t &addr, string_id_t identifier)
void ixion::model_context::set_formula_cell(const abs_address_t &addr, const char *p, size_t n, const formula_name_resolver &resolver)
void ixion::model_context::set_formula_cell(const abs_address_t &addr, size_t identifier, bool shared)
abs_range_t ixion::model_context::get_data_range(sheet_t sheet) const
void ixion::model_context::set_named_expression(const char *p, size_t n, formula_cell *cell)
formula_cell *ixion::model_context::get_named_expression(const std::string &name)
sheet_t ixion::model_context::append_sheet(const char *p, size_t n, row_t row_size, col_t col_size)

Append a new sheet to the model. The caller must ensure that the name of the new sheet is unique within the model context. When the name being used for the new sheet already exists, it throws a model_context_error exception.

Return
sheet index of the inserted sheet.
Parameters
  • p: pointer to the char array storing the name of the inserted sheet.
  • n: size of the sheet name char array.
  • row_size: number of rows in the inserted sheet.
  • col_size: number of columns in the inserted sheet.

void ixion::model_context::set_session_handler_factory(std::unique_ptr<session_handler_factory> &&factory)
void ixion::model_context::set_table_handler(iface::table_handler *handler)
size_t ixion::model_context::get_string_count() const
void ixion::model_context::dump_strings() const
const column_store_t *ixion::model_context::get_column(sheet_t sheet, col_t col) const

Get column storage.

Return
const pointer to column storage, or NULL in case sheet index or column index is out of bound.
Parameters
  • sheet: sheet index.
  • col: column index.

const column_stores_t *ixion::model_context::get_columns(sheet_t sheet) const

Get an array of column stores for the entire sheet.

Return
const pointer to an array of column stores, or nullptr in case the sheet index is out of bound.
Parameters
  • sheet: sheet index.

dirty_formula_cells_t ixion::model_context::get_all_formula_cells() const
class

Public Functions

virtual std::unique_ptr<iface::session_handler> ixion::model_context::session_handler_factory::create()
struct

Public Functions

ixion::model_context::shared_tokens::shared_tokens()
ixion::model_context::shared_tokens::shared_tokens(formula_tokens_t *tokens)
ixion::model_context::shared_tokens::shared_tokens(const shared_tokens &r)
bool ixion::model_context::shared_tokens::operator==(const shared_tokens &r) const

Public Members

formula_tokens_t *ixion::model_context::shared_tokens::tokens
abs_range_t ixion::model_context::shared_tokens::range