Formula Cell

class ixion::formula_cell

Public Functions

formula_cell(const formula_cell&) = delete
formula_cell &operator=(formula_cell) = delete
formula_cell()
formula_cell(const formula_tokens_store_ptr_t &tokens)
formula_cell(row_t group_row, col_t group_col, const calc_status_ptr_t &cs, const formula_tokens_store_ptr_t &tokens)
~formula_cell()
const formula_tokens_store_ptr_t &get_tokens() const
void set_tokens(const formula_tokens_store_ptr_t &tokens)
double get_value(formula_result_wait_policy_t policy) const
const std::string *get_string(formula_result_wait_policy_t policy) const
void interpret(iface::formula_model_access &context, const abs_address_t &pos)
void check_circular(const iface::formula_model_access &cxt, const abs_address_t &pos)

Determine if this cell contains circular reference by walking through all its reference tokens.

void reset()

Reset cell’s internal state.

std::vector<const formula_token*> get_ref_tokens(const iface::formula_model_access &cxt, const abs_address_t &pos) const

Get a series of all reference tokens included in the formula expression stored in this cell.

Parameters:
  • cxt – model context instance.

  • pos – position of the cell.

Returns:

an array of reference formula tokens. Each element is a pointer to the actual token instance stored in the cell object. Be aware that the pointer is valid only as long as the actual token instance is alive.

const formula_result &get_raw_result_cache(formula_result_wait_policy_t policy) const
formula_result get_result_cache(formula_result_wait_policy_t policy) const

Get the cached result as a single cell. For a non-grouped formula cell, it should be identical to the value from the get_raw_result_cache call. For a grouped formula cell, you’ll get a single value assigned to the position of the cell in case the original result is a matrix value.

Returns:

formula result.

void set_result_cache(formula_result result)

Set a cached result to this formula cell instance.

Parameters:

result – cached result.

formula_group_t get_group_properties() const
abs_address_t get_parent_position(const abs_address_t &pos) const

Get the absolute parent position of a grouped formula cell. If the cell is not grouped, it simply returns the original position passed to this method.

Parameters:

pos – original position from which to calculate the parent position.

Returns:

parent position of the grouped formula cell.

class ixion::formula_result

Store formula result which may be either numeric, textural, or error. In case the result is textural, it owns the instance of the string.

Public Types

enum result_type

Values:

enumerator value
enumerator string
enumerator error
enumerator matrix

Public Functions

formula_result()
formula_result(const formula_result &r)
formula_result(formula_result &&r)
formula_result(double v)
formula_result(std::string str)
formula_result(formula_error_t e)
formula_result(matrix mtx)
~formula_result()
void reset()
void set_value(double v)
void set_string_value(std::string str)
void set_error(formula_error_t e)
void set_matrix(matrix mtx)
double get_value() const

Get a numeric result value. The caller must make sure the result is of numeric type, else the behavior is undefined.

Returns:

numeric result value.

const std::string &get_string() const

Get a string value for textural result. The caller must make sure the result is of textural type, else the behavior is undefined.

Returns:

string value.

formula_error_t get_error() const

Get an error value of the result. The caller must make sure that the result is of error type, else the behavior is undefined.

See also

ixion::get_formula_error_name

Returns:

enum value representing the error.

const matrix &get_matrix() const

Get a matrix value of the result. The caller must make sure that the result is of matrix type, else the behavior is undefined.

Returns:

matrix result value.

matrix &get_matrix()

Get a matrix value of the result. The caller must make sure that the result is of matrix type, else the behavior is undefined.

Returns:

matrix result value.

result_type get_type() const

Get the type of result.

Returns:

enum value representing the result type.

std::string str(const iface::formula_model_access &cxt) const

Get a string representation of the result value no matter what the result type is.

Parameters:

cxt – model context object.

Returns:

string representation of the result value.

void parse(iface::formula_model_access &cxt, const char *p, size_t n)

Parse a textural representation of a formula result, and set result value of appropriate type.

formula_result &operator=(formula_result r)
bool operator==(const formula_result &r) const
bool operator!=(const formula_result &r) const