SAGA API  v9.7
table.h
Go to the documentation of this file.
1 
3 // //
4 // SAGA //
5 // //
6 // System for Automated Geoscientific Analyses //
7 // //
8 // Application Programming Interface //
9 // //
10 // Library: SAGA_API //
11 // //
12 //-------------------------------------------------------//
13 // //
14 // table.h //
15 // //
16 // Copyright (C) 2005 by Olaf Conrad //
17 // //
18 //-------------------------------------------------------//
19 // //
20 // This file is part of 'SAGA - System for Automated //
21 // Geoscientific Analyses'. //
22 // //
23 // This library is free software; you can redistribute //
24 // it and/or modify it under the terms of the GNU Lesser //
25 // General Public License as published by the Free //
26 // Software Foundation, either version 2.1 of the //
27 // License, or (at your option) any later version. //
28 // //
29 // This library is distributed in the hope that it will //
30 // be useful, but WITHOUT ANY WARRANTY; without even the //
31 // implied warranty of MERCHANTABILITY or FITNESS FOR A //
32 // PARTICULAR PURPOSE. See the GNU Lesser General Public //
33 // License for more details. //
34 // //
35 // You should have received a copy of the GNU Lesser //
36 // General Public License along with this program; if //
37 // not, see <http://www.gnu.org/licenses/>. //
38 // //
39 //-------------------------------------------------------//
40 // //
41 // contact: Olaf Conrad //
42 // Institute of Geography //
43 // University of Goettingen //
44 // Goldschmidtstr. 5 //
45 // 37077 Goettingen //
46 // Germany //
47 // //
48 // e-mail: oconrad@saga-gis.org //
49 // //
51 
52 //---------------------------------------------------------
53 #ifndef HEADER_INCLUDED__SAGA_API__table_H
54 #define HEADER_INCLUDED__SAGA_API__table_H
55 
56 
58 // //
59 // //
60 // //
62 
63 //---------------------------------------------------------
74 // //
76 // //
77 // //
79 
80 //---------------------------------------------------------
81 #include "dataobject.h"
82 #include "table_value.h"
83 
84 
86 // //
87 // //
88 // //
90 
91 //---------------------------------------------------------
92 typedef enum
93 {
98 }
100 
101 //---------------------------------------------------------
102 typedef enum
103 {
107 }
109 
110 
112 // //
113 // //
114 // //
116 
117 //---------------------------------------------------------
118 #define SG_TABLE_REC_FLAG_Modified 0x01
119 #define SG_TABLE_REC_FLAG_Selected 0x02
120 
121 
123 // //
124 // //
125 // //
127 
128 //---------------------------------------------------------
130 {
131  friend class CSG_Table; friend class CSG_PointCloud;
132 
133 public:
134 
135  class CSG_Table * Get_Table (void) { return( m_pTable ); }
136  sLong Get_Index (void) const { return( m_Index ); }
137 
138  virtual bool is_Valid (void) const { return( true ); }
139 
140  bool Set_Value (int Field, const CSG_String &Value);
141  bool Set_Value (int Field, const char *Value) { return( Set_Value( Field , CSG_String(Value)) ); }
142  bool Set_Value (int Field, const wchar_t *Value) { return( Set_Value( Field , CSG_String(Value)) ); }
143  bool Set_Value (const CSG_String &Field, const CSG_String &Value);
144  bool Set_Value (const char *Field, const CSG_String &Value) { return( Set_Value(CSG_String(Field), Value ) ); }
145  bool Set_Value (const wchar_t *Field, const CSG_String &Value) { return( Set_Value(CSG_String(Field), Value ) ); }
146  bool Set_Value (const char *Field, const char *Value) { return( Set_Value(CSG_String(Field), CSG_String(Value)) ); }
147  bool Set_Value (const wchar_t *Field, const wchar_t *Value) { return( Set_Value(CSG_String(Field), CSG_String(Value)) ); }
148 
149  bool Set_Value (int Field, const CSG_Bytes &Value);
150  bool Set_Value (const CSG_String &Field, const CSG_Bytes &Value);
151  bool Set_Value (const char *Field, const CSG_Bytes &Value) { return( Set_Value(CSG_String(Field), Value) ); }
152  bool Set_Value (const wchar_t *Field, const CSG_Bytes &Value) { return( Set_Value(CSG_String(Field), Value) ); }
153 
154  bool Set_Value (int Field, double Value);
155  bool Set_Value (const CSG_String &Field, double Value);
156  bool Set_Value (const char *Field, double Value) { return( Set_Value(CSG_String(Field), Value) ); }
157  bool Set_Value (const wchar_t *Field, double Value) { return( Set_Value(CSG_String(Field), Value) ); }
158 
159  bool Set_Value (int Field, sLong Value);
160  bool Set_Value (const CSG_String &Field, sLong Value);
161  bool Set_Value (const char *Field, sLong Value) { return( Set_Value(CSG_String(Field), Value) ); }
162  bool Set_Value (const wchar_t *Field, sLong Value) { return( Set_Value(CSG_String(Field), Value) ); }
163 
164  bool Set_Value (int Field, size_t Value) { return( Set_Value(Field, (double)Value) ); }
165  bool Set_Value (const CSG_String &Field, size_t Value) { return( Set_Value(Field, (double)Value) ); }
166  bool Set_Value (const char *Field, size_t Value) { return( Set_Value(Field, (double)Value) ); }
167  bool Set_Value (const wchar_t *Field, size_t Value) { return( Set_Value(Field, (double)Value) ); }
168 
169  bool Set_Value (int Field, DWORD Value) { return( Set_Value(Field, (double)Value) ); }
170  bool Set_Value (const CSG_String &Field, DWORD Value) { return( Set_Value(Field, (double)Value) ); }
171  bool Set_Value (const char *Field, DWORD Value) { return( Set_Value(Field, (double)Value) ); }
172  bool Set_Value (const wchar_t *Field, DWORD Value) { return( Set_Value(Field, (double)Value) ); }
173 
174  bool Set_Value (int Field, long Value) { return( Set_Value(Field, (double)Value) ); }
175  bool Set_Value (const CSG_String &Field, long Value) { return( Set_Value(Field, (double)Value) ); }
176  bool Set_Value (const char *Field, long Value) { return( Set_Value(Field, (double)Value) ); }
177  bool Set_Value (const wchar_t *Field, long Value) { return( Set_Value(Field, (double)Value) ); }
178 
179  bool Set_Value (int Field, int Value) { return( Set_Value(Field, (double)Value) ); }
180  bool Set_Value (const CSG_String &Field, int Value) { return( Set_Value(Field, (double)Value) ); }
181  bool Set_Value (const char *Field, int Value) { return( Set_Value(Field, (double)Value) ); }
182  bool Set_Value (const wchar_t *Field, int Value) { return( Set_Value(Field, (double)Value) ); }
183 
184  bool Add_Value (int Field, double Value);
185  bool Add_Value (const CSG_String &Field, double Value);
186  bool Add_Value (const char *Field, double Value) { return( Add_Value(CSG_String(Field), Value) ); }
187  bool Add_Value (const wchar_t *Field, double Value) { return( Add_Value(CSG_String(Field), Value) ); }
188 
189  bool Mul_Value (int Field, double Value);
190  bool Mul_Value (const CSG_String &Field, double Value);
191  bool Mul_Value (const char *Field, double Value) { return( Mul_Value(CSG_String(Field), Value) ); }
192  bool Mul_Value (const wchar_t *Field, double Value) { return( Mul_Value(CSG_String(Field), Value) ); }
193 
194  bool Set_NoData (int Field);
195  bool Set_NoData (const CSG_String &Field);
196  bool Set_NoData (const char *Field) { return( Set_NoData(CSG_String(Field)) ); }
197  bool Set_NoData (const wchar_t *Field) { return( Set_NoData(CSG_String(Field)) ); }
198 
199  bool is_NoData (int Field) const;
200  bool is_NoData (const CSG_String &Field) const;
201  bool is_NoData (const char *Field) const { return( is_NoData(CSG_String(Field)) ); }
202  bool is_NoData (const wchar_t *Field) const { return( is_NoData(CSG_String(Field)) ); }
203 
204  const SG_Char * asString (int Field, int Decimals = -99) const;
205  const SG_Char * asString (const CSG_String &Field, int Decimals = -99) const;
206  const SG_Char * asString (const char *Field, int Decimals = -99) const { return( asString(CSG_String(Field), Decimals) ); }
207  const SG_Char * asString (const wchar_t *Field, int Decimals = -99) const { return( asString(CSG_String(Field), Decimals) ); }
208 
209  SG_Char asChar (int Field) const;
210  SG_Char asChar (const CSG_String &Field) const;
211  SG_Char asChar (const char *Field) const { return( asChar (CSG_String(Field)) ); }
212  SG_Char asChar (const wchar_t *Field) const { return( asChar (CSG_String(Field)) ); }
213 
214  short asShort (int Field) const;
215  short asShort (const CSG_String &Field) const;
216  short asShort (const char *Field) const { return( asShort (CSG_String(Field)) ); }
217  short asShort (const wchar_t *Field) const { return( asShort (CSG_String(Field)) ); }
218 
219  int asInt (int Field) const;
220  int asInt (const CSG_String &Field) const;
221  int asInt (const char *Field) const { return( asInt (CSG_String(Field)) ); }
222  int asInt (const wchar_t *Field) const { return( asInt (CSG_String(Field)) ); }
223 
224  sLong asLong (int Field) const;
225  sLong asLong (const CSG_String &Field) const;
226  sLong asLong (const char *Field) const { return( asLong (CSG_String(Field)) ); }
227  sLong asLong (const wchar_t *Field) const { return( asLong (CSG_String(Field)) ); }
228 
229  float asFloat (int iField) const;
230  float asFloat (const CSG_String &Field) const;
231  float asFloat (const char *Field) const { return( asFloat (CSG_String(Field)) ); }
232  float asFloat (const wchar_t *Field) const { return( asFloat (CSG_String(Field)) ); }
233 
234  double asDouble (int Field) const;
235  double asDouble (const CSG_String &Field) const;
236  double asDouble (const char *Field) const { return( asDouble(CSG_String(Field)) ); }
237  double asDouble (const wchar_t *Field) const { return( asDouble(CSG_String(Field)) ); }
238 
239  CSG_Table_Value * Get_Value (int Field) { return( m_Values[Field] ); }
240  CSG_Table_Value & operator [] (int Field) const { return( *m_Values[Field] ); }
241 
242  virtual bool Assign (CSG_Table_Record *pRecord);
243 
244  bool is_Selected (void) const { return( (m_Flags & SG_TABLE_REC_FLAG_Selected) != 0 ); }
245  bool is_Modified (void) const { return( (m_Flags & SG_TABLE_REC_FLAG_Modified) != 0 ); }
246 
247 
248 protected:
249 
250  CSG_Table_Record(class CSG_Table *pTable, sLong Index);
251  virtual ~CSG_Table_Record(void);
252 
253 
254  char m_Flags;
255 
257 
259 
261 
262 
263  void Set_Selected (bool bOn = true);
264  void Set_Modified (bool bOn = true);
265 
266 
267  static CSG_Table_Value * _Create_Value (TSG_Data_Type Type);
268 
269  bool _Add_Field (int add_Field);
270  bool _Del_Field (int del_Field);
271 
272  int _Get_Field (const CSG_String &Field) const;
273 
274 };
275 
276 
278 // //
279 // //
280 // //
282 
283 //---------------------------------------------------------
285 {
286  friend class CSG_Table_Record;
287  friend class CSG_TIN;
288 
289 public:
290 
291  CSG_Table (void);
292  bool Create (void);
293 
294  CSG_Table (const CSG_Table &Table);
295  bool Create (const CSG_Table &Table);
296 
297  CSG_Table (const CSG_Table *pTemplate);
298  bool Create (const CSG_Table *pTemplate);
299 
301  bool Create (const CSG_String &File, TSG_Table_File_Type Format = TABLE_FILETYPE_Undefined, int Encoding = SG_FILE_ENCODING_UNDEFINED);
302  CSG_Table (const char *File, TSG_Table_File_Type Format = TABLE_FILETYPE_Undefined, int Encoding = SG_FILE_ENCODING_UNDEFINED);
303  bool Create (const char *File, TSG_Table_File_Type Format = TABLE_FILETYPE_Undefined, int Encoding = SG_FILE_ENCODING_UNDEFINED);
304  CSG_Table (const wchar_t *File, TSG_Table_File_Type Format = TABLE_FILETYPE_Undefined, int Encoding = SG_FILE_ENCODING_UNDEFINED);
305  bool Create (const wchar_t *File, TSG_Table_File_Type Format = TABLE_FILETYPE_Undefined, int Encoding = SG_FILE_ENCODING_UNDEFINED);
306 
307  CSG_Table (const CSG_String &File, TSG_Table_File_Type Format, const SG_Char Separator , int Encoding = SG_FILE_ENCODING_UNDEFINED);
308  bool Create (const CSG_String &File, TSG_Table_File_Type Format, const SG_Char Separator , int Encoding = SG_FILE_ENCODING_UNDEFINED);
309  CSG_Table (const char *File, TSG_Table_File_Type Format, const SG_Char Separator , int Encoding = SG_FILE_ENCODING_UNDEFINED);
310  bool Create (const char *File, TSG_Table_File_Type Format, const SG_Char Separator , int Encoding = SG_FILE_ENCODING_UNDEFINED);
311  CSG_Table (const wchar_t *File, TSG_Table_File_Type Format, const SG_Char Separator , int Encoding = SG_FILE_ENCODING_UNDEFINED);
312  bool Create (const wchar_t *File, TSG_Table_File_Type Format, const SG_Char Separator , int Encoding = SG_FILE_ENCODING_UNDEFINED);
313 
314  virtual ~CSG_Table(void);
315 
316  virtual bool Destroy (void);
317 
319 
320  CSG_Table & operator = (const CSG_Table &Table);
321  virtual bool Assign (CSG_Data_Object *pTable);
322 
323  bool Assign_Values (const CSG_Table &Table);
324  bool Assign_Values ( CSG_Table *pTable);
325  bool Assign_Values (const SG_Char *File);
326 
327  bool Load (const CSG_String &File, int Format, SG_Char Separator, int Encoding = SG_FILE_ENCODING_UNDEFINED);
328 
329  virtual bool Save (const CSG_String &File, int Format, SG_Char Separator, int Encoding = SG_FILE_ENCODING_UNDEFINED);
330  virtual bool Save (const char *File, int Format, SG_Char Separator, int Encoding = SG_FILE_ENCODING_UNDEFINED) { return( Save(CSG_String(File), Format, Separator, Encoding) ); }
331  virtual bool Save (const wchar_t *File, int Format, SG_Char Separator, int Encoding = SG_FILE_ENCODING_UNDEFINED) { return( Save(CSG_String(File), Format, Separator, Encoding) ); }
332 
333  virtual bool Save (const CSG_String &File, int Format = 0);
334  virtual bool Save (const char *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
335  virtual bool Save (const wchar_t *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
336 
337  bool Set_File_Encoding (int Encoding);
338  int Get_File_Encoding (void) const { return( m_Encoding ); }
339 
340  bool from_Text (const CSG_String &Text);
341  CSG_String to_Text (bool Selection = false) const;
342 
343  bool Serialize (CSG_File &Stream, bool bSave);
344 
345  //-----------------------------------------------------
346  virtual bool is_Valid (void) const { return( m_nFields > 0 ); }
347 
348  bool is_Compatible (const CSG_Table &Table, bool bExactMatch = false) const;
349  bool is_Compatible ( CSG_Table *pTable, bool bExactMatch = false) const;
350 
351  //-----------------------------------------------------
352  virtual const CSG_Rect & Get_Extent (void) { return( m_Extent ); }
353 
354  //-----------------------------------------------------
355  virtual bool Add_Field (const CSG_String &Name, TSG_Data_Type Type, int Position = -1);
356  virtual bool Add_Field (const char *Name, TSG_Data_Type Type, int Position = -1) { return( Add_Field(CSG_String(Name), Type, Position) ); }
357  virtual bool Add_Field (const wchar_t *Name, TSG_Data_Type Type, int Position = -1) { return( Add_Field(CSG_String(Name), Type, Position) ); }
358  virtual bool Del_Field (int iField);
359  virtual bool Mov_Field (int iField, int Position);
360 
361  int Get_Field_Count (void) const { return( m_nFields ); }
362  const SG_Char * Get_Field_Name (int iField) const { return( iField >= 0 && iField < m_nFields ? m_Field_Name[iField]->c_str() : NULL ); }
363  TSG_Data_Type Get_Field_Type (int iField) const { return( iField >= 0 && iField < m_nFields ? m_Field_Type[iField] : SG_DATATYPE_Undefined ); }
364  int Get_Field_Length (int iField, int Encoding = SG_FILE_ENCODING_UNDEFINED) const; // returns the maximum number of characters for data type string and zero for all other data types.
365  int Get_Field (const CSG_String &Name) const; // returns the zero based position of the field named 'Name' or '-1' if there is no field with such name.
366  int Get_Field (const char *Name) const; // returns the zero based position of the field named 'Name' or '-1' if there is no field with such name.
367  int Get_Field (const wchar_t *Name) const; // returns the zero based position of the field named 'Name' or '-1' if there is no field with such name.
368 
369  bool Set_Field_Name (int iField, const SG_Char *Name);
370  virtual bool Set_Field_Type (int iField, TSG_Data_Type Type);
371 
372  int Find_Field (const CSG_String &Name ) const;
373  int Find_Field (const char *Name ) const { return( Find_Field(CSG_String(Name)) ); }
374  int Find_Field (const wchar_t *Name ) const { return( Find_Field(CSG_String(Name)) ); }
375  bool Find_Field (const CSG_String &Name, int &Index) const;
376  bool Find_Field (const char *Name, int &Index) const { return( Find_Field(CSG_String(Name)) ); }
377  bool Find_Field (const wchar_t *Name, int &Index) const { return( Find_Field(CSG_String(Name)) ); }
378 
379  sLong Get_N (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_Count () : 0 ); }
380  double Get_Minimum (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_Minimum () : 0. ); }
381  double Get_Maximum (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_Maximum () : 0. ); }
382  double Get_Range (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_Range () : 0. ); }
383  double Get_Sum (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_Sum () : 0. ); }
384  double Get_Mean (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_Mean () : 0. ); }
385  double Get_StdDev (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_StdDev () : 0. ); }
386  double Get_Variance (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_Variance() : 0. ); }
387  const CSG_Simple_Statistics & Get_Statistics (int iField) const { _Stats_Update(iField); return( *m_Field_Stats[iField] ); }
388 
389  //-----------------------------------------------------
390  virtual CSG_Table_Record * Add_Record ( CSG_Table_Record *pCopy = NULL);
391  virtual CSG_Table_Record * Ins_Record (sLong Index, CSG_Table_Record *pCopy = NULL);
392  virtual bool Set_Record (sLong Index, CSG_Table_Record *pCopy );
393  virtual bool Del_Record (sLong Index);
394  virtual bool Del_Records (void);
395 
396  virtual bool Set_Count (sLong nRecords);
397  sLong Get_Count (void) const { return( m_nRecords ); }
398 
399  virtual CSG_Table_Record * Get_Record (sLong Index) const { return( Index >= 0 && Index < m_nRecords ? m_Records[Index] : NULL ); }
400  virtual CSG_Table_Record & operator [] (sLong Index) const { return( *Get_Record_byIndex(Index) ); }
401 
402  sLong Get_Index (sLong Index) const { return( Index >= 0 && Index < m_nRecords ? (is_Indexed() ? m_Index[Index] : Index) : -1 ); }
403 
405  {
406  return( Index >= 0 && Index < m_nRecords ? Get_Record(is_Indexed() ? m_Index[Index] : Index) : NULL );
407  }
408 
409  //-----------------------------------------------------
410  virtual bool Find_Record (sLong &Index, int iField, const CSG_String &Value, bool bCreateIndex = false);
411  virtual CSG_Table_Record * Find_Record ( int iField, const CSG_String &Value, bool bCreateIndex = false);
412  virtual bool Find_Record (sLong &Index, int iField, double Value, bool bCreateIndex = false);
413  virtual CSG_Table_Record * Find_Record ( int iField, double Value, bool bCreateIndex = false);
414 
415  //-----------------------------------------------------
416  virtual bool Set_Value (sLong Index, int iField, const SG_Char *Value);
417  virtual bool Set_Value (sLong Index, int iField, double Value);
418 
419  virtual bool Get_Value (sLong Index, int iField, CSG_String &Value) const;
420  virtual bool Get_Value (sLong Index, int iField, double &Value) const;
421 
422  virtual void Set_Modified (bool bModified = true);
423 
424  //-----------------------------------------------------
425  sLong Get_Selection_Count (void) const { return( m_Selection.Get_Size() ); }
426  sLong Get_Selection_Index (sLong Index = 0) const { return( Index >= 0 && Index < m_Selection.Get_Size() ? *((sLong *)m_Selection.Get_Entry(Index)) : Get_Count() ); }
427  virtual CSG_Table_Record * Get_Selection (sLong Index = 0) const { return( Index >= 0 && Index < m_Selection.Get_Size() ? Get_Record(Get_Selection_Index(Index)) : NULL ); }
428 
429  virtual bool is_Selected (sLong Index) const { return( Index >= 0 && Index < m_nRecords ? m_Records[Index]->is_Selected() : false ); }
430 
431  virtual bool Select (sLong Index , bool bInvert = false);
432  virtual bool Select (CSG_Table_Record *pRecord = NULL, bool bInvert = false);
433 
434  virtual sLong Del_Selection (void);
435  virtual sLong Inv_Selection (void);
436 
437  //-----------------------------------------------------
438  bool Sort (const char *Field, bool bAscending = true);
439  bool Sort (const wchar_t *Field, bool bAscending = true);
440  bool Sort (const CSG_String &Field, bool bAscending = true);
441  bool Sort (int Field, bool bAscending = true);
442  virtual bool Sort (const CSG_Index &Index);
443 
444  bool Set_Index (CSG_Index &Index, int Field , bool bAscending = true) const;
445  bool Set_Index (CSG_Index &Index, int Fields[], int nFields, bool bAscending = true) const;
446  bool Set_Index (CSG_Index &Index, const CSG_Array_Int &Fields, bool bAscending = true) const;
447 
448  bool Set_Index (int Field, TSG_Table_Index_Order Order = TABLE_INDEX_Ascending, int Field_2 = -1, TSG_Table_Index_Order Order_2 = TABLE_INDEX_None, int Field_3 = -1, TSG_Table_Index_Order Order_3 = TABLE_INDEX_None);
449  bool Del_Index (void);
450  bool Toggle_Index (int iField);
451  bool is_Indexed (void) const { return( m_nRecords > 0 && m_nRecords == m_Index.Get_Count() ); }
452  int Get_Index_Field (int i) const { return( i < 0 || i >= m_Index_Fields.Get_Size() ? -1 : abs(m_Index_Fields[i]) - 1 ); }
453  TSG_Table_Index_Order Get_Index_Order (int i) const { return( i < 0 || i >= m_Index_Fields.Get_Size() ? TABLE_INDEX_None : m_Index_Fields[i] > 0 ? TABLE_INDEX_Ascending : TABLE_INDEX_Descending ); }
454  int Get_Index_Field (size_t i) const { return( Get_Index_Field((int)i) ); }
455  TSG_Table_Index_Order Get_Index_Order (size_t i) const { return( Get_Index_Order((int)i) ); }
456 
457 
458 protected:
459 
461 
463 
465 
467 
469 
471 
473 
474 
475  virtual void _On_Construction (void);
476 
477  virtual CSG_Table_Record * _Get_New_Record (sLong Index);
478 
479  bool _Add_Selection (sLong Index);
480  bool _Set_Selection (sLong Index, sLong Selected);
481  bool _Del_Selection (sLong Index);
482 
483  bool _Stats_Invalidate (void) const;
484  bool _Stats_Invalidate (int iField) const;
485  virtual bool _Stats_Update (int iField) const;
486 
487  bool _Save_Text (const CSG_String &File, bool bHeadline, const SG_Char Separator);
488  bool _Save_DBase (const CSG_String &File);
489 
490  virtual bool On_NoData_Changed (void);
491  virtual bool On_Update (void);
492 
493  virtual bool On_Reload (void);
494  virtual bool On_Delete (void);
495 
496 
497 private:
498 
499  CSG_Index m_Index;
500 
501  CSG_Array_Int m_Index_Fields;
502 
503  CSG_Table_Record **m_Records;
504 
505 
506  bool _Destroy_Selection (void);
507 
508  bool _Inc_Array (void);
509  bool _Dec_Array (void);
510 
511  size_t _Load_Text_Trim ( CSG_String &Text, const SG_Char Separator);
512  size_t _Load_Text_EndQuote (const CSG_String &Text, const SG_Char Separator);
513 
514  bool _Load_Text (const CSG_String &File, bool bHeadline, const SG_Char Separator);
515  bool _Load_DBase (const CSG_String &File);
516 
517  void _Index_Update (void);
518 
519 };
520 
521 
523 // //
524 // //
525 // //
527 
528 //---------------------------------------------------------
531 
534 
537 
544 
546 SAGA_API_DLL_EXPORT CSG_Table * SG_Create_Table (const char *File, TSG_Table_File_Type Format, const SG_Char Separator , int Encoding = SG_FILE_ENCODING_UNDEFINED);
548 SAGA_API_DLL_EXPORT CSG_Table * SG_Create_Table (const wchar_t *File, TSG_Table_File_Type Format, const SG_Char Separator , int Encoding = SG_FILE_ENCODING_UNDEFINED);
550 SAGA_API_DLL_EXPORT CSG_Table * SG_Create_Table (const CSG_String &File, TSG_Table_File_Type Format, const SG_Char Separator , int Encoding = SG_FILE_ENCODING_UNDEFINED);
551 
552 
554 // //
555 // //
556 // //
558 
559 //---------------------------------------------------------
560 #endif // #ifndef HEADER_INCLUDED__SAGA_API__table_H
CSG_Index
Definition: mat_tools.h:200
CSG_Table_Record::Set_Value
bool Set_Value(const char *Field, size_t Value)
Definition: table.h:166
CSG_Table::CSG_Table_Record
friend class CSG_Table_Record
Definition: table.h:286
CSG_Rect
Definition: geo_tools.h:474
CSG_Table::Find_Record
virtual bool Find_Record(sLong &Index, int iField, const CSG_String &Value, bool bCreateIndex=false)
Definition: table.cpp:939
CSG_Data_Object::Assign
virtual bool Assign(CSG_Data_Object *pObject)
Definition: dataobject.cpp:797
CSG_Table::Assign
virtual bool Assign(CSG_Data_Object *pTable)
Definition: table.cpp:370
CSG_Table_Record::Set_Value
bool Set_Value(int Field, long Value)
Definition: table.h:174
SG_DATATYPE_Undefined
@ SG_DATATYPE_Undefined
Definition: api_core.h:1010
CSG_Table::is_Valid
virtual bool is_Valid(void) const
Definition: table.h:346
table_value.h
CSG_Table::Set_Count
virtual bool Set_Count(sLong nRecords)
Definition: table.cpp:919
CSG_Table::Save
virtual bool Save(const wchar_t *File, int Format=0)
Definition: table.h:335
CSG_Table::Del_Records
virtual bool Del_Records(void)
Definition: table.cpp:901
CSG_Table::Get_Index
sLong Get_Index(sLong Index) const
Definition: table.h:402
CSG_Array::Get_Size
sLong Get_Size(void) const
Definition: api_core.h:327
CSG_Data_Object::On_Reload
virtual bool On_Reload(void)=0
CSG_Table_Record::Set_Value
bool Set_Value(const char *Field, int Value)
Definition: table.h:181
CSG_Data_Object::On_Delete
virtual bool On_Delete(void)=0
TABLE_INDEX_None
@ TABLE_INDEX_None
Definition: table.h:104
CSG_Table_Record::is_Valid
virtual bool is_Valid(void) const
Definition: table.h:138
TABLE_FILETYPE_DBase
@ TABLE_FILETYPE_DBase
Definition: table.h:97
CSG_Table_Record::Set_Value
bool Set_Value(const char *Field, const CSG_String &Value)
Definition: table.h:144
CSG_Table_Record
Definition: table.h:130
CSG_Table::_Stats_Update
virtual bool _Stats_Update(int iField) const
Definition: table.cpp:1217
CSG_Table_Record::Set_Value
bool Set_Value(const wchar_t *Field, double Value)
Definition: table.h:157
CSG_Table::Get_ObjectType
virtual TSG_Data_Object_Type Get_ObjectType(void) const
Returns the object type as defined by TSG_Data_Object_Type. Used for run time type checking.
Definition: table.h:318
CSG_Table::Inv_Selection
virtual sLong Inv_Selection(void)
Definition: table_selection.cpp:203
CSG_Table_Record::m_pTable
class CSG_Table * m_pTable
Definition: table.h:260
CSG_Table::Get_Value
virtual bool Get_Value(sLong Index, int iField, CSG_String &Value) const
Definition: table.cpp:1150
CSG_Table::m_Selection
CSG_Array m_Selection
Definition: table.h:470
CSG_Table_Record::Set_Value
bool Set_Value(int Field, const wchar_t *Value)
Definition: table.h:142
CSG_Table::is_Selected
virtual bool is_Selected(sLong Index) const
Definition: table.h:429
CSG_Table::Del_Field
virtual bool Del_Field(int iField)
Definition: table.cpp:513
CSG_Table::Get_Record
virtual CSG_Table_Record * Get_Record(sLong Index) const
Definition: table.h:399
CSG_Table_Record::Set_Value
bool Set_Value(const char *Field, DWORD Value)
Definition: table.h:171
SG_TABLE_REC_FLAG_Selected
#define SG_TABLE_REC_FLAG_Selected
Definition: table.h:119
CSG_Table::m_Field_Name
CSG_String ** m_Field_Name
Definition: table.h:466
CSG_Table_Record::asChar
SG_Char asChar(const char *Field) const
Definition: table.h:211
CSG_Table::Find_Field
bool Find_Field(const wchar_t *Name, int &Index) const
Definition: table.h:377
CSG_Table::operator=
CSG_Table & operator=(const CSG_Table &Table)
Definition: table.cpp:362
CSG_Table_Record::Mul_Value
bool Mul_Value(const char *Field, double Value)
Definition: table.h:191
CSG_Data_Object::Save
virtual bool Save(const CSG_String &File, int Format=0)=0
CSG_Table::Get_Selection
virtual CSG_Table_Record * Get_Selection(sLong Index=0) const
Definition: table.h:427
CSG_Table::~CSG_Table
virtual ~CSG_Table(void)
Definition: table.cpp:319
CSG_Table_Record::asLong
sLong asLong(const wchar_t *Field) const
Definition: table.h:227
CSG_Table_Record::Set_Value
bool Set_Value(const wchar_t *Field, DWORD Value)
Definition: table.h:172
CSG_Table_Record::asShort
short asShort(const char *Field) const
Definition: table.h:216
CSG_Table_Record::is_Selected
bool is_Selected(void) const
Definition: table.h:244
CSG_Table::CSG_Table
CSG_Table(void)
Definition: table.cpp:147
CSG_Table::Get_Index_Order
TSG_Table_Index_Order Get_Index_Order(int i) const
Definition: table.h:453
CSG_Table::Get_Field_Count
int Get_Field_Count(void) const
Definition: table.h:361
CSG_Table_Record::Set_Value
bool Set_Value(const wchar_t *Field, const CSG_String &Value)
Definition: table.h:145
CSG_Table_Record::asShort
short asShort(const wchar_t *Field) const
Definition: table.h:217
CSG_Table::m_Extent
CSG_Rect m_Extent
Definition: table.h:472
CSG_Table::Get_Field_Length
int Get_Field_Length(int iField, int Encoding=SG_FILE_ENCODING_UNDEFINED) const
Definition: table.cpp:652
CSG_Table_Record::m_Values
class CSG_Table_Value ** m_Values
Definition: table.h:258
CSG_Table::Set_Record
virtual bool Set_Record(sLong Index, CSG_Table_Record *pCopy)
Definition: table.cpp:851
CSG_Table_Value
Definition: table_value.h:111
CSG_Table::Find_Field
bool Find_Field(const char *Name, int &Index) const
Definition: table.h:376
TABLE_FILETYPE_Undefined
@ TABLE_FILETYPE_Undefined
Definition: table.h:94
CSG_Table::to_Text
CSG_String to_Text(bool Selection=false) const
Definition: table_io.cpp:653
CSG_Table_Record::Get_Table
class CSG_Table * Get_Table(void)
Definition: table.h:135
CSG_Table_Record::is_NoData
bool is_NoData(const char *Field) const
Definition: table.h:201
CSG_Table::operator[]
virtual CSG_Table_Record & operator[](sLong Index) const
Definition: table.h:400
CSG_Table_Record::m_Index
sLong m_Index
Definition: table.h:256
CSG_Table::Get_Index_Field
int Get_Index_Field(size_t i) const
Definition: table.h:454
CSG_File
Definition: api_core.h:1126
CSG_Table::Set_Modified
virtual void Set_Modified(bool bModified=true)
Definition: table.cpp:1106
CSG_Table::_Stats_Invalidate
bool _Stats_Invalidate(void) const
Definition: table.cpp:1193
CSG_Table::m_Field_Type
TSG_Data_Type * m_Field_Type
Definition: table.h:464
CSG_Table_Record::m_Flags
char m_Flags
Definition: table.h:254
CSG_Table::Save
virtual bool Save(const wchar_t *File, int Format, SG_Char Separator, int Encoding=SG_FILE_ENCODING_UNDEFINED)
Definition: table.h:331
CSG_Table::Get_Index_Order
TSG_Table_Index_Order Get_Index_Order(size_t i) const
Definition: table.h:455
CSG_Table::Get_StdDev
double Get_StdDev(int iField) const
Definition: table.h:385
CSG_Table::Add_Field
virtual bool Add_Field(const wchar_t *Name, TSG_Data_Type Type, int Position=-1)
Definition: table.h:357
CSG_Table::Find_Field
int Find_Field(const CSG_String &Name) const
Definition: table.cpp:706
CSG_Table_Record::Set_Value
bool Set_Value(const CSG_String &Field, DWORD Value)
Definition: table.h:170
CSG_Table_Record::Set_Value
bool Set_Value(const CSG_String &Field, int Value)
Definition: table.h:180
CSG_Table::is_Compatible
bool is_Compatible(const CSG_Table &Table, bool bExactMatch=false) const
Definition: table.cpp:423
CSG_Table_Record::Set_Value
bool Set_Value(const CSG_String &Field, size_t Value)
Definition: table.h:165
CSG_TIN
Definition: tin.h:222
CSG_Table_Record::asChar
SG_Char asChar(const wchar_t *Field) const
Definition: table.h:212
CSG_Table::m_Field_Stats
CSG_Simple_Statistics ** m_Field_Stats
Definition: table.h:468
CSG_Table_Record::Add_Value
bool Add_Value(const wchar_t *Field, double Value)
Definition: table.h:187
CSG_Table::Find_Field
int Find_Field(const char *Name) const
Definition: table.h:373
CSG_Table::Add_Field
virtual bool Add_Field(const char *Name, TSG_Data_Type Type, int Position=-1)
Definition: table.h:356
CSG_Data_Object
Definition: dataobject.h:180
CSG_Data_Object::On_NoData_Changed
virtual bool On_NoData_Changed(void)
Definition: dataobject.cpp:601
CSG_Table::Get_Field_Name
const SG_Char * Get_Field_Name(int iField) const
Definition: table.h:362
CSG_Table_Record::Set_Value
bool Set_Value(int Field, size_t Value)
Definition: table.h:164
SG_FILE_ENCODING_UNDEFINED
@ SG_FILE_ENCODING_UNDEFINED
Definition: api_core.h:557
CSG_Table::Set_File_Encoding
bool Set_File_Encoding(int Encoding)
Definition: table_io.cpp:81
CSG_Table::Get_Selection_Count
sLong Get_Selection_Count(void) const
Definition: table.h:425
CSG_Table::Serialize
bool Serialize(CSG_File &Stream, bool bSave)
Definition: table_io.cpp:685
CSG_Table::_Set_Selection
bool _Set_Selection(sLong Index, sLong Selected)
Definition: table_selection.cpp:74
CSG_Table_Record::Set_Value
bool Set_Value(const char *Field, sLong Value)
Definition: table.h:161
SG_TABLE_REC_FLAG_Modified
#define SG_TABLE_REC_FLAG_Modified
Definition: table.h:118
CSG_Table_Record::Set_Value
bool Set_Value(const char *Field, double Value)
Definition: table.h:156
CSG_Table_Record::asInt
int asInt(const char *Field) const
Definition: table.h:221
TSG_Table_Index_Order
TSG_Table_Index_Order
Definition: table.h:103
sLong
signed long long sLong
Definition: api_core.h:158
CSG_Table_Record::asFloat
float asFloat(const char *Field) const
Definition: table.h:231
CSG_Data_Object::On_Update
virtual bool On_Update(void)
Definition: dataobject.h:287
CSG_Table::is_Indexed
bool is_Indexed(void) const
Definition: table.h:451
CSG_Table_Record::Set_Value
bool Set_Value(const wchar_t *Field, long Value)
Definition: table.h:177
CSG_TIN::_On_Construction
void _On_Construction(void)
Definition: tin.cpp:138
CSG_Table::Get_N
sLong Get_N(int iField) const
Definition: table.h:379
CSG_Table::Mov_Field
virtual bool Mov_Field(int iField, int Position)
Definition: table.cpp:551
CSG_Table::Get_Count
sLong Get_Count(void) const
Definition: table.h:397
CSG_Table::Assign_Values
bool Assign_Values(const CSG_Table &Table)
Definition: table.cpp:388
CSG_Table_Record::Set_NoData
bool Set_NoData(const wchar_t *Field)
Definition: table.h:197
TABLE_FILETYPE_Text_NoHeadLine
@ TABLE_FILETYPE_Text_NoHeadLine
Definition: table.h:96
CSG_Array_Int
Definition: api_core.h:423
CSG_Table_Record::Set_Value
bool Set_Value(const wchar_t *Field, size_t Value)
Definition: table.h:167
CSG_Table_Record::Set_Value
bool Set_Value(int Field, int Value)
Definition: table.h:179
CSG_Table::Get_Index_Field
int Get_Index_Field(int i) const
Definition: table.h:452
CSG_Table::Get_Maximum
double Get_Maximum(int iField) const
Definition: table.h:381
CSG_Table::Del_Index
bool Del_Index(void)
Definition: table.cpp:1368
CSG_Table_Record::Set_Value
bool Set_Value(const char *Field, const CSG_Bytes &Value)
Definition: table.h:151
SAGA_API_DLL_EXPORT
#define SAGA_API_DLL_EXPORT
Definition: api_core.h:94
CSG_Table_Record::asLong
sLong asLong(const char *Field) const
Definition: table.h:226
CSG_Table::m_nBuffer
sLong m_nBuffer
Definition: table.h:462
CSG_Data_Object::Set_Modified
virtual void Set_Modified(bool bOn=true)
Definition: dataobject.h:227
CSG_Table::Set_Value
virtual bool Set_Value(sLong Index, int iField, const SG_Char *Value)
Definition: table.cpp:1124
CSG_Table::Get_Statistics
const CSG_Simple_Statistics & Get_Statistics(int iField) const
Definition: table.h:387
CSG_Table::Save
virtual bool Save(const char *File, int Format=0)
Definition: table.h:334
CSG_Table_Record::asDouble
double asDouble(const wchar_t *Field) const
Definition: table.h:237
dataobject.h
CSG_Table::Get_Record_byIndex
CSG_Table_Record * Get_Record_byIndex(sLong Index) const
Definition: table.h:404
CSG_Table_Record::is_NoData
bool is_NoData(const wchar_t *Field) const
Definition: table.h:202
CSG_Bytes
Definition: api_core.h:813
CSG_Table::m_Encoding
int m_Encoding
Definition: table.h:460
CSG_Table::Get_Extent
virtual const CSG_Rect & Get_Extent(void)
Definition: table.h:352
CSG_Table::_Del_Selection
bool _Del_Selection(sLong Index)
Definition: table_selection.cpp:87
CSG_Table::Get_Variance
double Get_Variance(int iField) const
Definition: table.h:386
CSG_Table_Record::asDouble
double asDouble(const char *Field) const
Definition: table.h:236
CSG_Table::Get_Sum
double Get_Sum(int iField) const
Definition: table.h:383
CSG_Table_Record::Set_Value
bool Set_Value(int Field, const char *Value)
Definition: table.h:141
CSG_Table::Set_Field_Name
bool Set_Field_Name(int iField, const SG_Char *Name)
Definition: table.cpp:604
CSG_Table::Add_Field
virtual bool Add_Field(const CSG_String &Name, TSG_Data_Type Type, int Position=-1)
Definition: table.cpp:474
CSG_Table
Definition: table.h:285
SG_Create_Table
SAGA_API_DLL_EXPORT CSG_Table * SG_Create_Table(void)
Definition: table.cpp:65
CSG_Table_Record::Set_Value
bool Set_Value(const wchar_t *Field, const CSG_Bytes &Value)
Definition: table.h:152
TABLE_INDEX_Descending
@ TABLE_INDEX_Descending
Definition: table.h:106
CSG_Table::_Save_DBase
bool _Save_DBase(const CSG_String &File)
Definition: table_io.cpp:560
CSG_Table_Record::asInt
int asInt(const wchar_t *Field) const
Definition: table.h:222
CSG_Table::_Add_Selection
bool _Add_Selection(sLong Index)
Definition: table_selection.cpp:63
CSG_Table_Record::Mul_Value
bool Mul_Value(const wchar_t *Field, double Value)
Definition: table.h:192
CSG_Table_Record::Add_Value
bool Add_Value(const char *Field, double Value)
Definition: table.h:186
CSG_Table_Record::Set_Value
bool Set_Value(const CSG_String &Field, long Value)
Definition: table.h:175
CSG_Table_Record::Set_Value
bool Set_Value(int Field, DWORD Value)
Definition: table.h:169
CSG_Table::Get_Mean
double Get_Mean(int iField) const
Definition: table.h:384
CSG_Table::Del_Record
virtual bool Del_Record(sLong Index)
Definition: table.cpp:862
SG_Char
#define SG_Char
Definition: api_core.h:536
CSG_Table::Load
bool Load(const CSG_String &File, int Format, SG_Char Separator, int Encoding=SG_FILE_ENCODING_UNDEFINED)
Definition: table_io.cpp:99
TSG_Data_Object_Type
TSG_Data_Object_Type
Definition: dataobject.h:117
CSG_Array
Definition: api_core.h:308
CSG_String
Definition: api_core.h:563
SG_DATAOBJECT_TYPE_Table
@ SG_DATAOBJECT_TYPE_Table
Definition: dataobject.h:120
CSG_Table::Get_Minimum
double Get_Minimum(int iField) const
Definition: table.h:380
CSG_Table_Record::Set_NoData
bool Set_NoData(const char *Field)
Definition: table.h:196
TSG_Table_File_Type
TSG_Table_File_Type
Definition: table.h:93
CSG_Table::from_Text
bool from_Text(const CSG_String &Text)
Definition: table_io.cpp:575
CSG_TIN::m_Extent
CSG_Rect m_Extent
Definition: tin.h:295
CSG_Table::Get_Selection_Index
sLong Get_Selection_Index(sLong Index=0) const
Definition: table.h:426
CSG_Table::m_nFields
int m_nFields
Definition: table.h:460
CSG_Table::Ins_Record
virtual CSG_Table_Record * Ins_Record(sLong Index, CSG_Table_Record *pCopy=NULL)
Definition: table.cpp:794
CSG_Table_Record::Set_Value
bool Set_Value(const char *Field, long Value)
Definition: table.h:176
CSG_Table_Record::asString
const SG_Char * asString(const char *Field, int Decimals=-99) const
Definition: table.h:206
CSG_Table_Record::Get_Index
sLong Get_Index(void) const
Definition: table.h:136
CSG_Table_Record::Set_Value
bool Set_Value(const char *Field, const char *Value)
Definition: table.h:146
TABLE_INDEX_Ascending
@ TABLE_INDEX_Ascending
Definition: table.h:105
CSG_Table::Get_Range
double Get_Range(int iField) const
Definition: table.h:382
CSG_Table::Create
bool Create(void)
Definition: table.cpp:153
CSG_TIN::_Get_New_Record
virtual CSG_Table_Record * _Get_New_Record(sLong Index)
Definition: tin.cpp:409
CSG_Table_Record::Get_Value
CSG_Table_Value * Get_Value(int Field)
Definition: table.h:239
CSG_PointCloud
Definition: pointcloud.h:105
CSG_Table::Save
virtual bool Save(const char *File, int Format, SG_Char Separator, int Encoding=SG_FILE_ENCODING_UNDEFINED)
Definition: table.h:330
CSG_Table_Record::Set_Value
bool Set_Value(const wchar_t *Field, sLong Value)
Definition: table.h:162
TABLE_FILETYPE_Text
@ TABLE_FILETYPE_Text
Definition: table.h:95
CSG_Table_Record::Set_Value
bool Set_Value(const wchar_t *Field, int Value)
Definition: table.h:182
TSG_Data_Type
TSG_Data_Type
Definition: api_core.h:994
CSG_Table::Select
virtual bool Select(sLong Index, bool bInvert=false)
Definition: table_selection.cpp:136
CSG_Table::Set_Index
bool Set_Index(CSG_Index &Index, int Field, bool bAscending=true) const
Definition: table.cpp:1457
CSG_Table::Get_Field_Type
TSG_Data_Type Get_Field_Type(int iField) const
Definition: table.h:363
CSG_Table::Add_Record
virtual CSG_Table_Record * Add_Record(CSG_Table_Record *pCopy=NULL)
Definition: table.cpp:788
CSG_Table::Sort
bool Sort(const char *Field, bool bAscending=true)
Definition: table.cpp:1301
CSG_Table_Record::Set_Value
bool Set_Value(const wchar_t *Field, const wchar_t *Value)
Definition: table.h:147
CSG_Table::Get_Field
int Get_Field(const CSG_String &Name) const
Definition: table.cpp:688
CSG_Table::Del_Selection
virtual sLong Del_Selection(void)
Definition: table_selection.cpp:178
CSG_Simple_Statistics
Definition: mat_tools.h:723
CSG_Table::Set_Field_Type
virtual bool Set_Field_Type(int iField, TSG_Data_Type Type)
Definition: table.cpp:619
CSG_Table_Record::is_Modified
bool is_Modified(void) const
Definition: table.h:245
CSG_Data_Object::Destroy
virtual bool Destroy(void)
Definition: dataobject.cpp:281
CSG_Table::_Save_Text
bool _Save_Text(const CSG_String &File, bool bHeadline, const SG_Char Separator)
Definition: table_io.cpp:490
CSG_Table_Record::asFloat
float asFloat(const wchar_t *Field) const
Definition: table.h:232
CSG_Table::Toggle_Index
bool Toggle_Index(int iField)
Definition: table.cpp:1378
CSG_Table_Record::asString
const SG_Char * asString(const wchar_t *Field, int Decimals=-99) const
Definition: table.h:207
CSG_Table::m_nRecords
sLong m_nRecords
Definition: table.h:462
CSG_Table::Find_Field
int Find_Field(const wchar_t *Name) const
Definition: table.h:374
CSG_Array::Get_Entry
void * Get_Entry(sLong Index) const
Returns a pointer to the memory address of the requested variable. You have to type cast and derefere...
Definition: api_core.h:331
CSG_Table::Get_File_Encoding
int Get_File_Encoding(void) const
Definition: table.h:338