 |
SAGA API
v9.9
|
Go to the documentation of this file.
116 if( pTable->
Create(File, Format, Encoding) )
121 delete(pTable);
return( NULL );
131 if( pTable->
Create(File, Format, Separator, Encoding) )
136 delete(pTable);
return( NULL );
211 CSG_String Connection(DBase +
" [" + Host +
":" + Port +
"]");
256 return(
Load(File, (
int)Format, Separator, Encoding) );
316 _Destroy_Selection();
456 m_Name = Name; m_Type = Type;
468 m_Statistics.Invalidate(); m_Histogram.Destroy();
481 if( Position < 0 || Position >
m_nFields )
553 if( Field < 0 || Field >=
m_nFields || Field == Position )
559 if( Position > Field )
569 if( Position < Field )
574 #pragma omp parallel for
597 if( Field >= 0 && Field <
m_nFields && Name && *Name )
622 #pragma omp parallel for
627 bool bNoData = pRecord->
is_NoData(Field);
653 *(pRecord->
m_Values[Field]) = *pValue;
708 if( Length < nBytes )
717 return( (
int)Length );
772 #define GET_GROW_SIZE(n) (n < 256 ? 1 : (n < 8192 ? 128 : 1024))
775 bool CSG_Table::_Inc_Array(
void)
784 if( pRecords == NULL )
789 m_Records = pRecords;
796 bool CSG_Table::_Dec_Array(
void)
805 if( pRecords == NULL )
810 m_Records = pRecords;
851 if( Selection[i] > iRecord )
860 m_Records[i] = m_Records[i - 1]; m_Records[i]->
m_Index = i;
866 m_Records[iRecord] = pRecord;
888 if( iRecord >= 0 && iRecord <
m_nRecords && pCopy )
890 return( m_Records[iRecord]->
Assign(pCopy) );
906 delete(m_Records[iRecord]);
912 m_Records[i] = m_Records[i + 1]; m_Records[i]->
m_Index = i;
942 delete(m_Records[iRecord]);
960 else if( nRecords >= 0 &&
m_nRecords > nRecords )
983 return( Value.
Cmp(m_Records[iRecord = 0]->
asString(Field)) == 0 );
996 if( Value.
Cmp(m_Records[iRecord]->
asString(Field)) == 0 )
1006 #define GET_RECORD(i) Get_Record_byIndex(bAscending ? (iRecord = i) : m_nRecords - 1 - (iRecord = i))
1010 if( (d = Value.
Cmp(
GET_RECORD(0 )->asString(Field))) < 0 ) {
return(
false ); }
else if( d == 0 ) {
return(
true ); }
1011 if( (d = Value.
Cmp(
GET_RECORD(
m_nRecords - 1)->asString(Field))) > 0 ) {
return(
false ); }
else if( d == 0 ) {
return(
true ); }
1015 d = Value.
Cmp(
GET_RECORD(a + (b - a) / 2)->asString(Field));
1045 if(
Find_Record(iRecord, Field, Value, bCreateIndex) )
1063 return( Value == m_Records[iRecord = 0]->asDouble(Field) );
1074 for(iRecord=0; iRecord<
m_nRecords; iRecord++)
1076 if( Value == m_Records[iRecord]->asDouble(Field) )
1086 #define GET_RECORD(i) Get_Record_byIndex(bAscending ? (iRecord = i) : m_nRecords - 1 - (iRecord = i))
1090 if( (d = Value -
GET_RECORD(0 )->asDouble(Field)) < 0. ) {
return(
false ); }
else if( d == 0. ) {
return(
true ); }
1091 if( (d = Value -
GET_RECORD(
m_nRecords - 1)->asDouble(Field)) > 0. ) {
return(
false ); }
else if( d == 0. ) {
return(
true ); }
1095 d = Value -
GET_RECORD(a + (b - a) / 2)->asDouble(Field);
1125 if(
Find_Record(iRecord, Field, Value, bCreateIndex) )
1147 if( bModified ==
false )
1149 #pragma omp parallel for
1165 return( pRecord && pRecord->
Set_Value(Field, Value) );
1178 return( pRecord && pRecord->
Set_Value(Field, Value) );
1213 return( pRecord->
is_NoData(Field) ==
false );
1230 for(
int Field=0; Field<
m_nFields; Field++)
1270 for(
double i=0; i<(double)
Get_Count(); i+=d)
1274 Statistics += Value;
1290 Statistics += Value;
1369 m_Records[i] = Records[Index[i]];
1445 m_Index_Fields[0] = -m_Index_Fields[0]; m_Index.
Invert();
1462 CSG_Table_Record_Compare_Field(
const CSG_Table *pTable,
int Field,
bool Ascending)
1466 m_Ascending = Ascending;
1468 if( !m_pTable || m_Field < 0 || m_Field >= m_pTable->Get_Field_Count() )
1474 bool is_Okay (
void)
const {
return( m_pTable != NULL ); }
1476 virtual int Compare (
const sLong _a,
const sLong _b)
1478 sLong a = m_Ascending ? _a : _b;
1479 sLong b = m_Ascending ? _b : _a;
1481 switch( m_pTable->Get_Field_Type(m_Field) )
1483 default: {
double Value[2] = { 0., 0. };
1484 m_pTable->
Get_Value(a, m_Field, Value[0]);
1485 m_pTable->Get_Value(b, m_Field, Value[1]);
1486 return( Value[0] < Value[1] ? -1 : Value[0] > Value[1] ? 1 : 0 ); }
1490 m_pTable->Get_Value(a, m_Field, Value[0]);
1491 m_pTable->Get_Value(b, m_Field, Value[1]);
1492 return( Value[0].Cmp(Value[1]) ); }
1510 CSG_Table_Record_Compare_Field Compare(
this, Field, bAscending);
1524 CSG_Table_Record_Compare_Fields(
const CSG_Table *pTable,
int Fields[],
int nFields,
bool Ascending)
1525 : m_Fields(Fields),
m_nFields(nFields), m_pTable(pTable)
1527 m_Ascending.Create(nFields);
1529 for(
int i=0; m_pTable && i<
m_nFields; i++)
1531 if( m_Fields[i] >= m_pTable->Get_Field_Count() )
1536 m_Ascending[i] = Ascending ? 1 : 0;
1540 CSG_Table_Record_Compare_Fields(
const CSG_Table *pTable,
int Fields[],
int nFields,
int Ascending[])
1541 : m_Fields(Fields),
m_nFields(nFields), m_pTable(pTable)
1543 m_Ascending.Create(nFields);
1545 for(
int i=0; m_pTable && i<
m_nFields; i++)
1547 if( m_Fields[i] >= m_pTable->Get_Field_Count() )
1552 m_Ascending[i] = Ascending[i] > 0 ? 1 : 0;
1556 bool is_Okay (
void)
const {
return( m_pTable != NULL ); }
1558 virtual int Compare (
const sLong _a,
const sLong _b)
1562 for(
int i=0; !Difference && i<
m_nFields; i++)
1564 int Field = m_Fields[i];
1566 sLong a = m_Ascending[i] ? _a : _b;
1567 sLong b = m_Ascending[i] ? _b : _a;
1569 switch( m_pTable->Get_Field_Type(Field) )
1571 default: {
double Value[2] = { 0., 0. };
1572 m_pTable->Get_Value(a, Field, Value[0]);
1573 m_pTable->Get_Value(b, Field, Value[1]);
1574 Difference = Value[0] < Value[1] ? -1 : Value[0] > Value[1] ? 1 : 0;
1579 m_pTable->Get_Value(a, Field, Value[0]);
1580 m_pTable->Get_Value(b, Field, Value[1]);
1581 Difference = Value[0].
Cmp(Value[1]);
1586 return( Difference );
1603 CSG_Table_Record_Compare_Fields Compare(
this, Fields, nFields, bAscending);
1615 void CSG_Table::_Index_Update(
void)
1617 if( m_Index_Fields.
Get_Size() < 1 )
1626 Fields += abs(m_Index_Fields[i]) - 1;
1627 Ascending += m_Index_Fields[i] > 0 ? 1 : 0;
friend class CSG_Table_Record
virtual bool Assign(CSG_Data_Object *pObject, bool bProgress=false)
CSG_String BeforeFirst(char Character) const
double asDouble(int Field) const
sLong Get_Max_Samples(void) const
#define SG_FREE_SAFE(PTR)
CSG_Table * SG_Create_Table(void)
TSG_Data_Type Get_Field_Type(int Field) const
CSG_Histogram m_Histogram
virtual bool Set_Count(sLong nRecords)
virtual bool _Histogram_Update(int Field, size_t nClasses) const
@ SG_TABLE_VALUE_TYPE_String
virtual bool Del_Records(void)
sLong Get_Size(void) const
void Set_File_Name(const CSG_String &FileName)
size_t Length(void) const
virtual bool Get_Value(sLong Index, int Field, CSG_String &Value) const
const SG_Char * Get_Description(void) const
double Get_NoData_Value(bool bUpper=false) const
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.
@ SG_UI_MSG_STYLE_SUCCESS
virtual bool Set_Field_Type(int Field, TSG_Data_Type Type)
virtual bool is_Selected(sLong Index) const
virtual CSG_Table_Record * Get_Record(sLong Index) const
SAGA_API_DLL_EXPORT void * SG_Malloc(size_t size)
sLong Get_Size(void) const
virtual bool _Stats_Update(int Field) const
size_t SG_Data_Type_Get_Size(TSG_Data_Type Type)
CSG_Table & operator=(const CSG_Table &Table)
virtual bool Assign(CSG_Table_Record *pRecord)
bool Reset_Statistics(void)
virtual bool Destroy(void)
const SG_Char * Get_Name(void) const
bool Create(const CSG_Histogram &Histogram)
@ SG_FILE_ENCODING_UTF32BE
TSG_Table_Index_Order Get_Index_Order(int i) const
bool Set_Field_Name(int Field, const SG_Char *Name)
int Get_Field_Count(void) const
int * Get_Array(void) const
SAGA_API_DLL_EXPORT void SG_Free(void *memblock)
class CSG_Table_Value ** m_Values
CSG_Field_Info ** m_Field_Info
virtual bool Set_Record(sLong Index, CSG_Table_Record *pCopy)
virtual ~CSG_Field_Info(void)
virtual bool Find_Record(sLong &Index, int Field, const CSG_String &Value, bool bCreateIndex=false)
void Set_Update_Flag(bool bOn=true)
bool is_NoData(int Field) const
virtual void Set_Modified(bool bModified=true)
int Cmp(const CSG_String &String) const
bool _Stats_Invalidate(void) const
int Find_Field(const CSG_String &Name) const
@ SG_UI_MSG_STYLE_FAILURE
bool is_Compatible(const CSG_Table &Table, bool bExactMatch=false) const
SAGA_API_DLL_EXPORT bool SG_File_Exists(const CSG_String &FileName)
virtual TSG_Table_Value_Type Get_Type(void) const =0
const SG_Char * asString(int Field, int Decimals=-99) const
virtual bool On_NoData_Changed(void)
sLong Get_Count(void) const
sLong Get_Selection_Count(void) const
bool Create(sLong nValues, CSG_Index_Compare &Compare)
#define SG_TABLE_REC_FLAG_Modified
const SG_Char * Get_Field_Name(int Field) const
virtual int Get_Field_Length(int Field, int Encoding=SG_FILE_ENCODING_UNDEFINED) const
bool SG_Data_Type_is_Numeric(TSG_Data_Type Type)
virtual bool On_Update(void)
bool is_Indexed(void) const
virtual bool On_NoData_Changed(void)
@ SG_FILE_ENCODING_UTF32LE
sLong Get_Count(void) const
static CSG_Table_Value * _Create_Value(TSG_Data_Type Type)
virtual bool On_Update(void)
virtual bool is_Modified(void) const
bool Assign_Values(const CSG_Table &Table)
int is_Evaluated(void) const
int Get_Index_Field(int i) const
virtual void Set_Modified(bool bOn=true)
void * Create(const CSG_Array &Array)
bool Toggle_Index(int Field)
void * Get_Array(void) const
CSG_Table_Record * Get_Record_byIndex(sLong Index) const
class CSG_Table * asTable(bool bPolymorph=false) const
bool _Add_Field(int add_Field)
void Set_Name(const CSG_String &Name)
void Set_Modified(bool bOn=true)
size_t Get_Class_Count(void) const
bool Add_Entry(sLong Position=-1)
bool Set_Count(sLong Count)
static CSG_String Format(const char *Format,...)
bool _Del_Selection(sLong Index)
@ SG_FILE_ENCODING_UTF16LE
virtual bool Assign(CSG_Data_Object *pTable, bool bProgress=false)
virtual bool Add_Field(const CSG_String &Name, TSG_Data_Type Type, int Position=-1)
size_t to_UTF8(char **pString) const
@ SG_DATAOBJECT_TYPE_Shapes
CSG_String AfterFirst(char Character) const
CSG_Simple_Statistics m_Statistics
virtual bool Del_Record(sLong Index)
bool Load(const CSG_String &File, int Format, SG_Char Separator, int Encoding=SG_FILE_ENCODING_UNDEFINED)
@ SG_DATAOBJECT_TYPE_Table
void Set_Description(const CSG_String &Description)
bool SG_UI_Process_Set_Progress(int Position, int Range)
@ SG_FILE_ENCODING_UTF16BE
virtual bool Set_Value(const CSG_Bytes &Value)=0
bool Set_Value(int Field, const CSG_String &Value)
virtual bool Del_Field(int Field)
virtual CSG_Table_Record * Ins_Record(sLong Index, CSG_Table_Record *pCopy=NULL)
sLong Get_Index(void) const
virtual bool Set_Value(sLong Index, int Field, const SG_Char *Value)
double asDouble(void) const
void SG_UI_ProgressAndMsg_Lock(bool bOn)
const SG_Char * c_str(void) const
CSG_Table_Value * Get_Value(int Field)
virtual const SG_Char * asString(int Decimals=-99) const =0
SAGA_API_DLL_EXPORT void * SG_Realloc(void *memblock, size_t size)
bool Set_Index(CSG_Index &Index, int Field, bool bAscending=true) const
sLong Get_Count(void) const
virtual CSG_Table_Record * Add_Record(CSG_Table_Record *pCopy=NULL)
bool Sort(const char *Field, bool bAscending=true)
bool Del_Entry(sLong Position=-1)
int Get_Field(const CSG_String &Name) const
virtual bool Set_NoData_Value_Range(double Lower, double Upper)
virtual bool Destroy(void)
virtual CSG_Table_Record * _Get_New_Record(sLong Index)
@ SG_DATAOBJECT_TYPE_PointCloud
void SG_UI_Msg_Add(const char *Message, bool bNewLine, TSG_UI_MSG_STYLE Style)
bool _Del_Field(int del_Field)
virtual void _On_Construction(void)
CSG_Shapes * SG_Create_Shapes(void)
virtual bool Mov_Field(int Field, int Position)