This file is indexed.

/usr/include/terralib/kernel/TeTable.h is in libterralib-dev 4.3.0+dfsg.2-4build2.

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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
 /************************************************************************************
TerraLib - a library for developing GIS applications.
Copyright © 2001-2007 INPE and Tecgraf/PUC-Rio.

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

You should have received a copy of the GNU Lesser General Public
License along with this library.

The authors reassure the license terms regarding the warranties.
They specifically disclaim any warranties, including, but not limited to,
the implied warranties of merchantability and fitness for a particular purpose.
The library provided hereunder is on an "as is" basis, and the authors have no
obligation to provide maintenance, support, updates, enhancements, or modifications.
In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
indirect, special, incidental, or consequential damages arising out of the use
of this library and its documentation.
*************************************************************************************/
/*! \file TeTable.h
    \brief This file contains class TeTable definitions.
*/

#ifndef  __TERRALIB_INTERNAL_TABLE_H
#define  __TERRALIB_INTERNAL_TABLE_H

#ifdef WIN32
#pragma warning ( disable: 4786 )
#endif

#include <string>
#include <vector>
#include "TeComposite.h"
using namespace std;

#include "TeAttribute.h"

class TeTableImpl;

//! A table row is a vector of strings
typedef vector<string> TeTableRow;

//! The table implementation, this is the body class, of the handle/body idiom
/*!
	All members are private. This class is used only through the TeTable class
*/
class TL_DLL TeTableImpl: public TeComposite<TeTableRow>
{

friend class TeTable;

	int refCount_;

	//! Empty constructor
	TeTableImpl(): refCount_(0){}

	//! Returns the value of a cell in table
	string operator () ( int row, int col )
	{
		return components_[row].operator[] ( col );
	}

	void setValue (int row, int col, string& val)
	{
		TeTableRow tRow = components_[row];
		if (col >= (int)(tRow.size()))
			tRow.resize(col+1);
		tRow[col] = val;
		components_[row] = tRow;
	}

};

//! An attribute table in memory
/*!
	Instances of this classes represent non-spatial tables, or tables
	that don´t have a spatial data as one of its columns.
	The class stores the table schema and it also can store rows of data.

	Rows of data are stored according to handle/hody idiom, to make
	copies optimized.

  \sa
  TeAttribute TeTableImpl
*/
class TL_DLL TeTable
{
public:
	//! Empty constructor
	/*!
		\note
		Instance of TeTable will be created with the following default values:
		\arg name: "" (empty)
		\arg id_:  -1 (no database identifier)
        \arg type_: static attribute table
		\arg attList: empty list of attributes
        \arg attLink_:	"" (no index to geometries)
        \arg attUnique_: "" (no unique values)
		\arg separator_: ','  comma separator (used to read ASCII tables from files)
		\arg attInitialTime_: ""  no initial time information
		\arg attFinalTime_: ""  no final time information
		\arg attTimeUnit_: TeYear 
		\arg relatedTableId: -1 (no relation to other table)
		\arg relatedTableName: "" (name of the related table)
		\arg relatedAttribute: "" (attribute of the related table)
	*/
	TeTable();

	//! Constructor by name
	/*!
		\param name table name
		\note
		Instance of TeTable will be created with the following default values:
		\arg id_:  -1 (no database identifier)
        \arg tableType_: static attribute table
		\arg attList: empty list of attributes
        \arg attLink_:	"" (no index to geometries)
        \arg attUnique_: "" (no unique values)
		\arg separator_: ','  comma separator (used to read ASCII tables from files)
		\arg attInitialTime_: ""  no initial time information
		\arg attFinalTime_: ""  no final time information
		\arg attTimeUnit_: TeYear 
		\arg relatedTableId: -1 (no relation to other table)
		\arg relatedTableName: "" (name of the related table)
		\arg relatedAttribute: "" (attribute of the related table)
	*/
	TeTable(const string& name);

	//! Constructor by name and attribute list
	/*!
      \param name table name
      \param attList list of attributes
	  \param uniqueName column that unique attributes to be used as a primary key
	  \param linkName column that links attributes to geometries
	  \param tableType type of attribute table
	  \note
		Instance of TeTable will be created with the following default values:
	   \arg id_:  -1 (no database identifier)
	   \arg separator_: ','  comma separator (used to read ASCII tables from files)
	   \arg attInitialTime_: ""  no initial time information
	   \arg attFinalTime_: ""  no final time information
	   \arg attTimeUnit_: TeYear 
	   \arg relatedTableId: -1 (no relation to other table)
	   \arg relatedTableName: "" (name of the related table)
	   \arg relatedAttribute: "" (attribute of the related table)
	*/
	TeTable(const string& name, const TeAttributeList& attList, const string& uniqueName,
			const string& linkName="", TeAttrTableType tableType=TeAttrStatic);

	 //! Destructor
	~TeTable();

	//! Copy Constructor
	/*! Copies the representation pointer increments the reference counter	*/
	TeTable(const TeTable&);

	//! Operator =
	/*!
		Copies the representation pointer
		Decrements the reference counter of the current object
		Increments the reference counter for the new object
	*/
	TeTable& operator=(const TeTable&);

// -- Methods

	//! Returns the table name
	const string& name() const
	{ return name_; }

  //! Returns the table name
	string name()
	{ return name_; }

	//! Sets the table name
	void name(const string& n)
	{ name_ = n; }

	//! Returns the unique id of the table in a database
	int id() { return id_; }

	//! Sets the id of the table
	void setId(int n) { id_ = n; }

	//! Set the position of the table in a join
	void setOrder(int n) { order_ = n; }

	//! Get the position of the table in a join
	int getOrder() { return order_;}
	
	//! Defines the list of attributes of this table
	void setAttributeList ( const TeAttributeList& attList)
	{ attList_ = attList; }

	//! Retrieves the list of attributes of this table
	TeAttributeList& attributeList()
	{ return attList_; }

  //! Retrieves the list of attributes of this table
  const TeAttributeList& attributeList() const
	{ return attList_; }

	//! Retrieves the list of attribute names of this table
	bool attributeNames(vector<string>& attrs);
	
	//! Returns the type of this attribute table
	TeAttrTableType tableType()
	{ return type_; }

	//! Sets the table separator
	void setSeparator ( const char& c )
	{ separator_ = c ; }

	//! Returns the table separator
	char separator ()
	{ return separator_; }

	//! Sets the table type
	/*!
      \param attType table type
	  \note In case of external tables
      \param relatedTableId is the id of the related table 
	  \param relatedAttribute is column name of the related table
	*/
	bool setTableType( TeAttrTableType attType, int relatedTableId=-1, const string& relatedAttribute="");

	//! Sets an attribute as the table index.
	/*!
		Index in this context, means an attribute that is a link between
		the attribute table and a spatial table (a table of geometrical
		representation of objects).
	*/
	void setLinkName ( const string& linkName ) { attLink_ = linkName;}

	//! Returns the name of the column used as link between the attribute table and a spatial table
	string linkName()
	{	return attLink_; }

	//! Sets the name of the column that has unique values
	void setUniqueName ( const string& uniqueName ) { attUnique_ = uniqueName; }	

	//! Returns the name of the column used as primary key
	string uniqueName()
	{	return attUnique_;	}

	//! If there is one, returns the attribute used as an index
	/*!
		\param att to return the attribute used as an index
		\return TRUE if there is an index, FALSE otherwise
	*/
	bool attrLink(TeAttribute& att);

	//! If there is one, returns the attribute used as primary key
	/*!
		\param attr to return the attribute used as primary key
		\return TRUE if there is an index, FALSE otherwise
	*/
	bool attrUnique(TeAttribute& attr);
	
	//! Returns the position of the link attribute in the attribute list
	int attrLinkPosition();

	//! Returns the position of the unique attribute in the attribute list
	int attrUniquePosition();

	/** @name External tables
	    The following members are used to manipulate information about tables that
		are external: don´t have a direct link to geometries, but can be linked by
		a column to another attribute table
	*/
	//@{
	//! Sets the  id of a table to which this is related (only for TeAttrExternal tables)
	void relatedTableId(int id)
	{   relatedTableId_ = id; }

	//! Returns the id of a related table (only for TeAttrExternal tables)
	int relatedTableId()
	{   return relatedTableId_; }

	//! Sets the name of a table to which this is related (only for TeAttrExternal tables)
	void relatedTableName(string tableName)
	{   relatedTableName_ = tableName; }

	//! Returns the name of a related table (only for TeAttrExternal tables)
	string relatedTableName()
	{   return relatedTableName_; }

	//! Set the name of a column to link to a related table (only for TeAttrExternal tables)
	void relatedAttribute(const string& columnName)
	{	relatedAttribute_ = columnName; }

	//! Return the column that links to a related table (only for TeAttrExternal tables)
	string relatedAttribute()
	{ return relatedAttribute_; }

	//@}

	/** @name Temporal Attributes
	    The following members are used to manipulate the attribute tables with temporal
		information.
		\par Temporal tables contains columns to store a time interval in which the 
		 attributes (or a row) of an object is valid.
	*/
	//@{		

	//! Sets the name of the column that has the initial time of the validity interval
	void attInitialTime(const string& t)
	{	attInitialTime_ = t; }

	//! Returns the name of the column that has the initial time of the validity interval
	string attInitialTime()
	{	return attInitialTime_; }

	//! Sets the name of the column that has the final time of the validity interval
	void attFinalTime(const string& t)
	{	attFinalTime_ = t; }

	//! Returns the name of the column that has the final time of the validity interval
	string attFinalTime()
	{	return attFinalTime_; }

	//! Sets the time unit relative to the validity interval
	void attTimeUnit(TeChronon t)
	{	attTimeUnit_ = t; }

	//! Returns the time unit relative to the validity interval
	TeChronon attTimeUnit()
	{	return attTimeUnit_; }
	//@}

	/** @name Data in Memory
	    The following members are used to manipulate rows of the table in memory
	*/
	//@{
	//! Add a row to a table
	void add ( const TeTableRow& row );

	//! Returns the i-th row
	TeTableRow operator [] ( int row ) const;

	//! Returns the element indexed by (row,col)
	string operator () ( int row, int col );

	//! Sets the value of a cell indexed by row x col to value val
	void setValue (int row, int col, string& val);

	//! Returns the number of rows in a table
	unsigned int size () const;

	//! Clears the table storage in memory
	void clear ();
	//@}

	//! Returns the primary key names of the table 
	void primaryKeys(vector<string>& keys);

private:
	
	int					id_;	// unique id from a database where this table may be stored
	string				name_;	// name
	TeAttrTableType		type_;	// type of table
	int					order_; // the table position relative to others in a join 

	TeAttributeList		attList_;		// list of attributes
	string				attLink_;		// attribute that links objects to their spatial representation
										// in case of external table it is used to link to the related table
	string				attUnique_;		// primary key 
	char                separator_;		// in case of CSV table 

// --- The following attributes are relative to tables with temporal information
 
	string		attInitialTime_;	// initial time attribute
	string		attFinalTime_;		// final time attribute
	TeChronon	attTimeUnit_;		// time granularity

// --- The following attributes are relative to external tables
 	int		relatedTableId_;	// id of a table to which this is related	
 	string	relatedTableName_;	// name of a table to which this is related	
	string  relatedAttribute_;	// column name of table which this is related

// -- Table Implementation
	TeTableImpl* pImpl_;		// the rows of a table

};

//! A vector of tables
typedef vector<TeTable> TeAttrTableVector;

//! Return the sql join related with the table vector  
TL_DLL string tableJoin(TeAttrTableVector& vecTable, string firstTable="", string attrLink=""); 

/*! \example createTable.cpp
	Shows how to execute some operations relative to attribute tables.
 */

#endif