SAGA API Version 9.12
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, bool bMetaData)
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 if( bMetaData )
216 {
217 Save_MetaData(File);
218 }
219
221
222 return( true );
223 }
224
225 SG_UI_Msg_Add(_TL("failed"), false, SG_UI_MSG_STYLE_FAILURE);
226
227 return( false );
228}
229
230
232// //
233// Text //
234// //
236
237//---------------------------------------------------------
238size_t CSG_Table::_Load_Text_Trim(CSG_String &s, const SG_Char Separator)
239{
240 for(size_t i=0; i<s.Length(); i++)
241 {
242 SG_Char c = s[i];
243
244 if( c == Separator || (c != ' ' && c != '\t' && c != '\n' && c != '\v' && c != '\f' && c != '\r') )
245 {
246 if( i > 0 )
247 {
248 s = s.Right(s.Length() - i);
249 }
250
251 return( i );
252 }
253 }
254
255 return( 0 );
256}
257
258//---------------------------------------------------------
259size_t CSG_Table::_Load_Text_EndQuote(const CSG_String &s, const SG_Char Separator)
260{
261 if( s.Length() > 1 && s[0] == '\"' )
262 {
263 bool bInQuotes = true;
264
265 for(size_t i=1; i<s.Length(); i++)
266 {
267 if( bInQuotes )
268 {
269 if( s[i] == '\"' )
270 {
271 bInQuotes = false;
272 }
273 }
274 else if( s[i] == '\"' )
275 {
276 bInQuotes = true;
277 }
278 else if( s[i] == Separator )
279 {
280 return( i );
281 }
282 }
283
284 if( s[s.Length() - 1] == '\"' )
285 {
286 return( s.Length() );
287 }
288 }
289
290 return( 0 );
291}
292
293//---------------------------------------------------------
294bool CSG_Table::_Load_Text(const CSG_String &File, bool bHeadline, const SG_Char _Separator)
295{
296 CSG_File Stream;
297
298 if( Stream.Open(File, SG_FILE_R, false, m_Encoding) == false )
299 {
300 return( false );
301 }
302
303 sLong fLength = Stream.Length();
304
305 if( fLength < 1 )
306 {
307 return( false );
308 }
309
310 //-----------------------------------------------------
311 CSG_String Line;
312
313 if( !Stream.Read_Line(Line) ) // end-of-file !
314 {
315 return( false );
316 }
317
318 if( Line[0] == 65279 ) // 65279 => '\uFEFF' => BOM => zero-width no-break space ! ...to do: recognizing other 'magic' first characters !
319 {
320 Line.Remove(0, 1);
321 }
322
323 bool bCSV = SG_File_Cmp_Extension(File, "csv");
324
325 while( Line.is_Empty() || (bCSV && Line[0] == '#') ) // empty or comment
326 {
327 if( !Stream.Read_Line(Line) ) // end-of-file !
328 {
329 return( false );
330 }
331 }
332
333 //-----------------------------------------------------
334 SG_Char Separator = _Separator;
335
336 if( Separator == '\0' )
337 {
338 if( bCSV ) // comma separated values
339 {
340 Separator = Line.Find(';') >= 0 ? ';' : ','; // assume semicolon as value separator, comma as decimal separator!
341 }
342 else // assume tab spaced text table
343 {
344 Separator = '\t';
345 }
346 }
347
348 bool bComma2Point = bCSV && Separator == ';';
349
350 //-----------------------------------------------------
351 CSG_Table Table;
352
353 _Load_Text_Trim(Line, Separator);
354
355 while( !Line.is_Empty() )
356 {
357 CSG_String Value;
358
359 if( Line[0] == '\"' ) // value in quotas
360 {
361 Value = Line.AfterFirst('\"').BeforeFirst('\"');
362 Line = Line.AfterFirst('\"').AfterFirst ('\"');
363 }
364 else
365 {
366 Value = Line.BeforeFirst(Separator);
367 }
368
369 Line = Line.AfterFirst(Separator); _Load_Text_Trim(Line, Separator);
370
371 if( !bHeadline || Value.Length() == 0 )
372 {
373 Value.Printf("F%02d", Table.Get_Field_Count() + 1);
374 }
375
376 Table.Add_Field(Value, SG_DATATYPE_String);
377 }
378
379 //-----------------------------------------------------
380 TSG_Data_Type *Types = new TSG_Data_Type[Table.Get_Field_Count()];
381
382 for(int Field=0; Field<Table.Get_Field_Count(); Field++)
383 {
384 Types[Field] = SG_DATATYPE_Int;
385 }
386
387 if( !bHeadline )
388 {
389 Stream.Seek_Start();
390 }
391
392 while( Stream.Read_Line(Line) && SG_UI_Process_Set_Progress((double)Stream.Tell(), (double)fLength) )
393 {
394 if( Line.is_Empty() || (bCSV && Line[0] == '#') ) // empty or comment
395 {
396 continue;
397 }
398
399 CSG_Table_Record &Record = *Table.Add_Record();
400
401 _Load_Text_Trim(Line, Separator);
402
403 for(int Field=0; Field<Table.Get_Field_Count() && !Line.is_Empty(); Field++)
404 {
405 size_t Position = _Load_Text_EndQuote(Line, Separator); CSG_String Value;
406
407 if( Position > 0 ) // value in quotas !!!
408 {
409 if( Position - 2 > 0 )
410 {
411 Value = Line.Mid(1, Position - 2);
412 }
413 else
414 {
415 Value.Clear();
416 }
417
418 Line = Line.Right(Line.Length() - Position);
419
420 Types[Field] = SG_DATATYPE_String;
421 }
422 else
423 {
424 Value = Line.BeforeFirst(Separator);
425
426 if( bComma2Point )
427 {
428 Value.Replace(",", ".");
429 }
430 }
431
432 Line = Line.AfterFirst(Separator); _Load_Text_Trim(Line, Separator);
433
434 //---------------------------------------------
435 if( Types[Field] != SG_DATATYPE_String && !Value.is_Empty() )
436 {
437 if( Value[0] == '0' && Value[1] != '.' && Value[1] != '\0' ) // keep leading zero(s) => don't interpret as number !
438 {
439 Types[Field] = SG_DATATYPE_String;
440 }
441 else try
442 {
443 size_t pos; double number = std::stod(Value.to_StdString(), &pos);
444
445 if( pos < Value.Length() )
446 {
447 Types[Field] = SG_DATATYPE_String;
448 }
449 else if( Types[Field] != SG_DATATYPE_Double && (number - (int)number != 0. || Value.Find('.') >= 0) )
450 {
451 Types[Field] = SG_DATATYPE_Double;
452 }
453 }
454 catch(...)
455 {
456 Types[Field] = SG_DATATYPE_String;
457 }
458 }
459
460 Record.Set_Value(Field, Value);
461 }
462 }
463
464 //-----------------------------------------------------
465 if( Table.Get_Field_Count() > 0 )
466 {
467 for(int Field=0; Field<Table.Get_Field_Count(); Field++)
468 {
469 Add_Field(Table.Get_Field_Name(Field), Types[Field]);
470 }
471
472 for(sLong i=0; i<Table.Get_Count() && SG_UI_Process_Set_Progress(i, Table.Get_Count()); i++)
473 {
474 CSG_Table_Record &Record = *Add_Record();
475
476 for(int Field=0; Field<Get_Field_Count(); Field++)
477 {
478 if( *Table[i].asString(Field) )
479 {
480 Record.Set_Value(Field, Table[i].asString(Field));
481 }
482 else
483 {
484 Record.Set_NoData(Field);
485 }
486 }
487 }
488 }
489
490 delete[](Types);
491
493
494 return( Get_Field_Count() > 0 );
495}
496
497//---------------------------------------------------------
498bool CSG_Table::_Save_Text(const CSG_String &File, bool bHeadline, const SG_Char Separator)
499{
500 CSG_File Stream;
501
502 if( Get_Field_Count() <= 0 || Stream.Open(File, SG_FILE_W, false, m_Encoding) == false )
503 {
504 return( false );
505 }
506
507 //-----------------------------------------------------
508 for(int Field=0; Field<Get_Field_Count(); Field++)
509 {
510 Stream.Printf("%s%c", Get_Field_Name(Field), Field < Get_Field_Count() - 1 ? Separator : '\n');
511 }
512
513 //-----------------------------------------------------
514 for(sLong i=0; i<Get_Count() && SG_UI_Process_Set_Progress(i, Get_Count()); i++)
515 {
517
518 for(int Field=0; Field<Get_Field_Count(); Field++)
519 {
520 CSG_String Value;
521
522 if( !Record.is_NoData(Field) )
523 {
524 Value = Record.asString(Field);
525 }
526
527 switch( Get_Field_Type(Field) )
528 {
529 default:
530 break;
531
533 case SG_DATATYPE_Date :
534 Value.Replace("\t", " ");
535 Value.Replace("\n", " ");
536 Value = "\"" + Value + "\"";
537 break;
538 }
539
540 Stream.Write(Value + (Field < Get_Field_Count() - 1 ? Separator : SG_T('\n')));
541 }
542 }
543
544 //-----------------------------------------------------
546
547 return( true );
548}
549
550
552// //
553// DBase //
554// //
556
557//---------------------------------------------------------
558bool CSG_Table::_Load_DBase(const CSG_String &File)
559{
561
562 return( dbf.Open_Read(File, this) );
563}
564
565//---------------------------------------------------------
567{
569
570 return( dbf.Open_Write(File, this) );
571}
572
573
575// //
576// From/To Text //
577// //
579
580//---------------------------------------------------------
582{
583 if( Text.is_Empty() )
584 {
585 return( false );
586 }
587
588 Destroy(); Set_Name(_TL("New Table"));
589
590 //-----------------------------------------------------
591 CSG_Strings Values, Records(SG_String_Tokenize(Text, "\r\n"));
592
593 Values = (SG_String_Tokenize(Records[0], "\t"));
594
595 TSG_Data_Type *Types = new TSG_Data_Type[Values.Get_Count()];
596
597 for(int Field=0; Field<Values.Get_Count(); Field++)
598 {
599 Add_Field(Values[Field], SG_DATATYPE_String); Types[Field] = SG_DATATYPE_Int;
600 }
601
602 //-----------------------------------------------------
603 for(int i=1; i<Records.Get_Count(); i++)
604 {
605 CSG_Table_Record &Record = *Add_Record();
606
607 Values = (SG_String_Tokenize(Records[i], "\t"));
608
609 for(int Field=0; Field<Values.Get_Count() && Field<Get_Field_Count(); Field++)
610 {
611 CSG_String Value(Values[Field]);
612
613 if( Value.Length() >= 2 && Value[0] == '\"' && Value[Value.Length() - 1] == '\"' ) // is string, remove quota
614 {
615 Types[Field] = SG_DATATYPE_String; Value = Value.Mid(1, Value.Length() - 2);
616 }
617
618 Record.Set_Value(Field, Value);
619
620 if( Types[Field] != SG_DATATYPE_String && !Value.is_Empty() )
621 {
622 if( Value[0] == '0' && Value[1] != '.' ) // keep leading zero(s) => don't interpret as number !
623 {
624 Types[Field] = SG_DATATYPE_String;
625 }
626 else try
627 {
628 size_t pos; double number = std::stod(Value.to_StdString(), &pos);
629
630 if( pos < Value.Length() )
631 {
632 Types[Field] = SG_DATATYPE_String;
633 }
634 else if( Types[Field] != SG_DATATYPE_Double && (number - (int)number != 0. || Value.Find('.') >= 0) )
635 {
636 Types[Field] = SG_DATATYPE_Double;
637 }
638 }
639 catch(...)
640 {
641 Types[Field] = SG_DATATYPE_String;
642 }
643 }
644 }
645 }
646
647 //-----------------------------------------------------
648 for(int Field=0; Field<Get_Field_Count(); Field++)
649 {
650 Set_Field_Type(Field, Types[Field]);
651 }
652
653 delete[](Types);
654
655 return( Get_Field_Count() > 1 || Get_Count() > 0 );
656}
657
658//---------------------------------------------------------
659CSG_String CSG_Table::to_Text(bool Selection, bool Header, bool QuoteStrings) const
660{
661 CSG_String Text;
662
663 if( Header )
664 {
665 for(int Field=0; Field<Get_Field_Count(); Field++)
666 {
667 Text += Get_Field_Name(Field); Text += 1 + Field < Get_Field_Count() ? '\t' : '\n';
668 }
669 }
670
671 sLong n = Selection ? Get_Selection_Count() : Get_Count();
672
673 for(sLong i=0; i<n; i++)
674 {
675 CSG_Table_Record &Record = Selection ? *Get_Selection(i) : *Get_Record_byIndex(i);
676
677 for(int Field=0; Field<Get_Field_Count(); Field++)
678 {
679 CSG_String Value(Record.asString(Field));
680
681 if( Get_Field_Type(Field) == SG_DATATYPE_String )
682 {
683 Value.Replace("\t", " "); Value.Replace("\n", " ");
684
685 if( QuoteStrings )
686 {
687 Value = "\"" + Value + "\"";
688 }
689 }
690
691 Text += Value + (1 + Field < Get_Field_Count() ? '\t' : '\n');
692 }
693 }
694
695 return( Text );
696}
697
698
700// //
701// Serialize //
702// //
704
705//---------------------------------------------------------
706bool CSG_Table::Serialize(CSG_File &Stream, bool bSave)
707{
708 const SG_Char Separator = SG_T('\t');
709
710 //-----------------------------------------------------
711 if( bSave )
712 {
713 Stream.Printf("%d %d\n", m_nFields, m_nRecords);
714
715 for(int Field=0; Field<m_nFields; Field++)
716 {
717 Stream.Printf("%d \"%s\"\n", Get_Field_Type(Field), Get_Field_Name(Field));
718 }
719
720 for(sLong i=0; i<m_nRecords; i++)
721 {
722 for(int Field=0; Field<m_nFields; Field++)
723 {
724 Stream.Printf("%s%c", Get_Record(i)->asString(Field), Field < m_nFields - 1 ? Separator : '\n');
725 }
726 }
727
728 return( true );
729 }
730
731 //-----------------------------------------------------
732 CSG_String sLine; int nFields, FieldType; sLong nRecords;
733
734 if( Stream.Read_Line(sLine) && SG_SSCANF(sLine, SG_T("%d %lld"), &nFields, &nRecords) == 2 && nFields > 0 )
735 {
736 Destroy();
737
738 for(int Field=0; Field<nFields; Field++)
739 {
740 if( Stream.Read_Line(sLine) && SG_SSCANF(sLine, SG_T("%d"), &FieldType) == 1 )
741 {
742 Add_Field(sLine.AfterFirst('\"').BeforeFirst('\"'), (TSG_Data_Type)FieldType);
743 }
744 }
745
746 for(sLong i=0; i<nRecords; i++)
747 {
748 if( Stream.Read_Line(sLine) )
749 {
750 CSG_Table_Record &Record = *Add_Record();
751
752 for(int Field=0; Field<m_nFields; Field++)
753 {
754 Record.Set_Value(Field, sLine.BeforeFirst(Separator));
755
756 sLine = sLine.AfterFirst(Separator);
757 }
758 }
759 }
760
761 return( true );
762 }
763
764 //-----------------------------------------------------
765 return( false );
766}
767
768
770// //
771// //
772// //
774
775//---------------------------------------------------------
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:1627
@ SG_UI_MSG_STYLE_SUCCESS
Definition api_core.h:1626
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:1082
TSG_Data_Type
Definition api_core.h:1036
@ SG_DATATYPE_Double
Definition api_core.h:1047
@ SG_DATATYPE_Int
Definition api_core.h:1043
@ SG_DATATYPE_String
Definition api_core.h:1048
@ SG_DATATYPE_Date
Definition api_core.h:1049
#define SG_Char
Definition api_core.h:536
#define _TL(s)
Definition api_core.h:1610
@ SG_FILE_ENCODING_UNDEFINED
Definition api_core.h:557
#define SG_SSCANF
Definition api_core.h:540
@ SG_FILE_W
Definition api_core.h:1154
@ SG_FILE_R
Definition api_core.h:1153
void Set_Name(const CSG_String &Name)
void Set_Update_Flag(bool bOn=true)
Definition dataobject.h:288
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:278
CSG_MetaData & Get_MetaData_DB(void) const
Definition dataobject.h:238
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:409
size_t Write(void *Buffer, size_t Size, size_t Count=1) const
Definition api_file.cpp:382
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:719
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
bool Set_Field_Name(int Field, const SG_Char *Name)
Definition table.cpp:595
virtual bool Destroy(void)
Definition table.cpp:314
virtual bool Save(const CSG_String &File, int Format, SG_Char Separator, int Encoding=SG_FILE_ENCODING_UNDEFINED, bool bMetaData=true)
Definition table_io.cpp:150
sLong m_nRecords
Definition table.h:489
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:581
bool Set_File_Encoding(int Encoding)
Definition table_io.cpp:81
CSG_Table(void)
Definition table.cpp:147
CSG_String to_Text(bool Selection=false, bool Header=true, bool QuoteStrings=false) const
Definition table_io.cpp:659
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:498
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:566
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:706
@ 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