SAGA API v9.10
Loading...
Searching...
No Matches
table_io.cpp
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_io.cpp //
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#include "table.h"
54#include "table_dbase.h"
55
56
58// //
59// //
60// //
62
63//---------------------------------------------------------
65{
66 return( Create(Get_File_Name(false)) );
67}
68
69//---------------------------------------------------------
71{
72 return( SG_File_Delete(Get_File_Name(false)) );
73}
74
75
77// //
79
80//---------------------------------------------------------
82{
83 if( Encoding >= 0 && Encoding < SG_FILE_ENCODING_UNDEFINED )
84 {
85 m_Encoding = Encoding;
86
87 return( true );
88 }
89
90 return( false );
91}
92
93
95// //
97
98//---------------------------------------------------------
99bool CSG_Table::Load(const CSG_String &File, int Format, SG_Char Separator, int Encoding)
100{
101 Set_File_Encoding(Encoding);
102
103 if( !SG_File_Exists(File) )
104 {
105 return( false );
106 }
107
108 //-----------------------------------------------------
109 if( Format == TABLE_FILETYPE_Undefined )
110 {
112 }
113
114 //-----------------------------------------------------
115 Destroy();
116
117 switch( Format )
118 {
119 case TABLE_FILETYPE_Text: default: if( !_Load_Text (File, true , Separator) ) return( false ); break;
120 case TABLE_FILETYPE_Text_NoHeadLine: if( !_Load_Text (File, false, Separator) ) return( false ); break;
121 case TABLE_FILETYPE_DBase : if( !_Load_DBase(File ) ) return( false ); break;
122 }
123
124 //-----------------------------------------------------
125 Set_Name(SG_File_Get_Name(File, false));
126
127 Load_MetaData(File);
128
129 CSG_MetaData *pFields = Get_MetaData_DB().Get_Child("FIELDS");
130
131 if( pFields && pFields->Get_Children_Count() == Get_Field_Count() )
132 {
133 for(int Field=0; Field<Get_Field_Count(); Field++)
134 {
135 Set_Field_Name(Field, pFields->Get_Content(Field));
136 }
137 }
138
139 //-----------------------------------------------------
140 return( true );
141}
142
143//---------------------------------------------------------
144bool CSG_Table::Save(const CSG_String &File, int Format)
145{
146 return( Save(File, Format, '\0', m_Encoding) );
147}
148
149//---------------------------------------------------------
150bool CSG_Table::Save(const CSG_String &File, int Format, SG_Char Separator, int Encoding)
151{
152 if( File.is_Empty() )
153 {
154 return( *Get_File_Name(false) ? Save(Get_File_Name(false), Format) : false );
155 }
156
157 SG_UI_Msg_Add(CSG_String::Format("%s %s: %s...", _TL("Saving"), _TL("table"), File.c_str()), true);
158
159 Set_File_Encoding(Encoding);
160
161 //-----------------------------------------------------
162 if( Format <= TABLE_FILETYPE_Undefined || Format > TABLE_FILETYPE_DBase )
163 {
164 if( SG_File_Cmp_Extension(File, "dbf") )
165 {
166 Format = TABLE_FILETYPE_DBase;
167 }
168 else
169 {
170 Format = TABLE_FILETYPE_Text;
171
172 if( Separator == '\0' )
173 {
174 Separator = SG_File_Cmp_Extension(File, "csv") ? ',' : '\t'; // comma separated values or tab spaced text
175 }
176 }
177 }
178
179 //-----------------------------------------------------
180 bool bResult = false;
181
182 switch( Format )
183 {
184 case TABLE_FILETYPE_Text: default: bResult = _Save_Text (File, true , Separator); break;
185 case TABLE_FILETYPE_Text_NoHeadLine: bResult = _Save_Text (File, false, Separator); break;
186 case TABLE_FILETYPE_DBase : bResult = _Save_DBase(File ); break;
187 }
188
189 //-----------------------------------------------------
190 CSG_MetaData *pFields = Get_MetaData_DB().Get_Child("FIELDS");
191
192 if( !pFields )
193 {
194 pFields = Get_MetaData_DB().Add_Child("FIELDS");
195 }
196
197 pFields->Del_Children();
198
199 for(int Field=0; Field<Get_Field_Count(); Field++)
200 {
201 pFields->Add_Child("FIELD", Get_Field_Name(Field))->Add_Property("TYPE", gSG_Data_Type_Identifier[Get_Field_Type(Field)]);
202 }
203
204 //-----------------------------------------------------
205 if( bResult )
206 {
207 Set_Modified(false);
208
210
211 Set_File_Type(Format);
212
213 Set_File_Name(File, true);
214
215 Save_MetaData(File);
216
218
219 return( true );
220 }
221
222 SG_UI_Msg_Add(_TL("failed"), false, SG_UI_MSG_STYLE_FAILURE);
223
224 return( false );
225}
226
227
229// //
230// Text //
231// //
233
234//---------------------------------------------------------
235size_t CSG_Table::_Load_Text_Trim(CSG_String &s, const SG_Char Separator)
236{
237 for(size_t i=0; i<s.Length(); i++)
238 {
239 SG_Char c = s[i];
240
241 if( c == Separator || (c != ' ' && c != '\t' && c != '\n' && c != '\v' && c != '\f' && c != '\r') )
242 {
243 if( i > 0 )
244 {
245 s = s.Right(s.Length() - i);
246 }
247
248 return( i );
249 }
250 }
251
252 return( 0 );
253}
254
255//---------------------------------------------------------
256size_t CSG_Table::_Load_Text_EndQuote(const CSG_String &s, const SG_Char Separator)
257{
258 if( s.Length() > 1 && s[0] == '\"' )
259 {
260 bool bInQuotes = true;
261
262 for(size_t i=1; i<s.Length(); i++)
263 {
264 if( bInQuotes )
265 {
266 if( s[i] == '\"' )
267 {
268 bInQuotes = false;
269 }
270 }
271 else if( s[i] == '\"' )
272 {
273 bInQuotes = true;
274 }
275 else if( s[i] == Separator )
276 {
277 return( i );
278 }
279 }
280
281 if( s[s.Length() - 1] == '\"' )
282 {
283 return( s.Length() );
284 }
285 }
286
287 return( 0 );
288}
289
290//---------------------------------------------------------
291bool CSG_Table::_Load_Text(const CSG_String &File, bool bHeadline, const SG_Char _Separator)
292{
293 CSG_File Stream;
294
295 if( Stream.Open(File, SG_FILE_R, false, m_Encoding) == false )
296 {
297 return( false );
298 }
299
300 sLong fLength = Stream.Length();
301
302 if( fLength < 1 )
303 {
304 return( false );
305 }
306
307 //-----------------------------------------------------
308 CSG_String Line;
309
310 if( !Stream.Read_Line(Line) ) // end-of-file !
311 {
312 return( false );
313 }
314
315 if( Line[0] == 65279 ) // 65279 => '\uFEFF' => BOM => zero-width no-break space ! ...to do: recognizing other 'magic' first characters !
316 {
317 Line.Remove(0, 1);
318 }
319
320 bool bCSV = SG_File_Cmp_Extension(File, "csv");
321
322 while( Line.is_Empty() || (bCSV && Line[0] == '#') ) // empty or comment
323 {
324 if( !Stream.Read_Line(Line) ) // end-of-file !
325 {
326 return( false );
327 }
328 }
329
330 //-----------------------------------------------------
331 SG_Char Separator = _Separator;
332
333 if( Separator == '\0' )
334 {
335 if( bCSV ) // comma separated values
336 {
337 Separator = Line.Find(';') >= 0 ? ';' : ','; // assume semicolon as value separator, comma as decimal separator!
338 }
339 else // assume tab spaced text table
340 {
341 Separator = '\t';
342 }
343 }
344
345 bool bComma2Point = bCSV && Separator == ';';
346
347 //-----------------------------------------------------
348 CSG_Table Table;
349
350 _Load_Text_Trim(Line, Separator);
351
352 while( !Line.is_Empty() )
353 {
354 CSG_String Value;
355
356 if( Line[0] == '\"' ) // value in quotas
357 {
358 Value = Line.AfterFirst('\"').BeforeFirst('\"');
359 Line = Line.AfterFirst('\"').AfterFirst ('\"');
360 }
361 else
362 {
363 Value = Line.BeforeFirst(Separator);
364 }
365
366 Line = Line.AfterFirst(Separator); _Load_Text_Trim(Line, Separator);
367
368 if( !bHeadline || Value.Length() == 0 )
369 {
370 Value.Printf("F%02d", Table.Get_Field_Count() + 1);
371 }
372
373 Table.Add_Field(Value, SG_DATATYPE_String);
374 }
375
376 //-----------------------------------------------------
377 TSG_Data_Type *Types = new TSG_Data_Type[Table.Get_Field_Count()];
378
379 for(int Field=0; Field<Table.Get_Field_Count(); Field++)
380 {
381 Types[Field] = SG_DATATYPE_Int;
382 }
383
384 if( !bHeadline )
385 {
386 Stream.Seek_Start();
387 }
388
389 while( Stream.Read_Line(Line) && SG_UI_Process_Set_Progress((double)Stream.Tell(), (double)fLength) )
390 {
391 if( Line.is_Empty() || (bCSV && Line[0] == '#') ) // empty or comment
392 {
393 continue;
394 }
395
396 CSG_Table_Record &Record = *Table.Add_Record();
397
398 _Load_Text_Trim(Line, Separator);
399
400 for(int Field=0; Field<Table.Get_Field_Count() && !Line.is_Empty(); Field++)
401 {
402 size_t Position = _Load_Text_EndQuote(Line, Separator); CSG_String Value;
403
404 if( Position > 0 ) // value in quotas !!!
405 {
406 if( Position - 2 > 0 )
407 {
408 Value = Line.Mid(1, Position - 2);
409 }
410 else
411 {
412 Value.Clear();
413 }
414
415 Line = Line.Right(Line.Length() - Position);
416
417 Types[Field] = SG_DATATYPE_String;
418 }
419 else
420 {
421 Value = Line.BeforeFirst(Separator);
422
423 if( bComma2Point )
424 {
425 Value.Replace(",", ".");
426 }
427 }
428
429 Line = Line.AfterFirst(Separator); _Load_Text_Trim(Line, Separator);
430
431 //---------------------------------------------
432 if( Types[Field] != SG_DATATYPE_String && !Value.is_Empty() )
433 {
434 if( Value[0] == '0' && Value[1] != '.' && Value[1] != '\0' ) // keep leading zero(s) => don't interpret as number !
435 {
436 Types[Field] = SG_DATATYPE_String;
437 }
438 else try
439 {
440 size_t pos; double number = std::stod(Value.to_StdString(), &pos);
441
442 if( pos < Value.Length() )
443 {
444 Types[Field] = SG_DATATYPE_String;
445 }
446 else if( Types[Field] != SG_DATATYPE_Double && (number - (int)number != 0. || Value.Find('.') >= 0) )
447 {
448 Types[Field] = SG_DATATYPE_Double;
449 }
450 }
451 catch(...)
452 {
453 Types[Field] = SG_DATATYPE_String;
454 }
455 }
456
457 Record.Set_Value(Field, Value);
458 }
459 }
460
461 //-----------------------------------------------------
462 if( Table.Get_Field_Count() > 0 )
463 {
464 for(int Field=0; Field<Table.Get_Field_Count(); Field++)
465 {
466 Add_Field(Table.Get_Field_Name(Field), Types[Field]);
467 }
468
469 for(sLong i=0; i<Table.Get_Count() && SG_UI_Process_Set_Progress(i, Table.Get_Count()); i++)
470 {
471 CSG_Table_Record &Record = *Add_Record();
472
473 for(int Field=0; Field<Get_Field_Count(); Field++)
474 {
475 if( *Table[i].asString(Field) )
476 {
477 Record.Set_Value(Field, Table[i].asString(Field));
478 }
479 else
480 {
481 Record.Set_NoData(Field);
482 }
483 }
484 }
485 }
486
487 delete[](Types);
488
490
491 return( Get_Field_Count() > 0 );
492}
493
494//---------------------------------------------------------
495bool CSG_Table::_Save_Text(const CSG_String &File, bool bHeadline, const SG_Char Separator)
496{
497 CSG_File Stream;
498
499 if( Get_Field_Count() <= 0 || Stream.Open(File, SG_FILE_W, false, m_Encoding) == false )
500 {
501 return( false );
502 }
503
504 //-----------------------------------------------------
505 for(int Field=0; Field<Get_Field_Count(); Field++)
506 {
507 Stream.Printf("%s%c", Get_Field_Name(Field), Field < Get_Field_Count() - 1 ? Separator : '\n');
508 }
509
510 //-----------------------------------------------------
511 for(sLong i=0; i<Get_Count() && SG_UI_Process_Set_Progress(i, Get_Count()); i++)
512 {
514
515 for(int Field=0; Field<Get_Field_Count(); Field++)
516 {
517 switch( Get_Field_Type(Field) )
518 {
520 case SG_DATATYPE_Date :
521 if( !Record.is_NoData(Field) )
522 {
523 Stream.Printf("\"%s\"", Record.asString(Field));
524 }
525 else
526 {
527 Stream.Printf("\"\"");
528 }
529 break;
530
531 default:
532 if( !Record.is_NoData(Field) )
533 {
534 Stream.Printf("%s", Record.asString(Field));
535 }
536 break;
537 }
538
539 Stream.Printf("%c", Field < Get_Field_Count() - 1 ? Separator : '\n');
540 }
541 }
542
543 //-----------------------------------------------------
545
546 return( true );
547}
548
549
551// //
552// DBase //
553// //
555
556//---------------------------------------------------------
557bool CSG_Table::_Load_DBase(const CSG_String &File)
558{
560
561 return( dbf.Open_Read(File, this) );
562}
563
564//---------------------------------------------------------
566{
568
569 return( dbf.Open_Write(File, this) );
570}
571
572
574// //
575// From/To Text //
576// //
578
579//---------------------------------------------------------
581{
582 if( Text.is_Empty() )
583 {
584 return( false );
585 }
586
587 Destroy(); Set_Name(_TL("New Table"));
588
589 //-----------------------------------------------------
590 CSG_Strings Values, Records(SG_String_Tokenize(Text, "\r\n"));
591
592 Values = (SG_String_Tokenize(Records[0], "\t"));
593
594 TSG_Data_Type *Types = new TSG_Data_Type[Values.Get_Count()];
595
596 for(int Field=0; Field<Values.Get_Count(); Field++)
597 {
598 Add_Field(Values[Field], SG_DATATYPE_String); Types[Field] = SG_DATATYPE_Int;
599 }
600
601 //-----------------------------------------------------
602 for(int i=1; i<Records.Get_Count(); i++)
603 {
604 CSG_Table_Record &Record = *Add_Record();
605
606 Values = (SG_String_Tokenize(Records[i], "\t"));
607
608 for(int Field=0; Field<Values.Get_Count() && Field<Get_Field_Count(); Field++)
609 {
610 CSG_String Value(Values[Field]);
611
612 if( Value.Length() >= 2 && Value[0] == '\"' && Value[Value.Length() - 1] == '\"' ) // is string, remove quota
613 {
614 Types[Field] = SG_DATATYPE_String; Value = Value.Mid(1, Value.Length() - 2);
615 }
616
617 Record.Set_Value(Field, Value);
618
619 if( Types[Field] != SG_DATATYPE_String && !Value.is_Empty() )
620 {
621 if( Value[0] == '0' && Value[1] != '.' ) // keep leading zero(s) => don't interpret as number !
622 {
623 Types[Field] = SG_DATATYPE_String;
624 }
625 else try
626 {
627 size_t pos; double number = std::stod(Value.to_StdString(), &pos);
628
629 if( pos < Value.Length() )
630 {
631 Types[Field] = SG_DATATYPE_String;
632 }
633 else if( Types[Field] != SG_DATATYPE_Double && (number - (int)number != 0. || Value.Find('.') >= 0) )
634 {
635 Types[Field] = SG_DATATYPE_Double;
636 }
637 }
638 catch(...)
639 {
640 Types[Field] = SG_DATATYPE_String;
641 }
642 }
643 }
644 }
645
646 //-----------------------------------------------------
647 for(int Field=0; Field<Get_Field_Count(); Field++)
648 {
649 Set_Field_Type(Field, Types[Field]);
650 }
651
652 delete[](Types);
653
654 return( Get_Field_Count() > 1 || Get_Count() > 0 );
655}
656
657//---------------------------------------------------------
658CSG_String CSG_Table::to_Text(bool Selection) const
659{
660 CSG_String Text;
661
662 for(int Field=0; Field<Get_Field_Count(); Field++)
663 {
664 Text += Get_Field_Name(Field); Text += 1 + Field < Get_Field_Count() ? '\t' : '\n';
665 }
666
667 sLong n = Selection ? Get_Selection_Count() : Get_Count();
668
669 for(sLong i=0; i<n; i++)
670 {
671 CSG_Table_Record &Record = Selection ? *Get_Selection(i) : *Get_Record_byIndex(i);
672
673 for(int Field=0; Field<Get_Field_Count(); Field++)
674 {
675 Text += Record.asString(Field); Text += 1 + Field < Get_Field_Count() ? '\t' : '\n';
676 }
677 }
678
679 return( Text );
680}
681
682
684// //
685// Serialize //
686// //
688
689//---------------------------------------------------------
690bool CSG_Table::Serialize(CSG_File &Stream, bool bSave)
691{
692 const SG_Char Separator = SG_T('\t');
693
694 //-----------------------------------------------------
695 if( bSave )
696 {
697 Stream.Printf("%d %d\n", m_nFields, m_nRecords);
698
699 for(int Field=0; Field<m_nFields; Field++)
700 {
701 Stream.Printf("%d \"%s\"\n", Get_Field_Type(Field), Get_Field_Name(Field));
702 }
703
704 for(sLong i=0; i<m_nRecords; i++)
705 {
706 for(int Field=0; Field<m_nFields; Field++)
707 {
708 Stream.Printf("%s%c", Get_Record(i)->asString(Field), Field < m_nFields - 1 ? Separator : '\n');
709 }
710 }
711
712 return( true );
713 }
714
715 //-----------------------------------------------------
716 CSG_String sLine; int nFields, FieldType; sLong nRecords;
717
718 if( Stream.Read_Line(sLine) && SG_SSCANF(sLine, SG_T("%d %lld"), &nFields, &nRecords) == 2 && nFields > 0 )
719 {
720 Destroy();
721
722 for(int Field=0; Field<nFields; Field++)
723 {
724 if( Stream.Read_Line(sLine) && SG_SSCANF(sLine, SG_T("%d"), &FieldType) == 1 )
725 {
726 Add_Field(sLine.AfterFirst('\"').BeforeFirst('\"'), (TSG_Data_Type)FieldType);
727 }
728 }
729
730 for(sLong i=0; i<nRecords; i++)
731 {
732 if( Stream.Read_Line(sLine) )
733 {
734 CSG_Table_Record &Record = *Add_Record();
735
736 for(int Field=0; Field<m_nFields; Field++)
737 {
738 Record.Set_Value(Field, sLine.BeforeFirst(Separator));
739
740 sLine = sLine.AfterFirst(Separator);
741 }
742 }
743 }
744
745 return( true );
746 }
747
748 //-----------------------------------------------------
749 return( false );
750}
751
752
754// //
755// //
756// //
758
759//---------------------------------------------------------
void SG_UI_Msg_Add(const char *Message, bool bNewLine, TSG_UI_MSG_STYLE Style)
bool SG_UI_Process_Set_Ready(void)
bool SG_UI_Process_Set_Progress(int Position, int Range)
SAGA_API_DLL_EXPORT bool SG_File_Exists(const CSG_String &FileName)
@ SG_UI_MSG_STYLE_FAILURE
Definition api_core.h:1585
@ SG_UI_MSG_STYLE_SUCCESS
Definition api_core.h:1584
SAGA_API_DLL_EXPORT bool SG_File_Cmp_Extension(const CSG_String &File, const CSG_String &Extension)
signed long long sLong
Definition api_core.h:158
#define SG_T(s)
Definition api_core.h:537
SAGA_API_DLL_EXPORT bool SG_File_Delete(const CSG_String &FileName)
SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Name(const CSG_String &full_Path, bool bExtension)
SAGA_API_DLL_EXPORT CSG_Strings SG_String_Tokenize(const CSG_String &String, const CSG_String &Delimiters=SG_DEFAULT_DELIMITERS, TSG_String_Tokenizer_Mode Mode=SG_TOKEN_DEFAULT)
const char gSG_Data_Type_Identifier[][32]
Definition api_core.h:1043
TSG_Data_Type
Definition api_core.h:997
@ SG_DATATYPE_Double
Definition api_core.h:1008
@ SG_DATATYPE_Int
Definition api_core.h:1004
@ SG_DATATYPE_String
Definition api_core.h:1009
@ SG_DATATYPE_Date
Definition api_core.h:1010
#define SG_Char
Definition api_core.h:536
#define _TL(s)
Definition api_core.h:1568
@ SG_FILE_ENCODING_UNDEFINED
Definition api_core.h:557
#define SG_SSCANF
Definition api_core.h:540
@ SG_FILE_W
Definition api_core.h:1115
@ SG_FILE_R
Definition api_core.h:1114
void Set_Name(const CSG_String &Name)
void Set_Update_Flag(bool bOn=true)
Definition dataobject.h:285
bool Save_MetaData(const CSG_String &FileName)
const SG_Char * Get_File_Name(bool bNative=true) const
bool Load_MetaData(const CSG_String &FileName)
void Set_File_Type(int Type)
Definition dataobject.h:275
CSG_MetaData & Get_MetaData_DB(void) const
Definition dataobject.h:235
void Set_File_Name(const CSG_String &FileName)
sLong Length(void) const
Definition api_file.cpp:230
sLong Tell(void) const
Definition api_file.cpp:265
virtual bool Open(const SG_Char *FileName, int Mode=SG_FILE_R, bool bBinary=true, int Encoding=SG_FILE_ENCODING_ANSI)
Definition api_file.cpp:113
bool Read_Line(CSG_String &Line) const
Definition api_file.cpp:399
int Printf(const char *Format,...)
Definition api_file.cpp:287
bool Seek_Start(void) const
Definition api_file.cpp:261
bool Del_Children(int Depth=0, const SG_Char *Name=NULL)
Definition metadata.cpp:381
int Get_Children_Count(void) const
Definition metadata.h:148
CSG_MetaData * Get_Child(int Index) const
Definition metadata.h:149
const CSG_String & Get_Content(void) const
Definition metadata.h:133
CSG_MetaData * Add_Child(void)
Definition metadata.cpp:166
bool Add_Property(const CSG_String &Name, const CSG_String &Value)
Definition metadata.cpp:559
size_t Length(void) const
CSG_String AfterFirst(char Character) const
CSG_String & Remove(size_t pos)
void Clear(void)
CSG_String BeforeFirst(char Character) const
size_t Replace(const CSG_String &Old, const CSG_String &New, bool bReplaceAll=true)
std::string to_StdString(void) const
static CSG_String Format(const char *Format,...)
int Find(char Character, bool fromEnd=false) const
CSG_String Right(size_t count) const
const SG_Char * c_str(void) const
int Printf(const char *Format,...)
bool is_Empty(void) const
CSG_String Mid(size_t first, size_t count=0) const
int Get_Count(void) const
Definition api_core.h:714
bool Open_Write(const SG_Char *FileName, class CSG_Table *pTable, bool bRecords_Save=true)
bool Set_Value(int Field, const CSG_String &Value)
bool is_NoData(int Field) const
bool Set_NoData(int Field)
const SG_Char * asString(int Field, int Decimals=-99) const
const SG_Char * Get_Field_Name(int Field) const
Definition table.h:362
bool Create(void)
Definition table.cpp:153
sLong Get_Count(void) const
Definition table.h:400
CSG_String to_Text(bool Selection=false) const
Definition table_io.cpp:658
bool Set_Field_Name(int Field, const SG_Char *Name)
Definition table.cpp:595
virtual bool Destroy(void)
Definition table.cpp:314
sLong m_nRecords
Definition table.h:489
virtual bool Save(const CSG_String &File, int Format, SG_Char Separator, int Encoding=SG_FILE_ENCODING_UNDEFINED)
Definition table_io.cpp:150
bool Load(const CSG_String &File, int Format, SG_Char Separator, int Encoding=SG_FILE_ENCODING_UNDEFINED)
Definition table_io.cpp:99
bool from_Text(const CSG_String &Text)
Definition table_io.cpp:580
bool Set_File_Encoding(int Encoding)
Definition table_io.cpp:81
CSG_Table(void)
Definition table.cpp:147
virtual bool On_Delete(void)
Definition table_io.cpp:70
friend class CSG_Table_Record
Definition table.h:286
virtual CSG_Table_Record * Add_Record(CSG_Table_Record *pCopy=NULL)
Definition table.cpp:823
bool _Save_Text(const CSG_String &File, bool bHeadline, const SG_Char Separator)
Definition table_io.cpp:495
int m_Encoding
Definition table.h:487
virtual CSG_Table_Record * Get_Record(sLong Index) const
Definition table.h:402
virtual CSG_Table_Record * Get_Selection(sLong Index=0) const
Definition table.h:430
int Get_Field_Count(void) const
Definition table.h:361
bool _Save_DBase(const CSG_String &File)
Definition table_io.cpp:565
int m_nFields
Definition table.h:487
virtual bool On_Reload(void)
Definition table_io.cpp:64
virtual bool Add_Field(const CSG_String &Name, TSG_Data_Type Type, int Position=-1)
Definition table.cpp:479
sLong Get_Selection_Count(void) const
Definition table.h:428
CSG_Table_Record * Get_Record_byIndex(sLong Index) const
Definition table.h:407
TSG_Data_Type Get_Field_Type(int Field) const
Definition table.h:363
virtual bool Set_Field_Type(int Field, TSG_Data_Type Type)
Definition table.cpp:610
virtual void Set_Modified(bool bModified=true)
Definition table.cpp:1141
bool Serialize(CSG_File &Stream, bool bSave)
Definition table_io.cpp:690
@ 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