Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Calculator Class Reference

The almighty calculator class. More...

#include <Calculator.h>

List of all members.

Public Member Functions

Constructor
Functions for calculating expressions.
bool calculate (MathStructure *mstruct, string str, int msecs, const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL, MathStructure *to_struct=NULL, bool make_to_division=true)
MathStructure calculate (string str, const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL, MathStructure *to_struct=NULL, bool make_to_division=true)
string printMathStructureTimeOut (const MathStructure &mstruct, int msecs=100000, const PrintOptions &op=default_print_options)
int testCondition (string expression)
Functions for handling of threaded calculations
void abort ()
void abort_this ()
bool busy ()
void saveState ()
void restoreState ()
void clearBuffers ()
void terminateThreads ()
Functions for manipulation of the RPN stack.
bool calculateRPNRegister (size_t index, int msecs, const EvaluationOptions &eo=default_evaluation_options)
bool calculateRPN (MathOperation op, int msecs, const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL)
bool calculateRPN (MathFunction *f, int msecs, const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL)
bool calculateRPNBitwiseNot (int msecs, const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL)
bool calculateRPNLogicalNot (int msecs, const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL)
MathStructurecalculateRPN (MathOperation op, const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL)
MathStructurecalculateRPN (MathFunction *f, const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL)
MathStructurecalculateRPNBitwiseNot (const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL)
MathStructurecalculateRPNLogicalNot (const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL)
bool RPNStackEnter (MathStructure *mstruct, int msecs, const EvaluationOptions &eo=default_evaluation_options)
bool RPNStackEnter (string str, int msecs, const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL, MathStructure *to_struct=NULL, bool make_to_division=true)
void RPNStackEnter (MathStructure *mstruct, bool eval=false, const EvaluationOptions &eo=default_evaluation_options)
void RPNStackEnter (string str, const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL, MathStructure *to_struct=NULL, bool make_to_division=true)
bool setRPNRegister (size_t index, MathStructure *mstruct, int msecs, const EvaluationOptions &eo=default_evaluation_options)
bool setRPNRegister (size_t index, string str, int msecs, const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL, MathStructure *to_struct=NULL, bool make_to_division=true)
void setRPNRegister (size_t index, MathStructure *mstruct, bool eval=false, const EvaluationOptions &eo=default_evaluation_options)
void setRPNRegister (size_t index, string str, const EvaluationOptions &eo=default_evaluation_options, MathStructure *parsed_struct=NULL, MathStructure *to_struct=NULL, bool make_to_division=true)
void deleteRPNRegister (size_t index)
MathStructuregetRPNRegister (size_t index=1) const
size_t RPNStackSize () const
void clearRPNStack ()
void moveRPNRegister (size_t old_index, size_t new_index)
void moveRPNRegisterUp (size_t index)
void moveRPNRegisterDown (size_t index)
Functions for expression parsing.
string localizeExpression (string str) const
string unlocalizeExpression (string str, const ParseOptions &po=default_parse_options) const
bool separateToExpression (string &str, string &to_str, const EvaluationOptions &eo) const
void parseSigns (string &str) const
MathStructure parse (string str, const ParseOptions &po=default_parse_options)
void parse (MathStructure *mstruct, string str, const ParseOptions &po=default_parse_options)
bool parseNumber (MathStructure *mstruct, string str, const ParseOptions &po=default_parse_options)
bool parseOperators (MathStructure *mstruct, string str, const ParseOptions &po=default_parse_options)
bool parseAdd (string &str, MathStructure *mstruct, const ParseOptions &po, MathOperation s)
bool parseAdd (string &str, MathStructure *mstruct, const ParseOptions &po)
Functions converting epxressions between units.
MathStructure convert (const MathStructure &mstruct, string composite_, const EvaluationOptions &eo=default_evaluation_options)
MathStructure convert (const MathStructure &mstruct, Unit *to_unit, const EvaluationOptions &eo=default_evaluation_options, bool always_convert=true)
MathStructure convert (double value, Unit *from_unit, Unit *to_unit, const EvaluationOptions &eo=default_evaluation_options)
MathStructure convert (string str, Unit *from_unit, Unit *to_unit, const EvaluationOptions &eo=default_evaluation_options)
MathStructure convertToBaseUnits (const MathStructure &mstruct, const EvaluationOptions &eo=default_evaluation_options)
UnitgetBestUnit (Unit *u, bool allow_only_div=false)
MathStructure convertToBestUnit (const MathStructure &mstruct, const EvaluationOptions &eo=default_evaluation_options)
MathStructure convertToCompositeUnit (const MathStructure &mstruct, CompositeUnit *cu, const EvaluationOptions &eo=default_evaluation_options, bool always_convert=true)
Functions for default assumptions for unknown variables and symbols
void setDefaultAssumptions (Assumptions *ass)
AssumptionsdefaultAssumptions ()
Functions for retrieval of angle units
UnitgetGraUnit ()
UnitgetRadUnit ()
UnitgetDegUnit ()
Functions for finding a suitable prefix.
DecimalPrefixgetExactDecimalPrefix (int exp10, int exp=1) const
BinaryPrefixgetExactBinaryPrefix (int exp2, int exp=1) const
PrefixgetExactPrefix (const Number &o, int exp=1) const
DecimalPrefixgetNearestDecimalPrefix (int exp10, int exp=1) const
DecimalPrefixgetBestDecimalPrefix (int exp10, int exp=1, bool all_prefixes=true) const
DecimalPrefixgetBestDecimalPrefix (const Number &exp10, const Number &exp, bool all_prefixes=true) const
BinaryPrefixgetNearestBinaryPrefix (int exp2, int exp=1) const
BinaryPrefixgetBestBinaryPrefix (int exp2, int exp=1) const
BinaryPrefixgetBestBinaryPrefix (const Number &exp2, const Number &exp) const
PrefixaddPrefix (Prefix *p)
void prefixNameChanged (Prefix *p, bool new_item=false)
Functions for managing functions, variables, units, prefixes and data sets.
void expressionItemActivated (ExpressionItem *item)
void expressionItemDeactivated (ExpressionItem *item)
void expressionItemDeleted (ExpressionItem *item)
void nameChanged (ExpressionItem *item, bool new_item=false)
void deleteName (string name_, ExpressionItem *object=NULL)
void deleteUnitName (string name_, Unit *object=NULL)
UnitaddUnit (Unit *u, bool force=true, bool check_names=true)
void delPrefixUFV (Prefix *object)
void delUFV (ExpressionItem *object)
bool hasVariable (Variable *v)
bool hasUnit (Unit *u)
bool hasFunction (MathFunction *f)
bool stillHasVariable (Variable *v)
bool stillHasUnit (Unit *u)
bool stillHasFunction (MathFunction *f)
void saveFunctionCalled ()
bool checkSaveFunctionCalled ()
ExpressionItemgetActiveExpressionItem (string name, ExpressionItem *item=NULL)
ExpressionItemgetInactiveExpressionItem (string name, ExpressionItem *item=NULL)
ExpressionItemgetActiveExpressionItem (ExpressionItem *item)
ExpressionItemgetExpressionItem (string name, ExpressionItem *item=NULL)
UnitgetUnit (string name_)
UnitgetActiveUnit (string name_)
UnitgetCompositeUnit (string internal_name_)
PrefixgetPrefix (size_t index) const
PrefixgetPrefix (string name_) const
VariableaddVariable (Variable *v, bool force=true, bool check_names=true)
void variableNameChanged (Variable *v, bool new_item=false)
void functionNameChanged (MathFunction *f, bool new_item=false)
void unitNameChanged (Unit *u, bool new_item=false)
VariablegetVariable (string name_)
VariablegetActiveVariable (string name_)
ExpressionItemaddExpressionItem (ExpressionItem *item, bool force=true)
MathFunctionaddFunction (MathFunction *f, bool force=true, bool check_names=true)
DataSetaddDataSet (DataSet *dc, bool force=true, bool check_names=true)
DataSetgetDataSet (size_t index)
DataSetgetDataSet (string name)
MathFunctiongetFunction (string name_)
MathFunctiongetActiveFunction (string name_)
VariablegetVariable (size_t index) const
UnitgetUnit (size_t index) const
MathFunctiongetFunction (size_t index) const
bool unitIsUsedByOtherUnits (const Unit *u) const
Functions for handling of builtin expression items
void resetVariables ()
void resetFunctions ()
void resetUnits ()
void reset ()
void addBuiltinVariables ()
void addBuiltinFunctions ()
void addBuiltinUnits ()
Functions for testing validity of functions, variable and unit names.
bool variableNameIsValid (const string &name_)
bool variableNameIsValid (const char *name_)
bool variableNameIsValid (const char *name_, int version_numbers[3], bool is_user_defs)
bool variableNameIsValid (const string &name_, int version_numbers[3], bool is_user_defs)
string convertToValidVariableName (string name_)
bool functionNameIsValid (const string &name_)
bool functionNameIsValid (const char *name_)
bool functionNameIsValid (const char *name_, int version_numbers[3], bool is_user_defs)
bool functionNameIsValid (const string &name_, int version_numbers[3], bool is_user_defs)
string convertToValidFunctionName (string name_)
bool unitNameIsValid (const string &name_)
bool unitNameIsValid (const char *name_)
bool unitNameIsValid (const char *name_, int version_numbers[3], bool is_user_defs)
bool unitNameIsValid (const string &name_, int version_numbers[3], bool is_user_defs)
bool utf8_pos_is_valid_in_name (char *pos)
string convertToValidUnitName (string name_)
bool nameTaken (string name, ExpressionItem *object=NULL)
bool variableNameTaken (string name, Variable *object=NULL)
bool unitNameTaken (string name, Unit *object=NULL)
bool functionNameTaken (string name, MathFunction *object=NULL)
string getName (string name="", ExpressionItem *object=NULL, bool force=false, bool always_append=false)
Functions for message handling.
void error (bool critical, const char *TEMPLATE,...)
void message (MessageType mtype, const char *TEMPLATE,...)
CalculatorMessagemessage ()
CalculatorMessagenextMessage ()
bool showArgumentErrors () const
void beginTemporaryStopMessages ()
int endTemporaryStopMessages (int *message_count=NULL, int *warning_count=NULL)
Functions for loading and saving definitions (variables, functions, units, etc.).
bool loadGlobalDefinitions ()
bool loadGlobalDefinitions (string filename)
bool loadGlobalPrefixes ()
bool loadGlobalCurrencies ()
bool loadGlobalUnits ()
bool loadGlobalVariables ()
bool loadGlobalFunctions ()
bool loadGlobalDataSets ()
bool loadLocalDefinitions ()
int loadDefinitions (const char *file_name, bool is_user_defs=true)
bool saveDefinitions ()
int saveDataObjects ()
int savePrefixes (const char *file_name, bool save_global=false)
int saveVariables (const char *file_name, bool save_global=false)
int saveUnits (const char *file_name, bool save_global=false)
int saveFunctions (const char *file_name, bool save_global=false)
int saveDataSets (const char *file_name, bool save_global=false)
Functions for CSV file import/export.
bool importCSV (MathStructure &mstruct, const char *file_name, int first_row=1, string delimiter=",", vector< string > *headers=NULL)
bool importCSV (const char *file_name, int first_row=1, bool headers=true, string delimiter=",", bool to_matrix=false, string name="", string title="", string category="")
bool exportCSV (const MathStructure &mstruct, const char *file_name, string delimiter=",")
Functions for exchange rates.
bool canFetch ()
bool hasGnomeVFS ()
bool loadExchangeRates ()
string getExchangeRatesFileName ()
string getExchangeRatesUrl ()
bool fetchExchangeRates (int timeout, string wget_args)
bool fetchExchangeRates (int timeout=15)
bool checkExchangeRatesDate ()
Functions for plotting
bool canPlot ()
MathStructure expressionToPlotVector (string expression, const MathStructure &min, const MathStructure &max, int steps, MathStructure *x_vector=NULL, string x_var="\\x", const ParseOptions &po=default_parse_options)
MathStructure expressionToPlotVector (string expression, float min, float max, int steps, MathStructure *x_vector=NULL, string x_var="\\x", const ParseOptions &po=default_parse_options)
MathStructure expressionToPlotVector (string expression, const MathStructure &min, const MathStructure &max, const MathStructure &step, MathStructure *x_vector=NULL, string x_var="\\x", const ParseOptions &po=default_parse_options)
MathStructure expressionToPlotVector (string expression, float min, float max, float step, MathStructure *x_vector=NULL, string x_var="\\x", const ParseOptions &po=default_parse_options)
MathStructure expressionToPlotVector (string expression, const MathStructure &x_vector, string x_var="\\x", const ParseOptions &po=default_parse_options)
bool plotVectors (PlotParameters *param, const vector< MathStructure > &y_vectors, const vector< MathStructure > &x_vectors, vector< PlotDataParameters * > &pdps, bool persistent=false)
bool invokeGnuplot (string commands, string commandline_extra="", bool persistent=false)
bool closeGnuplot ()
bool gnuplotOpen ()
Functions for global precision
void setPrecision (int precision=DEFAULT_PRECISION)
int getPrecision () const
Functions for localization
const string & getDecimalPoint () const
const string & getComma () const
void setLocale ()
void useDecimalComma ()
void useDecimalPoint ()
void unsetLocale ()
string localToString () const
Functions adding alternative symbols for operators and such
void addStringAlternative (string replacement, string standard)
bool delStringAlternative (string replacement, string standard)
void addDefaultStringAlternative (string replacement, string standard)
bool delDefaultStringAlternative (string replacement, string standard)
Functions for storing values with associated identifiers
size_t addId (MathStructure *mstruct, bool persistent=false)
size_t parseAddId (MathFunction *f, const string &str, const ParseOptions &po, bool persistent=false)
size_t parseAddIdAppend (MathFunction *f, const MathStructure &append_mstruct, const string &str, const ParseOptions &po, bool persistent=false)
size_t parseAddVectorId (const string &str, const ParseOptions &po, bool persistent=false)
MathStructuregetId (size_t id)
void delId (size_t id)

Public Attributes

KnownVariablev_pi
KnownVariablev_e
KnownVariablev_i
KnownVariablev_inf
KnownVariablev_pinf
KnownVariablev_minf
KnownVariablev_undef
UnknownVariablev_x
UnknownVariablev_y
UnknownVariablev_z
MathFunctionf_vector
MathFunctionf_sort
MathFunctionf_rank
MathFunctionf_limits
MathFunctionf_component
MathFunctionf_dimension
MathFunctionf_merge_vectors
MathFunctionf_matrix
MathFunctionf_matrix_to_vector
MathFunctionf_area
MathFunctionf_rows
MathFunctionf_columns
MathFunctionf_row
MathFunctionf_column
MathFunctionf_elements
MathFunctionf_element
MathFunctionf_transpose
MathFunctionf_identity
MathFunctionf_determinant
MathFunctionf_permanent
MathFunctionf_adjoint
MathFunctionf_cofactor
MathFunctionf_inverse
MathFunctionf_factorial
MathFunctionf_factorial2
MathFunctionf_multifactorial
MathFunctionf_binomial
MathFunctionf_xor
MathFunctionf_bitxor
MathFunctionf_even
MathFunctionf_odd
MathFunctionf_shift
MathFunctionf_abs
MathFunctionf_gcd
MathFunctionf_lcm
MathFunctionf_signum
MathFunctionf_round
MathFunctionf_floor
MathFunctionf_ceil
MathFunctionf_trunc
MathFunctionf_int
MathFunctionf_frac
MathFunctionf_rem
MathFunctionf_mod
MathFunctionf_polynomial_unit
MathFunctionf_polynomial_primpart
MathFunctionf_polynomial_content
MathFunctionf_coeff
MathFunctionf_lcoeff
MathFunctionf_tcoeff
MathFunctionf_degree
MathFunctionf_ldegree
MathFunctionf_re
MathFunctionf_im
MathFunctionf_arg
MathFunctionf_numerator
MathFunctionf_denominator
MathFunctionf_sqrt
MathFunctionf_sq
MathFunctionf_exp
MathFunctionf_ln
MathFunctionf_logn
MathFunctionf_sin
MathFunctionf_cos
MathFunctionf_tan
MathFunctionf_asin
MathFunctionf_acos
MathFunctionf_atan
MathFunctionf_sinh
MathFunctionf_cosh
MathFunctionf_tanh
MathFunctionf_asinh
MathFunctionf_acosh
MathFunctionf_atanh
MathFunctionf_radians_to_default_angle_unit
MathFunctionf_zeta
MathFunctionf_gamma
MathFunctionf_beta
MathFunctionf_total
MathFunctionf_percentile
MathFunctionf_min
MathFunctionf_max
MathFunctionf_mode
MathFunctionf_rand
MathFunctionf_isodate
MathFunctionf_localdate
MathFunctionf_timestamp
MathFunctionf_stamptodate
MathFunctionf_days
MathFunctionf_yearfrac
MathFunctionf_week
MathFunctionf_weekday
MathFunctionf_month
MathFunctionf_day
MathFunctionf_year
MathFunctionf_yearday
MathFunctionf_time
MathFunctionf_bin
MathFunctionf_oct
MathFunctionf_hex
MathFunctionf_base
MathFunctionf_roman
MathFunctionf_ascii
MathFunctionf_char
MathFunctionf_length
MathFunctionf_concatenate
MathFunctionf_replace
MathFunctionf_stripunits
MathFunctionf_genvector
MathFunctionf_for
MathFunctionf_sum
MathFunctionf_product
MathFunctionf_process
MathFunctionf_process_matrix
MathFunctionf_csum
MathFunctionf_if
MathFunctionf_function
MathFunctionf_select
MathFunctionf_diff
MathFunctionf_integrate
MathFunctionf_solve
MathFunctionf_multisolve
MathFunctionf_error
MathFunctionf_warning
MathFunctionf_message
MathFunctionf_save
MathFunctionf_load
MathFunctionf_export
MathFunctionf_title
MathFunctionf_register
MathFunctionf_stack
Unitu_rad
Unitu_gra
Unitu_deg
Unitu_euro
DecimalPrefixdecimal_null_prefix
BinaryPrefixbinary_null_prefix
bool place_currency_code_before
bool place_currency_sign_before
bool place_currency_code_before_negative
bool place_currency_sign_before_negative
bool default_dot_as_separator
bool b_busy
bool calculate_thread_stopped
bool print_thread_stopped
string expression_to_calculate
string tmp_print_result
PrintOptions tmp_printoptions
EvaluationOptions tmp_evaluationoptions
MathStructuretmp_parsedstruct
MathStructuretmp_tostruct
MathStructuretmp_rpn_mstruct
bool tmp_maketodivision
int tmp_proc_command
size_t tmp_rpnindex
PrintOptions save_printoptions
vector< Variable * > variables
vector< MathFunction * > functions
vector< Unit * > units
vector< Prefix * > prefixes
vector< DecimalPrefix * > decimal_prefixes
vector< BinaryPrefix * > binary_prefixes

Protected Member Functions

bool calculateRPN (MathStructure *mstruct, int command, size_t index, int msecs, const EvaluationOptions &eo)
bool calculateRPN (string str, int command, size_t index, int msecs, const EvaluationOptions &