|
SAGA API
v9.6
|
Go to the documentation of this file.
114 if( Separator ==
'\0' )
124 case TABLE_FILETYPE_Text:
default:
if( !_Load_Text (FileName,
true , Separator) )
return(
false );
break;
172 if( Separator ==
'\0' )
180 bool bResult =
false;
237 for(
size_t i=0; i<s.
Length(); i++)
241 if( c == Separator || (c !=
' ' && c !=
'\t' && c !=
'\n' && c !=
'\v' && c !=
'\f' && c !=
'\r') )
256 size_t CSG_Table::_Load_Text_EndQuote(
const CSG_String &s,
const SG_Char Separator)
258 if( s.
Length() > 1 && s[0] ==
'\"' )
260 bool bInQuotes =
true;
262 for(
size_t i=1; i<s.
Length(); i++)
271 else if( s[i] ==
'\"' )
275 else if( s[i] == Separator )
281 if( s[s.
Length() - 1] ==
'\"' )
291 bool CSG_Table::_Load_Text(
const CSG_String &FileName,
bool bHeadline,
const SG_Char Separator)
317 _Load_Text_Trim(sLine, Separator);
323 if( sLine[0] ==
'\"' )
333 sLine = sLine.
AfterFirst(Separator); _Load_Text_Trim(sLine, Separator);
335 if( !bHeadline || sField.
Length() == 0 )
365 _Load_Text_Trim(sLine, Separator);
369 size_t Position = _Load_Text_EndQuote(sLine, Separator);
CSG_String sField;
373 if( Position - 2 > 0 )
375 sField = sLine.
Mid(1, Position - 2);
391 sLine = sLine.
AfterFirst(Separator); _Load_Text_Trim(sLine, Separator);
398 size_t pos;
double Value = std::stod(sField.
to_StdString(), &pos);
400 if( pos < sField.
Length() )
433 if( *Table[iRecord].asString(iField) )
435 pRecord->
Set_Value(iField, Table[iRecord].asString(iField));
515 bool CSG_Table::_Load_DBase(
const CSG_String &FileName)
519 return( dbf.Open_Read(FileName,
this) );
547 for(
int iField=0; iField<
m_nFields; iField++)
554 for(
int iField=0; iField<
m_nFields; iField++)
566 if( Stream.
Read_Line(sLine) &&
SG_SSCANF(sLine,
SG_T(
"%d %lld"), &nFields, &nRecords) == 2 && nFields > 0 )
570 for(
int iField=0; iField<nFields; iField++)
578 for(
sLong iRecord=0; iRecord<nRecords; iRecord++)
584 for(
int iField=0; iField<
m_nFields; iField++)
CSG_String BeforeFirst(char Character) const
virtual bool Open(const CSG_String &FileName, int Mode=SG_FILE_R, bool bBinary=true, int Encoding=SG_FILE_ENCODING_ANSI)
int Printf(const char *Format,...)
bool Seek_Start(void) const
void Set_File_Name(const CSG_String &FileName)
size_t Length(void) const
CSG_String Mid(size_t first, size_t count=0) const
@ SG_UI_MSG_STYLE_SUCCESS
virtual CSG_Table_Record * Get_Record(sLong Index) const
SAGA_API_DLL_EXPORT bool SG_File_Cmp_Extension(const CSG_String &FileName, const CSG_String &Extension)
bool Save_MetaData(const CSG_String &FileName)
virtual bool Destroy(void)
virtual bool On_Reload(void)
bool Open_Write(const SG_Char *FileName, class CSG_Table *pTable, bool bRecords_Save=true)
int Get_Field_Count(void) const
SAGA_API_DLL_EXPORT bool SG_File_Delete(const CSG_String &FileName)
@ TABLE_FILETYPE_Undefined
virtual bool On_Delete(void)
void Set_Update_Flag(bool bOn=true)
bool is_NoData(int Field) const
virtual void Set_Modified(bool bModified=true)
@ SG_UI_MSG_STYLE_FAILURE
SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Name(const CSG_String &full_Path, bool bExtension)
SAGA_API_DLL_EXPORT bool SG_File_Exists(const CSG_String &FileName)
const SG_Char * asString(int Field, int Decimals=-99) const
const SG_Char * Get_Field_Name(int iField) const
std::string to_StdString(void) const
@ SG_FILE_ENCODING_UNDEFINED
bool Set_File_Encoding(int Encoding)
bool Serialize(CSG_File &Stream, bool bSave)
bool Read_Line(CSG_String &sLine) const
sLong Get_Count(void) const
void Set_File_Type(int Type)
@ TABLE_FILETYPE_Text_NoHeadLine
const SG_Char * Get_File_Name(bool bNative=true) const
CSG_Table_Record * Get_Record_byIndex(sLong Index) const
void Set_Name(const CSG_String &Name)
static CSG_String Format(const char *Format,...)
int Find(char Character, bool fromEnd=false) const
bool Set_Field_Name(int iField, const SG_Char *Name)
virtual bool Add_Field(const CSG_String &Name, TSG_Data_Type Type, int Position=-1)
const char gSG_Data_Type_Identifier[][32]
bool _Save_DBase(const CSG_String &File)
CSG_String AfterFirst(char Character) const
bool Load(const CSG_String &File, int Format, SG_Char Separator, int Encoding=SG_FILE_ENCODING_UNDEFINED)
CSG_MetaData & Get_MetaData_DB(void) const
int Printf(const char *Format,...)
bool is_Empty(void) const
bool SG_UI_Process_Set_Progress(int Position, int Range)
bool Set_Value(int Field, const CSG_String &Value)
bool Load_MetaData(const CSG_String &FileName)
virtual bool Save(const CSG_String &File, int Format, SG_Char Separator, int Encoding=SG_FILE_ENCODING_UNDEFINED)
const SG_Char * c_str(void) const
bool SG_UI_Process_Set_Ready(void)
TSG_Data_Type Get_Field_Type(int iField) const
virtual CSG_Table_Record * Add_Record(CSG_Table_Record *pCopy=NULL)
bool Set_NoData(int Field)
bool _Save_Text(const CSG_String &File, bool bHeadline, const SG_Char Separator)
CSG_String Right(size_t count) const
void SG_UI_Msg_Add(const char *Message, bool bNewLine, TSG_UI_MSG_STYLE Style)