This file is indexed.

/usr/include/libqalculate/DataSet.h is in libqalculate-dev 0.9.7-9.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
/*
    Qalculate    

    Copyright (C) 2004-2006  Niklas Knutsson (nq@altern.org)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
*/

#ifndef DATA_SET_H
#define DATA_SET_H

#include <libqalculate/includes.h>
#include <libqalculate/Function.h>

/** @file */

typedef Sgi::vector<DataProperty*>::iterator DataObjectPropertyIter;

/// A a data set object.
/** Data objects consist of property-value pairs. */
class DataObject {

  protected:

	vector<DataProperty*> properties;
	vector<string> s_properties;
	vector<string> s_nonlocalized_properties;
	vector<MathStructure*> m_properties;
	vector<int> a_properties;
	DataSet *parent;
	bool b_uchanged;
	
  public:
 
	/** Create a data object.
	*
	* @param parent_set Data set that the object will belong to.
	*/
	DataObject(DataSet *parent_set);

	/** Unset (erase value) a property.
	*
	* @param property Property to unset.
	*/
	void eraseProperty(DataProperty *property);
	/** Set value for a property.
	*
	* @param property Property to set (must belong to parent data set).
	* @param s_vale Value for the property.
	* @param is_approximate If the value is approximate. 1 for approximate, 0 for exact, -1 for property default.
	*/
	void setProperty(DataProperty *property, string s_value, int is_approximate = -1);
	/** 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.
	*
	* @param property Property to set (must belong to parent data set).
	* @param s_vale Value for the property.
	*/
	void setNonlocalizedKeyProperty(DataProperty *property, string s_value);
	
	/** Returns parsed value for a property. Parses the text string value if not parsed before 
	*
	* @param property Property to read.
	* @returns Parsed value or NULL if property value is not set.
	*/
	const MathStructure *getPropertyStruct(DataProperty *property);
	/** Returns unparsed value for a property.
	*
	* @param property Property to read.
	* @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.
	* @returns Unparsed value or empty string if property value is not set.
	*/
	const string &getProperty(DataProperty *property, int *is_approximate = NULL);
	/** 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.
	*
	* @param property Property to read.
	* @returns Unparsed untranslated value or empty string if property value is not set.
	*/
	const string &getNonlocalizedKeyProperty(DataProperty *property);
	/** Returns value for a property in a format suitable for use in expressions with unit appended.
	*
	* @param property Property to read.
	* @returns Value in input format or empty string if property value is not set.
	*/
	string getPropertyInputString(DataProperty *property);
	/** Returns value for a property in a format suitable for display with unit appended.
	*
	* @param property Property to read.
	* @returns Value in display format or empty string if property value is not set.
	*/
	string getPropertyDisplayString(DataProperty *property);

	/** If the object has been modified by the end user (if setUserModified() has been called).
	*
	* @returns true if the object has been modified by the user.
	*/
	bool isUserModified() const;
	/** Specify if the object has been modified by the end user.
	*
	* @param user_modified true if the object has been modified by the user.
	*/
	void setUserModified(bool user_modified = true);

	/** Returns the data set that the object belongs to.
	*
	* @returns Parent data set.
	*/
	DataSet *parentSet() const;

};

typedef enum {
	PROPERTY_EXPRESSION,
	PROPERTY_NUMBER,
	PROPERTY_STRING
} PropertyType;

/// A data set property.
/** Property definitions for use with data set objects. */
class DataProperty {

  protected:

	vector<string> names;
	vector<bool> name_is_ref;
	string sdescr, stitle, sunit;
	MathStructure *m_unit;
	bool b_approximate, b_brackets, b_key, b_case, b_hide;
	DataSet *parent;
	PropertyType ptype;
	bool b_uchanged;
	
  public:

	/** Create a data property.
	*
	* @param s_name Property name (initial) used for reference.
	* @param s_title Descriptive name/title.
	* @param s_description Description.
	*/
	DataProperty(DataSet *parent_set, string s_name = "", string s_title = "", string s_description = "");
	DataProperty(const DataProperty &dp);
	
	void set(const DataProperty &dp);
	void setName(string s_name, bool is_ref = false);
	void setNameIsReference(size_t index = 1, bool is_ref = true);
	bool nameIsReference(size_t index = 1) const;
	void clearNames();
	void addName(string s_name, bool is_ref = false, size_t index = 0);
	size_t hasName(const string &s_name);
	size_t countNames() const;
	const string &getName(size_t index = 1) const;
	const string &getReferenceName() const;
	void setTitle(string s_title);
	const string &title(bool return_name_if_no_title = true) const;
	void setDescription(string s_description);
	const string &description() const;
	void setUnit(string s_unit);
	const string &getUnitString() const;
	const MathStructure *getUnitStruct();
	string getInputString(const string &valuestr);
	string getDisplayString(const string &valuestr);
	MathStructure *generateStruct(const string &valuestr, int is_approximate = -1);
	void setKey(bool is_key = true);
	bool isKey() const;
	void setHidden(bool is_hidden = true);
	bool isHidden() const;
	void setCaseSensitive(bool is_case_sensitive = true);
	bool isCaseSensitive() const;
	void setUsesBrackets(bool uses_brackets = true);
	bool usesBrackets() const;
	void setApproximate(bool is_approximate = true);
	bool isApproximate() const;
	void setPropertyType(PropertyType property_type);
	PropertyType propertyType() const;
	
	bool isUserModified() const;
	void setUserModified(bool user_modified = true);
	
	DataSet *parentSet() const;
	
};

typedef vector<DataProperty*>::iterator DataPropertyIter;
typedef vector<DataObject*>::iterator DataObjectIter;

/// A data set.
/** This is a simple database class for storage of many grouped values, when ordinary variables is not practical.
*
* 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.
*
* A data set is also mathemtical function, dataset(object, property), which retrieves values for objects and properties.
* Data sets can be saved and loaded from a XML file.
*/
class DataSet : public MathFunction {

  protected:
  
	string sfile, scopyright;
	bool b_loaded;
	vector<DataProperty*> properties;
	vector<DataObject*> objects;
	
  public:
  
  	DataSet(string s_category = "", string s_name = "", string s_default_file = "", string s_title = "", string s_description = "", bool is_local = true);
	DataSet(const DataSet *o);
	
	ExpressionItem *copy() const;
	void set(const ExpressionItem *item);
	int subtype() const;
	
	void setCopyright(string s_copyright);
	const string &copyright() const;
	void setDefaultDataFile(string s_file);
	const string &defaultDataFile() const;
	
	void setDefaultProperty(string property);
	const string &defaultProperty() const;
	
	virtual int calculate(MathStructure &mstruct, const MathStructure &vargs, const EvaluationOptions &eo);
	
	bool loadObjects(const char *file_name = NULL, bool is_user_defs = true);
	int saveObjects(const char *file_name = NULL, bool save_global = false);
	bool objectsLoaded() const;
	void setObjectsLoaded(bool objects_loaded);
	
	void addProperty(DataProperty *dp);
	void delProperty(DataProperty *dp);
	void delProperty(DataPropertyIter *it);
	DataProperty *getPrimaryKeyProperty();
	DataProperty *getProperty(string property);
	DataProperty *getFirstProperty(DataPropertyIter *it);
	DataProperty *getNextProperty(DataPropertyIter *it);
	const string &getFirstPropertyName(DataPropertyIter *it);
	const string &getNextPropertyName(DataPropertyIter *it);
	
	void addObject(DataObject *o);
	void delObject(DataObject *o);
	void delObject(DataObjectIter *it);
	DataObject *getObject(string object);
	DataObject *getObject(const MathStructure &object);
	DataObject *getFirstObject(DataObjectIter *it);
	DataObject *getNextObject(DataObjectIter *it);
	
	const MathStructure *getObjectProperyStruct(string property, string object);
	const string &getObjectProperty(string property, string object);
	string getObjectPropertyInputString(string property, string object);
	string getObjectPropertyDisplayString(string property, string object);
	
	string printProperties(string object);
	string printProperties(DataObject *o);
		
};

/// Data property function argument.
class DataPropertyArgument : public Argument {

  protected:
  
  	DataSet *o_data;
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;

  public:
  
  	DataPropertyArgument(DataSet *data_set, string name_ = "", bool does_test = true, bool does_error = true);
	DataPropertyArgument(const DataPropertyArgument *arg);
	~DataPropertyArgument();
	int type() const;
	Argument *copy() const;
	string print() const;
	DataSet *dataSet() const;
	void setDataSet(DataSet *data_set);
	
};

/// Data object function argument.
class DataObjectArgument : public Argument {

  protected:
  
  	DataSet *o_data;
  
	virtual bool subtest(MathStructure &value, const EvaluationOptions &eo) const;  
	virtual string subprintlong() const;

  public:
  
  	DataObjectArgument(DataSet *data_set, string name_ = "", bool does_test = true, bool does_error = true);
	DataObjectArgument(const DataObjectArgument *arg);
	~DataObjectArgument();
	int type() const;
	Argument *copy() const;
	string print() const;
	DataSet *dataSet() const;
	void setDataSet(DataSet *data_set);
	
};

#endif