SAGA API v9.10
Loading...
Searching...
No Matches
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//---------------------------------------------------------
72
73
75// //
76// //
77// //
79
80//---------------------------------------------------------
81#include "dataobject.h"
82#include "table_value.h"
83
84
86// //
87// //
88// //
90
91//---------------------------------------------------------
100
101//---------------------------------------------------------
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
133public:
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 Field) 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
248protected:
249
250 CSG_Table_Record(class CSG_Table *pTable, sLong Index);
251 virtual ~CSG_Table_Record(void);
252
253
255
257
259
261
262
263 void Set_Selected (bool bOn = true);
264 void Set_Modified (bool bOn = true);
265
266
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
289public:
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
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, bool bProgress = false);
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 Field);
359 virtual bool Mov_Field (int Field, int Position);
360
361 int Get_Field_Count (void) const { return( m_nFields ); }
362 const SG_Char * Get_Field_Name (int Field) const { return( Field >= 0 && Field < m_nFields ? m_Field_Info[Field]->m_Name.c_str() : NULL ); }
363 TSG_Data_Type Get_Field_Type (int Field) const { return( Field >= 0 && Field < m_nFields ? m_Field_Info[Field]->m_Type : SG_DATATYPE_Undefined ); }
364 bool is_Field_Numeric (int Field) const { return( SG_Data_Type_is_Numeric(Get_Field_Type(Field)) ); }
365 virtual int Get_Field_Length (int Field, int Encoding = SG_FILE_ENCODING_UNDEFINED) const;
366 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.
367 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.
368 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.
369
370 bool Set_Field_Name (int Field, const SG_Char *Name);
371 virtual bool Set_Field_Type (int Field, TSG_Data_Type Type);
372
373 int Find_Field (const CSG_String &Name ) const;
374 int Find_Field (const char *Name ) const { return( Find_Field(CSG_String(Name)) ); }
375 int Find_Field (const wchar_t *Name ) const { return( Find_Field(CSG_String(Name)) ); }
376 bool Find_Field (const CSG_String &Name, int &Index) const;
377 bool Find_Field (const char *Name, int &Index) const { return( Find_Field(CSG_String(Name)) ); }
378 bool Find_Field (const wchar_t *Name, int &Index) const { return( Find_Field(CSG_String(Name)) ); }
379
380 sLong Get_N (int Field) const { return( _Stats_Update(Field) ? m_Field_Info[Field]->m_Statistics.Get_Count () : 0 ); }
381 double Get_Minimum (int Field) const { return( _Stats_Update(Field) ? m_Field_Info[Field]->m_Statistics.Get_Minimum () : 0. ); }
382 double Get_Maximum (int Field) const { return( _Stats_Update(Field) ? m_Field_Info[Field]->m_Statistics.Get_Maximum () : 0. ); }
383 double Get_Range (int Field) const { return( _Stats_Update(Field) ? m_Field_Info[Field]->m_Statistics.Get_Range () : 0. ); }
384 double Get_Sum (int Field) const { return( _Stats_Update(Field) ? m_Field_Info[Field]->m_Statistics.Get_Sum () : 0. ); }
385 double Get_Mean (int Field) const { return( _Stats_Update(Field) ? m_Field_Info[Field]->m_Statistics.Get_Mean () : 0. ); }
386 double Get_StdDev (int Field) const { return( _Stats_Update(Field) ? m_Field_Info[Field]->m_Statistics.Get_StdDev () : 0. ); }
387 double Get_Variance (int Field) const { return( _Stats_Update(Field) ? m_Field_Info[Field]->m_Statistics.Get_Variance() : 0. ); }
388 const CSG_Simple_Statistics & Get_Statistics (int Field) const { _Stats_Update(Field); return( m_Field_Info[Field]->m_Statistics ); }
389
390 const CSG_Histogram & Get_Histogram (int Field, size_t nClasses = 0) const { _Histogram_Update(Field, nClasses); return( m_Field_Info[Field]->m_Histogram ); }
391
392 //-----------------------------------------------------
393 virtual CSG_Table_Record * Add_Record ( CSG_Table_Record *pCopy = NULL);
394 virtual CSG_Table_Record * Ins_Record (sLong Index, CSG_Table_Record *pCopy = NULL);
395 virtual bool Set_Record (sLong Index, CSG_Table_Record *pCopy );
396 virtual bool Del_Record (sLong Index);
397 virtual bool Del_Records (void);
398
399 virtual bool Set_Count (sLong nRecords);
400 sLong Get_Count (void) const { return( m_nRecords ); }
401
402 virtual CSG_Table_Record * Get_Record (sLong Index) const { return( Index >= 0 && Index < m_nRecords ? m_Records[Index] : NULL ); }
403 virtual CSG_Table_Record & operator [] (sLong Index) const { return( *Get_Record_byIndex(Index) ); }
404
405 sLong Get_Index (sLong Index) const { return( Index >= 0 && Index < m_nRecords ? (is_Indexed() ? m_Index[Index] : Index) : -1 ); }
406
408 {
409 return( Index >= 0 && Index < m_nRecords ? Get_Record(is_Indexed() ? m_Index[Index] : Index) : NULL );
410 }
411
412 //-----------------------------------------------------
413 virtual bool Find_Record (sLong &Index, int Field, const CSG_String &Value, bool bCreateIndex = false);
414 virtual CSG_Table_Record * Find_Record ( int Field, const CSG_String &Value, bool bCreateIndex = false);
415 virtual bool Find_Record (sLong &Index, int Field, double Value, bool bCreateIndex = false);
416 virtual CSG_Table_Record * Find_Record ( int Field, double Value, bool bCreateIndex = false);
417
418 //-----------------------------------------------------
419 virtual bool Set_Value (sLong Index, int Field, const SG_Char *Value);
420 virtual bool Set_Value (sLong Index, int Field, double Value);
421
422 virtual bool Get_Value (sLong Index, int Field, CSG_String &Value) const;
423 virtual bool Get_Value (sLong Index, int Field, double &Value) const;
424
425 virtual void Set_Modified (bool bModified = true);
426
427 //-----------------------------------------------------
428 sLong Get_Selection_Count (void) const { return( m_Selection.Get_Size() ); }
429 sLong Get_Selection_Index (sLong Index = 0) const { return( Index >= 0 && Index < m_Selection.Get_Size() ? *((sLong *)m_Selection.Get_Entry(Index)) : Get_Count() ); }
430 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 ); }
431
432 virtual bool is_Selected (sLong Index) const { return( Index >= 0 && Index < m_nRecords ? m_Records[Index]->is_Selected() : false ); }
433
434 virtual bool Select (sLong Index , bool bInvert = false);
435 virtual bool Select (CSG_Table_Record *pRecord = NULL, bool bInvert = false);
436
437 virtual sLong Del_Selection (void);
438 virtual sLong Inv_Selection (void);
439
440 //-----------------------------------------------------
441 bool Sort (const char *Field, bool bAscending = true);
442 bool Sort (const wchar_t *Field, bool bAscending = true);
443 bool Sort (const CSG_String &Field, bool bAscending = true);
444 bool Sort (int Field, bool bAscending = true);
445 virtual bool Sort (const CSG_Index &Index);
446
447 bool Set_Index (CSG_Index &Index, int Field , bool bAscending = true) const;
448 bool Set_Index (CSG_Index &Index, int Fields[], int nFields, bool bAscending = true) const;
449 bool Set_Index (CSG_Index &Index, const CSG_Array_Int &Fields, bool bAscending = true) const;
450
451 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);
452 bool Del_Index (void);
453 bool Toggle_Index (int Field);
454 bool is_Indexed (void) const { return( m_nRecords > 0 && m_nRecords == m_Index.Get_Count() ); }
455 int Get_Index_Field (int i) const { return( i < 0 || i >= m_Index_Fields.Get_Size() ? -1 : abs(m_Index_Fields[i]) - 1 ); }
456 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 ); }
457 int Get_Index_Field (size_t i) const { return( Get_Index_Field((int)i) ); }
458 TSG_Table_Index_Order Get_Index_Order (size_t i) const { return( Get_Index_Order((int)i) ); }
459
460
461protected:
462
464 {
465 public:
466 CSG_Field_Info(void);
467 virtual ~CSG_Field_Info(void);
468
469 CSG_Field_Info(const CSG_String &Name, TSG_Data_Type Type);
470
471 bool Reset_Statistics (void);
472
473
475
477
479
481
482 };
483
484
486
488
490
492
494
495
496 virtual void _On_Construction (void);
497
498 virtual CSG_Table_Record * _Get_New_Record (sLong Index);
499
500 bool _Add_Selection (sLong Index);
501 bool _Set_Selection (sLong Index, sLong Selected);
502 bool _Del_Selection (sLong Index);
503
504 bool _Stats_Invalidate (void) const;
505 bool _Stats_Invalidate (int Field) const;
506 virtual bool _Stats_Update (int Field) const;
507 virtual bool _Histogram_Update (int Field, size_t nClasses) const;
508
509 bool _Save_Text (const CSG_String &File, bool bHeadline, const SG_Char Separator);
510 bool _Save_DBase (const CSG_String &File);
511
512 virtual bool On_NoData_Changed (void);
513 virtual bool On_Update (void);
514
515 virtual bool On_Reload (void);
516 virtual bool On_Delete (void);
517
518
519private:
520
521 CSG_Index m_Index;
522
523 CSG_Array_Int m_Index_Fields;
524
525 CSG_Table_Record **m_Records = NULL;
526
527
528 bool _Destroy_Selection (void);
529
530 bool _Inc_Array (void);
531 bool _Dec_Array (void);
532
533 size_t _Load_Text_Trim ( CSG_String &Text, const SG_Char Separator);
534 size_t _Load_Text_EndQuote (const CSG_String &Text, const SG_Char Separator);
535
536 bool _Load_Text (const CSG_String &File, bool bHeadline, const SG_Char Separator);
537 bool _Load_DBase (const CSG_String &File);
538
539 void _Index_Update (void);
540
541};
542
543
545// //
546// //
547// //
549
550//---------------------------------------------------------
553
556
559
566
568SAGA_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);
570SAGA_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);
573
574
576// //
577// //
578// //
580
581//---------------------------------------------------------
582#endif // #ifndef HEADER_INCLUDED__SAGA_API__table_H
bool SG_Data_Type_is_Numeric(TSG_Data_Type Type)
Definition api_core.cpp:198
signed long long sLong
Definition api_core.h:158
#define SAGA_API_DLL_EXPORT
Definition api_core.h:94
TSG_Data_Type
Definition api_core.h:997
@ SG_DATATYPE_Undefined
Definition api_core.h:1013
#define SG_Char
Definition api_core.h:536
@ SG_FILE_ENCODING_UTF8
Definition api_core.h:552
@ SG_FILE_ENCODING_UNDEFINED
Definition api_core.h:557
bool Reset_Statistics(void)
Definition table.cpp:466
TSG_Data_Type m_Type
Definition table.h:474
CSG_Simple_Statistics m_Statistics
Definition table.h:478
CSG_Histogram m_Histogram
Definition table.h:480
void Set_Modified(bool bOn=true)
bool Set_Value(const wchar_t *Field, sLong Value)
Definition table.h:162
SG_Char asChar(const wchar_t *Field) const
Definition table.h:212
bool Set_Value(const char *Field, DWORD Value)
Definition table.h:171
SG_Char asChar(const char *Field) const
Definition table.h:211
bool Set_Value(const wchar_t *Field, int Value)
Definition table.h:182
bool Set_Value(const char *Field, size_t Value)
Definition table.h:166
sLong m_Index
Definition table.h:256
class CSG_Table_Value ** m_Values
Definition table.h:258
bool Set_Value(const char *Field, long Value)
Definition table.h:176
CSG_Table_Record(class CSG_Table *pTable, sLong Index)
bool Set_Value(const CSG_String &Field, int Value)
Definition table.h:180
bool is_NoData(const wchar_t *Field) const
Definition table.h:202
double asDouble(const wchar_t *Field) const
Definition table.h:237
bool Set_Value(const CSG_String &Field, DWORD Value)
Definition table.h:170
bool _Del_Field(int del_Field)
bool is_NoData(const char *Field) const
Definition table.h:201
bool is_Modified(void) const
Definition table.h:245
void Set_Selected(bool bOn=true)
class CSG_Table * m_pTable
Definition table.h:260
bool Add_Value(const wchar_t *Field, double Value)
Definition table.h:187
sLong Get_Index(void) const
Definition table.h:136
bool Set_Value(int Field, const wchar_t *Value)
Definition table.h:142
sLong asLong(int Field) const
bool Set_Value(const wchar_t *Field, const CSG_Bytes &Value)
Definition table.h:152
bool _Add_Field(int add_Field)
double asDouble(const char *Field) const
Definition table.h:236
const SG_Char * asString(const char *Field, int Decimals=-99) const
Definition table.h:206
bool Set_Value(const wchar_t *Field, const wchar_t *Value)
Definition table.h:147
bool Set_Value(const char *Field, const CSG_Bytes &Value)
Definition table.h:151
float asFloat(const wchar_t *Field) const
Definition table.h:232
friend class CSG_PointCloud
Definition table.h:131
short asShort(const char *Field) const
Definition table.h:216
int asInt(int Field) const
int _Get_Field(const CSG_String &Field) const
float asFloat(const char *Field) const
Definition table.h:231
const SG_Char * asString(const wchar_t *Field, int Decimals=-99) const
Definition table.h:207
bool Set_Value(const wchar_t *Field, const CSG_String &Value)
Definition table.h:145
bool is_Selected(void) const
Definition table.h:244
friend class CSG_Table
Definition table.h:131
bool Set_NoData(const char *Field)
Definition table.h:196
bool Add_Value(const char *Field, double Value)
Definition table.h:186
bool Mul_Value(const char *Field, double Value)
Definition table.h:191
int asInt(const char *Field) const
Definition table.h:221
bool Set_Value(int Field, size_t Value)
Definition table.h:164
class CSG_Table * Get_Table(void)
Definition table.h:135
int asInt(const wchar_t *Field) const
Definition table.h:222
bool Set_Value(const CSG_String &Field, size_t Value)
Definition table.h:165
float asFloat(int Field) const
bool Set_Value(const wchar_t *Field, size_t Value)
Definition table.h:167
bool Set_Value(int Field, DWORD Value)
Definition table.h:169
bool Set_Value(const char *Field, int Value)
Definition table.h:181
SG_Char asChar(int Field) const
short asShort(int Field) const
bool Set_Value(const char *Field, double Value)
Definition table.h:156
bool Set_Value(const CSG_String &Field, long Value)
Definition table.h:175
bool Set_Value(int Field, long Value)
Definition table.h:174
bool Set_Value(const char *Field, const CSG_String &Value)
Definition table.h:144
bool Set_Value(const wchar_t *Field, DWORD Value)
Definition table.h:172
short asShort(const wchar_t *Field) const
Definition table.h:217
bool Mul_Value(const wchar_t *Field, double Value)
Definition table.h:192
sLong asLong(const char *Field) const
Definition table.h:226
bool Set_Value(const char *Field, sLong Value)
Definition table.h:161
CSG_Table_Value * Get_Value(int Field)
Definition table.h:239
bool Set_Value(int Field, int Value)
Definition table.h:179
bool Set_Value(const wchar_t *Field, long Value)
Definition table.h:177
static CSG_Table_Value * _Create_Value(TSG_Data_Type Type)
bool Set_Value(int Field, const char *Value)
Definition table.h:141
virtual bool is_Valid(void) const
Definition table.h:138
sLong asLong(const wchar_t *Field) const
Definition table.h:227
bool Set_NoData(const wchar_t *Field)
Definition table.h:197
bool Set_Value(const wchar_t *Field, double Value)
Definition table.h:157
bool Set_Value(const char *Field, const char *Value)
Definition table.h:146
const SG_Char * Get_Field_Name(int Field) const
Definition table.h:362
virtual const CSG_Rect & Get_Extent(void)
Definition table.h:352
bool Create(void)
Definition table.cpp:153
int Find_Field(const wchar_t *Name) const
Definition table.h:375
virtual bool _Stats_Update(int Field) const
Definition table.cpp:1252
virtual bool Add_Field(const wchar_t *Name, TSG_Data_Type Type, int Position=-1)
Definition table.h:357
TSG_Table_Index_Order Get_Index_Order(size_t i) const
Definition table.h:458
sLong Get_Count(void) const
Definition table.h:400
int Find_Field(const char *Name) const
Definition table.h:374
virtual bool Destroy(void)
Definition table.cpp:314
bool _Set_Selection(sLong Index, sLong Selected)
double Get_Minimum(int Field) const
Definition table.h:381
virtual bool Save(const char *File, int Format, SG_Char Separator, int Encoding=SG_FILE_ENCODING_UNDEFINED)
Definition table.h:330
int Get_File_Encoding(void) const
Definition table.h:338
sLong m_nRecords
Definition table.h:489
double Get_Mean(int Field) const
Definition table.h:385
virtual bool On_NoData_Changed(void)
Definition table.cpp:1324
virtual bool is_Valid(void) const
Definition table.h:346
double Get_StdDev(int Field) const
Definition table.h:386
sLong Get_N(int Field) const
Definition table.h:380
virtual bool _Histogram_Update(int Field, size_t nClasses) const
Definition table.cpp:1299
bool _Stats_Invalidate(void) const
Definition table.cpp:1228
CSG_Field_Info ** m_Field_Info
Definition table.h:485
CSG_Table(void)
Definition table.cpp:147
virtual bool Save(const wchar_t *File, int Format=0)
Definition table.h:335
TSG_Table_Index_Order Get_Index_Order(int i) const
Definition table.h:456
bool is_Indexed(void) const
Definition table.h:454
virtual bool On_Delete(void)
Definition table_io.cpp:70
virtual bool On_Update(void)
Definition table.cpp:1332
friend class CSG_Table_Record
Definition table.h:286
CSG_Array m_Selection
Definition table.h:491
virtual bool Save(const wchar_t *File, int Format, SG_Char Separator, int Encoding=SG_FILE_ENCODING_UNDEFINED)
Definition table.h:331
int Get_Index_Field(size_t i) const
Definition table.h:457
friend class CSG_TIN
Definition table.h:287
int Get_Index_Field(int i) const
Definition table.h:455
bool _Save_Text(const CSG_String &File, bool bHeadline, const SG_Char Separator)
Definition table_io.cpp:495
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
int m_Encoding
Definition table.h:487
bool Find_Field(const char *Name, int &Index) const
Definition table.h:377
virtual CSG_Table_Record * _Get_New_Record(sLong Index)
Definition table.cpp:817
bool Find_Field(const wchar_t *Name, int &Index) const
Definition table.h:378
virtual bool Add_Field(const char *Name, TSG_Data_Type Type, int Position=-1)
Definition table.h:356
virtual CSG_Table_Record * Get_Record(sLong Index) const
Definition table.h:402
const CSG_Histogram & Get_Histogram(int Field, size_t nClasses=0) const
Definition table.h:390
virtual bool Save(const char *File, int Format=0)
Definition table.h:334
virtual CSG_Table_Record * Get_Selection(sLong Index=0) const
Definition table.h:430
int Get_Field_Count(void) const
Definition table.h:361
double Get_Range(int Field) const
Definition table.h:383
bool _Save_DBase(const CSG_String &File)
Definition table_io.cpp:565
bool _Add_Selection(sLong Index)
virtual bool is_Selected(sLong Index) const
Definition table.h:432
sLong m_nBuffer
Definition table.h:489
int m_nFields
Definition table.h:487
virtual bool On_Reload(void)
Definition table_io.cpp:64
CSG_Rect m_Extent
Definition table.h:493
sLong Get_Selection_Index(sLong Index=0) const
Definition table.h:429
bool is_Field_Numeric(int Field) const
Definition table.h:364
sLong Get_Selection_Count(void) const
Definition table.h:428
double Get_Sum(int Field) const
Definition table.h:384
CSG_Table_Record * Get_Record_byIndex(sLong Index) const
Definition table.h:407
const CSG_Simple_Statistics & Get_Statistics(int Field) const
Definition table.h:388
bool _Del_Selection(sLong Index)
TSG_Data_Type Get_Field_Type(int Field) const
Definition table.h:363
double Get_Variance(int Field) const
Definition table.h:387
sLong Get_Index(sLong Index) const
Definition table.h:405
virtual void _On_Construction(void)
Definition table.cpp:295
double Get_Maximum(int Field) const
Definition table.h:382
TSG_Data_Object_Type
Definition dataobject.h:117
@ SG_DATAOBJECT_TYPE_Table
Definition dataobject.h:120
SAGA_API_DLL_EXPORT CSG_Table * SG_Create_Table(void)
Definition table.cpp:65
TSG_Table_File_Type
Definition table.h:93
@ TABLE_FILETYPE_DBase
Definition table.h:97
@ TABLE_FILETYPE_Text
Definition table.h:95
@ TABLE_FILETYPE_Text_NoHeadLine
Definition table.h:96
@ TABLE_FILETYPE_Undefined
Definition table.h:94
#define SG_TABLE_REC_FLAG_Selected
Definition table.h:119
TSG_Table_Index_Order
Definition table.h:103
@ TABLE_INDEX_Descending
Definition table.h:106
@ TABLE_INDEX_Ascending
Definition table.h:105
@ TABLE_INDEX_None
Definition table.h:104
#define SG_TABLE_REC_FLAG_Modified
Definition table.h:118