// CodeGear C++Builder
// Copyright (c) 1995, 2021 by Embarcadero Technologies, Inc.
// All rights reserved

// (DO NOT EDIT: machine generated header) 'ABSRelationalAlgebra.pas' rev: 35.00 (Windows)

#ifndef AbsrelationalalgebraHPP
#define AbsrelationalalgebraHPP

#pragma delphiheader begin
#pragma option push
#pragma option -w-      // All warnings off
#pragma option -Vx      // Zero-length empty class member 
#pragma pack(push,8)
#include <System.hpp>
#include <SysInit.hpp>
#include <Winapi.Windows.hpp>
#include <System.Classes.hpp>
#include <Data.DB.hpp>
#include <System.SysUtils.hpp>
#include <System.Math.hpp>
#include <ABSConst.hpp>
#include <ABSConverts.hpp>
#include <ABSExcept.hpp>
#include <ABSBase.hpp>
#include <ABSTypes.hpp>
#include <ABSVariant.hpp>

//-- user supplied -----------------------------------------------------------

namespace Absrelationalalgebra
{
//-- forward type declarations -----------------------------------------------
struct TABSFieldLink;
struct TABSSelectListItem;
class DELPHICLASS TABSFields;
class DELPHICLASS TABSAO;
class DELPHICLASS TABSAOTable;
class DELPHICLASS TABSAOJoin;
class DELPHICLASS TABSAOUnion;
class DELPHICLASS TABSAOTableExpr;
class DELPHICLASS TABSAOGroupBy;
class DELPHICLASS TABSAOSQLTopRowCount;
//-- type declarations -------------------------------------------------------
struct DECLSPEC_DRECORD TABSFieldLink
{
public:
	System::UnicodeString FieldName;
	System::UnicodeString DisplayName;
	Abstypes::TABSAdvancedFieldType FieldType;
	int FieldPrecision;
	int FieldSize;
	System::Byte BLOBCompressionAlgorithm;
	System::Byte BLOBCompressionMode;
	int BLOBBlockSize;
	void *AO;
	Data::Db::TDataSet* Dataset;
	bool IsHidden;
	int FieldNo;
	bool IsExpression;
	bool IsAggregate;
	System::TObject* Expr;
};


struct DECLSPEC_DRECORD TABSSelectListItem
{
public:
	System::UnicodeString TableName;
	bool AllFields;
	System::UnicodeString FieldName;
	bool IsExpression;
	bool IsDuplicatedField;
	System::TObject* ValueExpr;
	System::UnicodeString Pseudonym;
};


#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSFields : public System::TObject
{
	typedef System::TObject inherited;
	
	
private:
	typedef System::DynamicArray<TABSSelectListItem> _TABSFields__1;
	
	
public:
	_TABSFields__1 Items;
	int ItemCount;
	__fastcall TABSFields();
	void __fastcall Append(TABSSelectListItem &Item);
public:
	/* TObject.Destroy */ inline __fastcall virtual ~TABSFields() { }
	
};

#pragma pack(pop)

class PASCALIMPLEMENTATION TABSAO : public System::TObject
{
	typedef System::TObject inherited;
	
	
private:
	typedef System::DynamicArray<int> _TABSAO__1;
	
	typedef System::DynamicArray<TABSFieldLink> _TABSAO__2;
	
	
public:
	bool FIsRootAO;
	bool FIsAOTable;
	bool FIsAOGroupBy;
	System::TObject* FFilterExpr;
	__int64 FTopRowCount;
	__int64 FFirstRowNo;
	bool FHasSetResultFields;
	System::UnicodeString FResultTableName;
	
protected:
	bool FResultInMemory;
	bool FResultImmediate;
	System::UnicodeString FResultDatabaseName;
	System::UnicodeString FTableName;
	System::UnicodeString FTableAlias;
	bool FIsMaterialized;
	Data::Db::TDataSet* FResultDataset;
	Abstypes::TABSIntegerArray* FResultFieldsOrder;
	int FFieldCount;
	bool FLeftAONull;
	bool FRightAONull;
	bool FDistinctApplied;
	System::UnicodeString FDistinctFields;
	int FDistinctFieldCount;
	_TABSAO__1 FDistinctFieldsMap;
	System::Classes::TStringList* FResultIndexFieldsList;
	System::Classes::TStringList* FResultIndexAscDescFieldsList;
	System::Classes::TStringList* FResultIndexCaseInsFieldsList;
	bool FExpressionsExists;
	bool FIsLocked;
	bool FDisableTempFiles;
	Absvariant::TABSVariant* FValue;
	_TABSAO__2 FFieldLinks;
	
public:
	TABSAO* FLeftAO;
	TABSAO* FRightAO;
	
protected:
	void __fastcall InternalCreate(TABSAO* LeftAO = (TABSAO*)(0x0), TABSAO* RightAO = (TABSAO*)(0x0), System::UnicodeString TableName = System::UnicodeString(), System::UnicodeString TableAlias = System::UnicodeString());
	virtual void __fastcall InternalFirst();
	virtual void __fastcall InternalNext();
	virtual bool __fastcall InternalGetEof();
	virtual int __fastcall InternalGetRecordCount();
	virtual void __fastcall First();
	virtual void __fastcall Next();
	virtual bool __fastcall GetEof();
	virtual int __fastcall GetRecordCount();
	virtual void __fastcall SetFieldNames();
	System::UnicodeString __fastcall CreateIndexForMaterialize(bool BeforeCreateTable);
	void __fastcall CreateTableForMaterialize(System::Classes::TStringList* FieldList, System::Classes::TStringList* AliasList);
	void __fastcall FillTableForMaterialize();
	void __fastcall ReplaceInIndexAliasesToFields(System::Classes::TStringList* FieldList, System::Classes::TStringList* AliasList, System::Classes::TStringList* FResultIndexFieldsList);
	void __fastcall FinalizeMaterialize(System::Classes::TStringList* FieldList, System::Classes::TStringList* AliasList);
	void __fastcall DoMaterialize();
	
public:
	__fastcall virtual ~TABSAO();
	virtual void __fastcall Execute(bool IsRootAO, TABSAO* ParentQueryAO, Absbase::TABSCursor* ParentCursor);
	bool __fastcall LockTables();
	bool __fastcall UnlockTables();
	bool __fastcall OpenTables();
	bool __fastcall CloseTables();
	void __fastcall SetFilter(System::TObject* FilterExpr);
	void __fastcall SetResultTable(bool InMemory, bool Immediate, System::UnicodeString TableName, System::UnicodeString DatabaseName);
	virtual void __fastcall SetTopRowCount(int FirstRowNo, int TopRowCount);
	void __fastcall ApplyDistinct(System::UnicodeString DistinctFields);
	virtual void __fastcall SetResultFields(TABSSelectListItem *FieldRefs, const int FieldRefs_High, bool bDistinct);
	virtual int __fastcall FieldExists(System::UnicodeString FieldName, System::UnicodeString TableName, bool Unhide, Abstypes::TABSIntegerArray* FieldNumbers = (Abstypes::TABSIntegerArray*)(0x0), bool UnhideChildrenOnly = false, bool ScanOnlyVisibleFields = false);
	bool __fastcall FindFieldInFieldLinks(System::UnicodeString FieldName, int &FieldNo);
	System::UnicodeString __fastcall GetFieldName(int FieldNo, bool ApplyOrderBy = false);
	System::UnicodeString __fastcall GetFieldNameByColumnName(System::UnicodeString ColumnName);
	System::UnicodeString __fastcall GetFieldNameByColumnNo(int ColumnNo);
	System::UnicodeString __fastcall GetFieldNameByVisibleNumber(int VisibleFieldNo);
	int __fastcall GetFieldNoByVisibleNumber(int VisibleFieldNo);
	void __fastcall GetFieldValue(Absvariant::TABSVariant* Value, int FieldNo, bool bCopy = false, bool AccessToHidden = false);
	Abstypes::TABSAdvancedFieldType __fastcall GetFieldType(int FieldNo)/* overload */;
	int __fastcall GetFieldSize(int FieldNo);
	int __fastcall GetFieldPrecision(int FieldNo);
	void __fastcall CopyFieldValue(int SrcFieldNo, int DestFieldNo);
	bool __fastcall GetFieldDatsetAndFieldNo(Data::Db::TDataSet* &SrcFieldDatset, int &SrcFieldDatasetFieldNo);
	
private:
	void __fastcall InternalSetDistinct();
	void __fastcall InternalSetIndex(bool ToClearFields = true);
	void __fastcall CreateResultIndexLists(bool ToClear = true);
	void __fastcall FreeResultIndexLists();
	void __fastcall AddFieldLink(int FieldLinkNo, bool SkipHiddenFields = true);
	
public:
	virtual void __fastcall SetIndex(System::UnicodeString IndexFieldNames, System::UnicodeString DescFields, System::UnicodeString CaseInsensitiveFields);
	__property bool IsMaterialized = {read=FIsMaterialized, nodefault};
	__property int FieldCount = {read=FFieldCount, nodefault};
	__property int RecordCount = {read=GetRecordCount, nodefault};
	__property Data::Db::TDataSet* ResultDataset = {read=FResultDataset};
	__property bool Eof = {read=GetEof, nodefault};
	__property System::UnicodeString TableAlias = {read=FTableAlias, write=FTableAlias};
public:
	/* TObject.Create */ inline __fastcall TABSAO() : System::TObject() { }
	
};


class PASCALIMPLEMENTATION TABSAOTable : public TABSAO
{
	typedef TABSAO inherited;
	
private:
	System::TObject* FDatabase;
	
public:
	__fastcall TABSAOTable(System::UnicodeString TableName, System::UnicodeString TableAlias, System::TObject* DB, Data::Db::TDataSet* Table);
	__fastcall virtual ~TABSAOTable();
	virtual void __fastcall Execute(bool IsRootAO, TABSAO* ParentQueryAO, Absbase::TABSCursor* ParentCursor);
	virtual void __fastcall SetResultFields(TABSSelectListItem *FieldRefs, const int FieldRefs_High, bool bDistinct);
	bool __fastcall TransferIndexToParentIfNeeded(System::Classes::TStringList* &FieldNamesList, System::Classes::TStringList* &AscDescList, System::Classes::TStringList* &CaseSensitivityList);
	__property IsMaterialized;
	__property FieldCount;
	__property RecordCount;
	__property ResultDataset;
	__property Eof;
};


class PASCALIMPLEMENTATION TABSAOJoin : public TABSAO
{
	typedef TABSAO inherited;
	
private:
	bool FDekart;
	bool FOuterJoin;
	bool FInnerJoin;
	Abstypes::TABSJoinType FJoinType;
	Abstypes::TABSIntegerArray* FFields1;
	Abstypes::TABSIntegerArray* FFields2;
	System::TObject* FJoinCondition;
	Abstypes::TABSCompareResult FCompareResult;
	bool FEqualStarted;
	bool FFirstTimeCalled;
	bool FEof;
	System::DynamicArray<System::Byte> FRightBeginBookmark;
	System::DynamicArray<System::Byte> FRightEndBookmark;
	bool FBothNullsStarted;
	bool FLeftAOEmpty;
	bool FRightAOEmpty;
	int FLinkCount;
	bool FFieldsLink;
	
protected:
	void __fastcall CompareRecords()/* overload */;
	virtual void __fastcall InternalFirst();
	virtual void __fastcall InternalNext();
	virtual bool __fastcall InternalGetEof();
	virtual int __fastcall InternalGetRecordCount();
	
public:
	__fastcall TABSAOJoin(TABSAO* LeftChild, TABSAO* RightChild, Abstypes::TABSJoinType JoinType, bool IsNatural, TABSFields* FieldList1, TABSFields* FieldList2, System::TObject* JoinCondition);
	__fastcall virtual ~TABSAOJoin();
	virtual void __fastcall Execute(bool IsRootAO, TABSAO* ParentQueryAO, Absbase::TABSCursor* ParentCursor);
	__property IsMaterialized;
	__property FieldCount;
	__property RecordCount;
	__property ResultDataset;
	__property Eof;
	__property bool OuterJoin = {read=FOuterJoin, nodefault};
};


class PASCALIMPLEMENTATION TABSAOUnion : public TABSAO
{
	typedef TABSAO inherited;
	
private:
	bool FEof;
	Abstypes::TABSUnionType FUnionType;
	Abstypes::TABSIntegerArray* FFields1;
	Abstypes::TABSIntegerArray* FFields2;
	Abstypes::TABSCompareResult FCompareResult;
	bool FFirstTimeCalled;
	bool FShowLeft;
	
protected:
	void __fastcall CompareRecords();
	void __fastcall ShowLeftAO();
	void __fastcall ShowRightAO();
	virtual void __fastcall InternalFirst();
	virtual void __fastcall InternalNext();
	virtual bool __fastcall InternalGetEof();
	virtual int __fastcall InternalGetRecordCount();
	
public:
	__fastcall TABSAOUnion(TABSAO* LeftChild, TABSAO* RightChild, Abstypes::TABSUnionType UnionType, TABSAO* ParentQueryAO, Absbase::TABSCursor* ParentCursor, bool IsCorresponding, bool bDistinct, TABSFields* FieldList);
	__fastcall virtual ~TABSAOUnion();
	__property IsMaterialized;
	__property FieldCount;
	__property RecordCount;
	__property ResultDataset;
	__property Eof;
};


class PASCALIMPLEMENTATION TABSAOTableExpr : public TABSAO
{
	typedef TABSAO inherited;
	
private:
	void __fastcall ReplacePseudonymsInIndexFields();
	void __fastcall AddHiddenIndexFields();
	
protected:
	virtual void __fastcall InternalFirst();
	virtual void __fastcall InternalNext();
	virtual bool __fastcall InternalGetEof();
	virtual int __fastcall InternalGetRecordCount();
	
public:
	__fastcall TABSAOTableExpr(TABSAO* Child);
	virtual void __fastcall SetTopRowCount(int FirstRowNo, int TopRowCount);
	virtual void __fastcall Execute(bool IsRootAO, TABSAO* ParentQueryAO, Absbase::TABSCursor* ParentCursor);
	__property IsMaterialized;
	__property FieldCount;
	__property RecordCount;
	__property ResultDataset;
	__property Eof;
public:
	/* TABSAO.Destroy */ inline __fastcall virtual ~TABSAOTableExpr() { }
	
};


class PASCALIMPLEMENTATION TABSAOGroupBy : public TABSAO
{
	typedef TABSAO inherited;
	
protected:
	Data::Db::TDataSet* FTempDataset;
	bool FFirstTimeCalled;
	bool FAllFields;
	Abstypes::TABSIntegerArray* FFields;
	Abstypes::TABSCompareResult FCompareResult;
	bool FGroupFinished;
	bool FEOF;
	System::UnicodeString GroupByFields;
	void __fastcall CompareRecords();
	virtual void __fastcall InternalFirst();
	virtual void __fastcall InternalNext();
	virtual bool __fastcall InternalGetEof();
	virtual int __fastcall InternalGetRecordCount();
	bool __fastcall IsCountAll();
	void __fastcall DoCountAll();
	
public:
	virtual void __fastcall SetResultFields(TABSSelectListItem *FieldRefs, const int FieldRefs_High, bool bDistinct);
	__fastcall TABSAOGroupBy(TABSAO* Child, TABSFields* FieldList, TABSSelectListItem *FieldRefs, const int FieldRefs_High);
	__fastcall virtual ~TABSAOGroupBy();
	__property IsMaterialized;
	__property FieldCount;
	__property RecordCount;
	__property ResultDataset;
	__property Eof;
};


class PASCALIMPLEMENTATION TABSAOSQLTopRowCount : public TABSAO
{
	typedef TABSAO inherited;
	
protected:
	virtual void __fastcall InternalFirst();
	virtual void __fastcall InternalNext();
	virtual bool __fastcall InternalGetEof();
	virtual int __fastcall InternalGetRecordCount();
	
public:
	__fastcall TABSAOSQLTopRowCount(TABSAO* Child);
	virtual void __fastcall SetTopRowCount(int FirstRowNo, int TopRowCount);
	__property IsMaterialized;
	__property FieldCount;
	__property RecordCount;
	__property ResultDataset;
	__property Eof;
public:
	/* TABSAO.Destroy */ inline __fastcall virtual ~TABSAOSQLTopRowCount() { }
	
};


//-- var, const, procedure ---------------------------------------------------
extern DELPHI_PACKAGE void __fastcall ConvertIndexFieldNamesToLists(System::UnicodeString FieldNames, System::UnicodeString DescFields, System::UnicodeString CaseInsFields, System::Classes::TStringList* FieldList, System::Classes::TStringList* AscDescList, System::Classes::TStringList* CaseInsList);
extern DELPHI_PACKAGE void __fastcall ConvertListsToIndexFieldNames(System::UnicodeString &FieldNames, System::UnicodeString &DescNames, System::UnicodeString &CaseInsNames, System::Classes::TStringList* FieldList, System::Classes::TStringList* AscDescList, System::Classes::TStringList* CaseInsList);
}	/* namespace Absrelationalalgebra */
#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_ABSRELATIONALALGEBRA)
using namespace Absrelationalalgebra;
#endif
#pragma pack(pop)
#pragma option pop

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif	// AbsrelationalalgebraHPP
