libqalculate-ruby 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,304 @@
1
+ /*
2
+ Qalculate
3
+
4
+ Copyright (C) 2004-2006 Niklas Knutsson (nq@altern.org)
5
+
6
+ This program is free software; you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation; either version 2 of the License, or
9
+ (at your option) any later version.
10
+ */
11
+
12
+ #ifndef DATA_SET_H
13
+ #define DATA_SET_H
14
+
15
+ #include <libqalculate/includes.h>
16
+ #include <libqalculate/Function.h>
17
+
18
+ /** @file */
19
+
20
+ typedef Sgi::vector<DataProperty*>::iterator DataObjectPropertyIter;
21
+
22
+ /// A a data set object.
23
+ /** Data objects consist of property-value pairs. */
24
+ class DataObject {
25
+
26
+ protected:
27
+
28
+ vector<DataProperty*> properties;
29
+ vector<string> s_properties;
30
+ vector<string> s_nonlocalized_properties;
31
+ vector<MathStructure*> m_properties;
32
+ vector<int> a_properties;
33
+ DataSet *parent;
34
+ bool b_uchanged;
35
+
36
+ public:
37
+
38
+ /** Create a data object.
39
+ *
40
+ * @param parent_set Data set that the object will belong to.
41
+ */
42
+ DataObject(DataSet *parent_set);
43
+
44
+ /** Unset (erase value) a property.
45
+ *
46
+ * @param property Property to unset.
47
+ */
48
+ void eraseProperty(DataProperty *property);
49
+ /** Set value for a property.
50
+ *
51
+ * @param property Property to set (must belong to parent data set).
52
+ * @param s_vale Value for the property.
53
+ * @param is_approximate If the value is approximate. 1 for approximate, 0 for exact, -1 for property default.
54
+ */
55
+ void setProperty(DataProperty *property, string s_value, int is_approximate = -1);
56
+ /** Set an untranslated value for a key property. Used when a text value is translated, but the original value still is needed as a reference key.
57
+ *
58
+ * @param property Property to set (must belong to parent data set).
59
+ * @param s_vale Value for the property.
60
+ */
61
+ void setNonlocalizedKeyProperty(DataProperty *property, string s_value);
62
+
63
+ /** Returns parsed value for a property. Parses the text string value if not parsed before
64
+ *
65
+ * @param property Property to read.
66
+ * @returns Parsed value or NULL if property value is not set.
67
+ */
68
+ const MathStructure *getPropertyStruct(DataProperty *property);
69
+ /** Returns unparsed value for a property.
70
+ *
71
+ * @param property Property to read.
72
+ * @param[out] is_approximate If the value is approximate. Is set to 1 for approximate, 0 for exact, -1 for property default, if not NULL.
73
+ * @returns Unparsed value or empty string if property value is not set.
74
+ */
75
+ const string &getProperty(DataProperty *property, int *is_approximate = NULL);
76
+ /** Returns unparsed untranslated value for a key property. Used when a text value is translated, but the original value still is needed as a reference key.
77
+ *
78
+ * @param property Property to read.
79
+ * @returns Unparsed untranslated value or empty string if property value is not set.
80
+ */
81
+ const string &getNonlocalizedKeyProperty(DataProperty *property);
82
+ /** Returns value for a property in a format suitable for use in expressions with unit appended.
83
+ *
84
+ * @param property Property to read.
85
+ * @returns Value in input format or empty string if property value is not set.
86
+ */
87
+ string getPropertyInputString(DataProperty *property);
88
+ /** Returns value for a property in a format suitable for display with unit appended.
89
+ *
90
+ * @param property Property to read.
91
+ * @returns Value in display format or empty string if property value is not set.
92
+ */
93
+ string getPropertyDisplayString(DataProperty *property);
94
+
95
+ /** If the object has been modified by the end user (if setUserModified() has been called).
96
+ *
97
+ * @returns true if the object has been modified by the user.
98
+ */
99
+ bool isUserModified() const;
100
+ /** Specify if the object has been modified by the end user.
101
+ *
102
+ * @param user_modified true if the object has been modified by the user.
103
+ */
104
+ void setUserModified(bool user_modified = true);
105
+
106
+ /** Returns the data set that the object belongs to.
107
+ *
108
+ * @returns Parent data set.
109
+ */
110
+ DataSet *parentSet() const;
111
+
112
+ };
113
+
114
+ typedef enum {
115
+ PROPERTY_EXPRESSION,
116
+ PROPERTY_NUMBER,
117
+ PROPERTY_STRING
118
+ } PropertyType;
119
+
120
+ /// A data set property.
121
+ /** Property definitions for use with data set objects. */
122
+ class DataProperty {
123
+
124
+ protected:
125
+
126
+ vector<string> names;
127
+ vector<bool> name_is_ref;
128
+ string sdescr, stitle, sunit;
129
+ MathStructure *m_unit;
130
+ bool b_approximate, b_brackets, b_key, b_case, b_hide;
131
+ DataSet *parent;
132
+ PropertyType ptype;
133
+ bool b_uchanged;
134
+
135
+ public:
136
+
137
+ /** Create a data property.
138
+ *
139
+ * @param s_name Property name (initial) used for reference.
140
+ * @param s_title Descriptive name/title.
141
+ * @param s_description Description.
142
+ */
143
+ DataProperty(DataSet *parent_set, string s_name = "", string s_title = "", string s_description = "");
144
+ DataProperty(const DataProperty &dp);
145
+
146
+ void set(const DataProperty &dp);
147
+ void setName(string s_name, bool is_ref = false);
148
+ void setNameIsReference(size_t index = 1, bool is_ref = true);
149
+ bool nameIsReference(size_t index = 1) const;
150
+ void clearNames();
151
+ void addName(string s_name, bool is_ref = false, size_t index = 0);
152
+ size_t hasName(const string &s_name);
153
+ size_t countNames() const;
154
+ const string &getName(size_t index = 1) const;
155
+ const string &getReferenceName() const;
156
+ void setTitle(string s_title);
157
+ const string &title(bool return_name_if_no_title = true) const;
158
+ void setDescription(string s_description);
159
+ const string &description() const;
160
+ void setUnit(string s_unit);
161
+ const string &getUnitString() const;
162
+ const MathStructure *getUnitStruct();
163
+ string getInputString(const string &valuestr);
164
+ string getDisplayString(const string &valuestr);
165
+ MathStructure *generateStruct(const string &valuestr, int is_approximate = -1);
166
+ void setKey(bool is_key = true);
167
+ bool isKey() const;
168
+ void setHidden(bool is_hidden = true);
169
+ bool isHidden() const;
170
+ void setCaseSensitive(bool is_case_sensitive = true);
171
+ bool isCaseSensitive() const;
172
+ void setUsesBrackets(bool uses_brackets = true);
173
+ bool usesBrackets() const;
174
+ void setApproximate(bool is_approximate = true);
175
+ bool isApproximate() const;
176
+ void setPropertyType(PropertyType property_type);
177
+ PropertyType propertyType() const;
178
+
179
+ bool isUserModified() const;
180
+ void setUserModified(bool user_modified = true);
181
+
182
+ DataSet *parentSet() const;
183
+
184
+ };
185
+
186
+ typedef vector<DataProperty*>::iterator DataPropertyIter;
187
+ typedef vector<DataObject*>::iterator DataObjectIter;
188
+
189
+ /// A data set.
190
+ /** This is a simple database class for storage of many grouped values, when ordinary variables is not practical.
191
+ *
192
+ * A data set consists of properties and objects, with values for the properties. Qalculate! includes for example a "Planets" data set with properties such as name, mass, speed and density, and an object for each planet in solar system.
193
+ *
194
+ * A data set is also mathemtical function, dataset(object, property), which retrieves values for objects and properties.
195
+ * Data sets can be saved and loaded from a XML file.
196
+ */
197
+ class DataSet : public MathFunction {
198
+
199
+ protected:
200
+
201
+ string sfile, scopyright;
202
+ bool b_loaded;
203
+ vector<DataProperty*> properties;
204
+ vector<DataObject*> objects;
205
+
206
+ public:
207
+
208
+ DataSet(string s_category = "", string s_name = "", string s_default_file = "", string s_title = "", string s_description = "", bool is_local = true);
209
+ DataSet(const DataSet *o);
210
+
211
+ ExpressionItem *copy() const;
212
+ void set(const ExpressionItem *item);
213
+ int subtype() const;
214
+
215
+ void setCopyright(string s_copyright);
216
+ const string &copyright() const;
217
+ void setDefaultDataFile(string s_file);
218
+ const string &defaultDataFile() const;
219
+
220
+ void setDefaultProperty(string property);
221
+ const string &defaultProperty() const;
222
+
223
+ int calculate(MathStructure &mstruct, const MathStructure &vargs, const EvaluationOptions &eo);
224
+
225
+ bool loadObjects(const char *file_name = NULL, bool is_user_defs = true);
226
+ int saveObjects(const char *file_name = NULL, bool save_global = false);
227
+ bool objectsLoaded() const;
228
+ void setObjectsLoaded(bool objects_loaded);
229
+
230
+ void addProperty(DataProperty *dp);
231
+ void delProperty(DataProperty *dp);
232
+ void delProperty(DataPropertyIter *it);
233
+ DataProperty *getPrimaryKeyProperty();
234
+ DataProperty *getProperty(string property);
235
+ DataProperty *getFirstProperty(DataPropertyIter *it);
236
+ DataProperty *getNextProperty(DataPropertyIter *it);
237
+ const string &getFirstPropertyName(DataPropertyIter *it);
238
+ const string &getNextPropertyName(DataPropertyIter *it);
239
+
240
+ void addObject(DataObject *o);
241
+ void delObject(DataObject *o);
242
+ void delObject(DataObjectIter *it);
243
+ DataObject *getObject(string object);
244
+ DataObject *getObject(const MathStructure &object);
245
+ DataObject *getFirstObject(DataObjectIter *it);
246
+ DataObject *getNextObject(DataObjectIter *it);
247
+
248
+ const MathStructure *getObjectProperyStruct(string property, string object);
249
+ const string &getObjectProperty(string property, string object);
250
+ string getObjectPropertyInputString(string property, string object);
251
+ string getObjectPropertyDisplayString(string property, string object);
252
+
253
+ string printProperties(string object);
254
+ string printProperties(DataObject *o);
255
+
256
+ };
257
+
258
+ /// Data property function argument.
259
+ class DataPropertyArgument : public Argument {
260
+
261
+ protected:
262
+
263
+ DataSet *o_data;
264
+
265
+ virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;
266
+ virtual string subprintlong() const;
267
+
268
+ public:
269
+
270
+ DataPropertyArgument(DataSet *data_set, string name_ = "", bool does_test = true, bool does_error = true);
271
+ DataPropertyArgument(const DataPropertyArgument *arg);
272
+ ~DataPropertyArgument();
273
+ int type() const;
274
+ Argument *copy() const;
275
+ string print() const;
276
+ DataSet *dataSet() const;
277
+ void setDataSet(DataSet *data_set);
278
+
279
+ };
280
+
281
+ /// Data object function argument.
282
+ class DataObjectArgument : public Argument {
283
+
284
+ protected:
285
+
286
+ DataSet *o_data;
287
+
288
+ virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;
289
+ virtual string subprintlong() const;
290
+
291
+ public:
292
+
293
+ DataObjectArgument(DataSet *data_set, string name_ = "", bool does_test = true, bool does_error = true);
294
+ DataObjectArgument(const DataObjectArgument *arg);
295
+ ~DataObjectArgument();
296
+ int type() const;
297
+ Argument *copy() const;
298
+ string print() const;
299
+ DataSet *dataSet() const;
300
+ void setDataSet(DataSet *data_set);
301
+
302
+ };
303
+
304
+ #endif
@@ -0,0 +1,289 @@
1
+ /*
2
+ Qalculate
3
+
4
+ Copyright (C) 2003-2007 Niklas Knutsson (nq@altern.org)
5
+
6
+ This program is free software; you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation; either version 2 of the License, or
9
+ (at your option) any later version.
10
+ */
11
+
12
+ #ifndef EXPRESSIONITEM_H
13
+ #define EXPRESSIONITEM_H
14
+
15
+ #include <libqalculate/includes.h>
16
+
17
+ /** @file */
18
+
19
+ /// A name for an expression item (function, variable or unit)
20
+ /** An expression name has a text std::string representing a name and boolean values describing the names properties.
21
+ */
22
+ struct ExpressionName {
23
+
24
+ /// If the name is an abbreviation.
25
+ bool abbreviation;
26
+ /// If the name has a suffix. If set to true, the part of the name after an underscore should be treated as a suffix.
27
+ bool suffix;
28
+ /// If the name contains unicode characters.
29
+ bool unicode;
30
+ /// If the name is in plural form.
31
+ bool plural;
32
+ /// If the name shall be used as a fixed reference. If this is set to true, the name will kept as it is in addition to translations of it.
33
+ bool reference;
34
+ /// If the name is unsuitable for user input.
35
+ bool avoid_input;
36
+ /// If the name is case sensitive. The default behavior is that abbreviations are case sensitive and other names are not.
37
+ bool case_sensitive;
38
+ /// The name.
39
+ std::string name;
40
+
41
+ /** Create an empty expression name. All properties are set to false.
42
+ */
43
+ ExpressionName();
44
+ /** Create an expression name. All properties are set to false, unless the name only has one character in which case abbreviation and case_sesnsitive is set to true.
45
+ *
46
+ * @param sname The name.
47
+ */
48
+ ExpressionName(std::string sname);
49
+
50
+ void operator = (const ExpressionName &ename);
51
+ bool operator == (const ExpressionName &ename) const;
52
+ bool operator != (const ExpressionName &ename) const;
53
+
54
+ };
55
+
56
+ /// Abstract base class for functions, variables and units.
57
+ /**
58
+ * Expression items have one or more names used to reference it in mathematical expressions and display them in a result.
59
+ * Each name must be fully unique, with the exception that functions can have names used by other types of items
60
+ * (for example "min" is used as a name for the minute unit but also for a function returning smallest value in a vector).
61
+ *
62
+ * Items have an optional title and description for information to the end user.
63
+ * The categoy property is used to organize items, so that the end user can easily find them.
64
+ * Subcategories are separated by a slash, '/' (ex. "Physical Constants/Electromagnetic Constants").
65
+ *
66
+ * A local item is created/edited by the end user.
67
+ *
68
+ * A builtin item has defining properties that can/should not be edited by the user and is usually an item not loaded from the definition files.
69
+ *
70
+ * An inactive item can not be used in expressions and can share the name of an active item.
71
+ *
72
+ * The hidden propery defines if the item should be hidden from the end user.
73
+ *
74
+ * Before an item can be used in expressions, it must be added to the Calculator object using CALCULATOR->addExpressionItem().
75
+ * It is then said to be registered.
76
+ *
77
+ * To delete an ExpressionItem object you should use destroy() to make sure that the item is removed from the Calculator and does not have any referrer.
78
+ *
79
+ */
80
+ class ExpressionItem {
81
+
82
+ protected:
83
+
84
+ std::string scat, stitle, sdescr;
85
+ bool b_local, b_changed, b_builtin, b_approx, b_active, b_registered, b_hidden, b_destroyed;
86
+ int i_ref, i_precision;
87
+ vector<ExpressionItem*> v_refs;
88
+ vector<ExpressionName> names;
89
+
90
+ public:
91
+
92
+ ExpressionItem(std::string cat_, std::string name_, std::string title_ = "", std::string descr_ = "", bool is_local = true, bool is_builtin = false, bool is_active = true);
93
+ ExpressionItem();
94
+ virtual ~ExpressionItem();
95
+
96
+ virtual ExpressionItem *copy() const = 0;
97
+ virtual void set(const ExpressionItem *item);
98
+
99
+ virtual bool destroy();
100
+
101
+ bool isRegistered() const;
102
+ /// For internal use.
103
+ void setRegistered(bool is_registered);
104
+
105
+ virtual const std::string &name(bool use_unicode = false, bool (*can_display_unicode_string_function) (const char*, void*) = NULL, void *can_display_unicode_string_arg = NULL) const;
106
+ virtual const std::string &referenceName() const;
107
+
108
+ /** Returns the name that best fulfils provided criterias. If two names are equally preferred, the one with lowest index is returned.
109
+ *
110
+ * @param abbreviation If an abbreviated name is preferred.
111
+ * @param use_unicode If a name with unicode characters can be displayed/is preferred (prioritized if false).
112
+ * @param plural If a name in plural form is preferred.
113
+ * @param reference If a reference name is preferred (ignored if false).
114
+ * @param can_display_unicode_string_function Function that tests if the unicode characters in a name can be displayed. If the function returns false, the name will be rejected.
115
+ * @param can_display_unicode_string_arg Argument to pass to the above test function.
116
+ * @returns The preferred name.
117
+ */
118
+ virtual const ExpressionName &preferredName(bool abbreviation = false, bool use_unicode = false, bool plural = false, bool reference = false, bool (*can_display_unicode_string_function) (const char*, void*) = NULL, void *can_display_unicode_string_arg = NULL) const;
119
+ /** Returns the name that best fulfils provided criterias and is suitable for user input. If two names are equally preferred, the one with lowest index is returned.
120
+ *
121
+ * @param abbreviation If an abbreviated name is preferred.
122
+ * @param use_unicode If a name with unicode characters can be displayed/is preferred (prioritized if false).
123
+ * @param plural If a name in plural form is preferred.
124
+ * @param reference If a reference name is preferred (ignored if false).
125
+ * @param can_display_unicode_string_function Function that tests if the unicode characters in a name can be displayed. If the function returns false, the name will be rejected.
126
+ * @param can_display_unicode_string_arg Argument to pass to the above test function.
127
+ * @returns The preferred name.
128
+ */
129
+ virtual const ExpressionName &preferredInputName(bool abbreviation = false, bool use_unicode = false, bool plural = false, bool reference = false, bool (*can_display_unicode_string_function) (const char*, void*) = NULL, void *can_display_unicode_string_arg = NULL) const;
130
+ /** Returns the name that best fulfils provided criterias and is suitable for display. If two names are equally preferred, the one with lowest index is returned.
131
+ *
132
+ * @param abbreviation If an abbreviated name is preferred.
133
+ * @param use_unicode If a name with unicode characters can be displayed/is preferred (prioritized if false).
134
+ * @param plural If a name in plural form is preferred.
135
+ * @param reference If a reference name is preferred (ignored if false).
136
+ * @param can_display_unicode_string_function Function that tests if the unicode characters in a name can be displayed. If the function returns false, the name will be rejected.
137
+ * @param can_display_unicode_string_arg Argument to pass to the above test function.
138
+ * @returns The preferred name.
139
+ */
140
+ virtual const ExpressionName &preferredDisplayName(bool abbreviation = false, bool use_unicode = false, bool plural = false, bool reference = false, bool (*can_display_unicode_string_function) (const char*, void*) = NULL, void *can_display_unicode_string_arg = NULL) const;
141
+ /** Returns name for an index (starting at one). All functions can be traversed by starting at index one and increasing the index until empty_expression_name is returned.
142
+ *
143
+ * @param index Index of name.
144
+ * @returns Name for index or empty_expression_name if not found.
145
+ */
146
+ virtual const ExpressionName &getName(size_t index) const;
147
+ /** Changes a name. If a name for the provided index is not present, it is added (equivalent to addName(ename, index, force)).
148
+ *
149
+ * @param ename The new name.
150
+ * @param index Index of name to change.
151
+ * @param force If true, expression items with conflicting names are replaced, otherwise . Only applies if the item is registered.
152
+ */
153
+ virtual void setName(const ExpressionName &ename, size_t index = 1, bool force = true);
154
+ /** Changes the text string of a name. If a name for the provided index is not present, it is added (equivalent to addName(sname, index, force)).
155
+ *
156
+ * @param sname The new name text string.
157
+ * @param index Index of name to change.
158
+ * @param force If true, expression items with conflicting names are replaced, otherwise . Only applies if the item is registered.
159
+ */
160
+ virtual void setName(std::string sname, size_t index, bool force = true);
161
+ virtual void addName(const ExpressionName &ename, size_t index = 0, bool force = true);
162
+ virtual void addName(std::string sname, size_t index = 0, bool force = true);
163
+ virtual size_t countNames() const;
164
+ /** Removes all names. */
165
+ virtual void clearNames();
166
+ /** Removes all names that are not used for reference (ExpressionName.reference = true). */
167
+ virtual void clearNonReferenceNames();
168
+ virtual void removeName(size_t index);
169
+ /** Checks if the expression item has a name with a specific text string.
170
+ *
171
+ * @param sname A text string to look for (not case sensitive)
172
+ * @param case_sensitive If the name is case sensitive.
173
+ * @returns Index of the name with the given text string or zero if such a name was not found.
174
+ */
175
+ virtual size_t hasName(const std::string &sname, bool case_sensitive = true) const;
176
+ /** Checks if the expression item has a name with a specific case sensitive text string.
177
+ *
178
+ * @param sname A text string to look for (case sensitive)
179
+ * @returns Index of the name with the given text string or zero if such a name was not found.
180
+ */
181
+ virtual size_t hasNameCaseSensitive(const std::string &sname) const;
182
+ /** Searches for a name with specific properties.
183
+ *
184
+ * @param abbreviation If the name must be abbreviated. 1=true, 0=false, -1=ignore.
185
+ * @param use_unicode If the name must have unicode characters. 1=true, 0=false, -1=ignore.
186
+ * @param plural If the name must be in plural form. 1=true, 0=false, -1=ignore.
187
+ * @param can_display_unicode_string_function Function that tests if the unicode characters in a name can be displayed. If the function returns false, the name will be rejected.
188
+ * @param can_display_unicode_string_arg Argument to pass to the above test function.
189
+ * @returns The first found name with the specified properties or empty_expression_name if none found.
190
+ */
191
+ virtual const ExpressionName &findName(int abbreviation = -1, int use_unicode = -1, int plural = -1, bool (*can_display_unicode_string_function) (const char*, void*) = NULL, void *can_display_unicode_string_arg = NULL) const;
192
+
193
+ /** Returns the title, descriptive name, of the item.
194
+ *
195
+ * @param return_name_if_no_title If true, a name is returned if the title string is empty (using preferredName(false, use_unicode, false, false, can_display_unicode_string_function, can_display_unicode_string_arg)).
196
+ * @param use_unicode If a name with unicode characters can be displayed/is preferred (passed to preferredName()).
197
+ * @param can_display_unicode_string_function Function that tests if the unicode characters in a name can be displayed. If the function returns false, the name will be rejected (passed to preferredName()).
198
+ * @param can_display_unicode_string_arg Argument to pass to the above test function (passed to preferredName()).
199
+ * @returns Item title.
200
+ */
201
+ virtual const std::string &title(bool return_name_if_no_title = true, bool use_unicode = false, bool (*can_display_unicode_string_function) (const char*, void*) = NULL, void *can_display_unicode_string_arg = NULL) const;
202
+
203
+ /** Sets the title, descriptive name, of the item. The title can not be used in expressions.
204
+ *
205
+ * @param title_ The new title.
206
+ */
207
+ virtual void setTitle(std::string title_);
208
+
209
+ /** Returns the expression items description.
210
+ *
211
+ * @returns Description.
212
+ */
213
+ virtual const std::string &description() const;
214
+ /** Sets the expression items description.
215
+ *
216
+ * @param descr_ Description.
217
+ */
218
+ virtual void setDescription(std::string descr_);
219
+
220
+ /** Returns the category that the expression item belongs to. Subcategories are separated by '/'.
221
+ *
222
+ * @returns Category.
223
+ */
224
+ virtual const std::string &category() const;
225
+ /** Sets which category the expression belongs to. Subcategories are separated by '/'.
226
+ *
227
+ * @param cat_ Category.
228
+ */
229
+ virtual void setCategory(std::string cat_);
230
+
231
+ /** If the object has been changed since it was created/loaded. */
232
+ virtual bool hasChanged() const;
233
+ virtual void setChanged(bool has_changed);
234
+
235
+ virtual bool isLocal() const;
236
+ virtual bool setLocal(bool is_local = true, int will_be_active = -1);
237
+
238
+ virtual bool isBuiltin() const;
239
+
240
+ /** If the item is approximate or exact.
241
+ * Note that an actual value associated with the item might have a have a lower precision.
242
+ * For, for example, a mathematical function this defines the precision of the formula, not the result.
243
+ *
244
+ * @returns true if the item is approximate
245
+ */
246
+ virtual bool isApproximate() const;
247
+ virtual void setApproximate(bool is_approx = true);
248
+
249
+ /** Returns precision of the item, if it is approximate.
250
+ * Note that an actual value associated with the item might have a have a lower precision.
251
+ * For, for example, a mathematical function this defines the precision of the formula, not the result.
252
+ */
253
+ virtual int precision() const;
254
+ virtual void setPrecision(int prec);
255
+
256
+ /** Returns if the expression item is active and can be used in expressions.
257
+ *
258
+ * @returns true if active.
259
+ */
260
+ virtual bool isActive() const;
261
+ virtual void setActive(bool is_active);
262
+
263
+ virtual bool isHidden() const;
264
+ virtual void setHidden(bool is_hidden);
265
+
266
+ /** The reference count is not used to delete the expression item when it becomes zero, but to stop from being deleted while it is in use.
267
+ */
268
+ virtual int refcount() const;
269
+ virtual void ref();
270
+ virtual void unref();
271
+ virtual void ref(ExpressionItem *o);
272
+ virtual void unref(ExpressionItem *o);
273
+ virtual ExpressionItem *getReferencer(size_t index = 1) const;
274
+ virtual bool changeReference(ExpressionItem *o_from, ExpressionItem *o_to);
275
+
276
+ /** Returns the type of the expression item, corresponding to which subclass the object belongs to.
277
+ *
278
+ * @returns ::ExpressionItemType.
279
+ */
280
+ virtual int type() const = 0;
281
+ /** Returns the subtype of the expression item, corresponding to which subsubclass the object belongs to.
282
+ *
283
+ * @returns Subtype/subsubclass.
284
+ */
285
+ virtual int subtype() const = 0;
286
+
287
+ };
288
+
289
+ #endif