Formula Engine

formula_tokens_t ixion::parse_formula_string(iface::formula_model_access &cxt, const abs_address_t &pos, const formula_name_resolver &resolver, const char *p, size_t n)

Parse a raw formula expression string into formula tokens.

Return

formula tokens representing the parsed formula expression.

Parameters
  • cxt: model context.

  • pos: address of the cell that has the formula expression.

  • resolver: name resolver object used to resolve name tokens.

  • p: pointer to the first character of raw formula expression string.

  • n: size of the raw formula expression string.

std::string ixion::print_formula_tokens(const iface::formula_model_access &cxt, const abs_address_t &pos, const formula_name_resolver &resolver, const formula_tokens_t &tokens)

Convert formula tokens into a human-readable string representation.

Return

string representation of the formula tokens.

Parameters
  • cxt: model context.

  • pos: address of the cell that has the formula tokens.

  • resolver: name resolver object used to print name tokens.

  • tokens: formula tokens.

void ixion::register_formula_cell(iface::formula_model_access &cxt, const abs_address_t &pos, const formula_cell *cell = nullptr)

Regisiter a formula cell with cell dependency tracker.

Parameters
  • cxt: model context.

  • pos: address of the cell being registered. In case of grouped cells, the position must be that of teh top-left cell of that group.

  • cell: (optional) pointer to the formula cell object to register. You can skip this parameter, in which case the formula cell object will be fetched from the address of the cell. But passing a pointer will save the overhead of fetching.

void ixion::unregister_formula_cell(iface::formula_model_access &cxt, const abs_address_t &pos)

Unregister a formula cell with cell dependency tracker if a formula cell exists at specified cell address. If there is no existing cell at the specified address, or the cell is not a formula cell, this function is a no-op.

Parameters
  • cxt: model context.

  • pos: address of the cell being unregistered.

abs_address_set_t ixion::query_dirty_cells(iface::formula_model_access &cxt, const abs_address_set_t &modified_cells)

Get the positions of those formula cells that directly or indirectly depend on the specified source cells.

Return

collection of the positions of formula cells that directly or indirectly depend on at least one of the specified source cells.

Parameters
  • cxt: model context.

  • modified_cells: collection of the postiions of cells that have been modified.

std::vector<abs_range_t> ixion::query_and_sort_dirty_cells(iface::formula_model_access &cxt, const abs_range_set_t &modified_cells, const abs_range_set_t *dirty_formula_cells = nullptr)

Get a sequence of the positions of all formula cells that track at least one of the specified modified cells either directly or indirectly. Such formula cells are referred to as “dirty” formula cells. The sequence returned from this function is already sorted in topological order based on the dependency relationships between the affected formula cells. Note that if the model contains volatile formula cells, they will be included in the returned sequence each and every time.

Use ixion::query_dirty_cells instead if you don’t need the results to be sorted in order of dependency, to avoid the extra overhead incurred by the sorting.

Return

an sequence containing the positions of the formula cells that track at least one of the modified cells, as well as those formula cells that are already known to be dirty.

Parameters
  • cxt: model context.

  • modified_cells: a collection of non-formula cells whose values have been updated. You can specify one or more ranges of cells rather than individual cell positions.

  • dirty_formula_cells: (optional) a collection of formula cells that are already known to be dirty. These formula cells will be added to the list of the affected formula cells returned from this function. Note that even though this parameter is a set of cell ranges, regular formula cell positions must be given as single cell addresses. Only the positions of grouped formula cells must be given as ranges.

void ixion::calculate_sorted_cells(iface::formula_model_access &cxt, const std::vector<abs_range_t> &formula_cells, size_t thread_count)

Calculate all specified formula cells in the order they occur in the sequence.

Parameters
  • cxt: model context.

  • formula_cells: formula cells to be calculated. The cells will be calculated in the order they appear in the sequence. In a typical use case, this will be the returned value from {}. thread_count number of calculation threads to use. Note that passing 0 will make the process use the main thread only, while passing any number greater than 0 will make the process spawn specified number of calculation threads plus one additional thread to manage the calculation threads.