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