// Borland C++ Builder
// Copyright (c) 1995, 2005 by Borland Software Corporation
// All rights reserved

// (DO NOT EDIT: machine generated header) 'Fibcachemanage.pas' rev: 10.00

#ifndef FibcachemanageHPP
#define FibcachemanageHPP

#pragma delphiheader begin
#pragma option push
#pragma option -w-      // All warnings off
#pragma option -Vx      // Zero-length empty class member functions
#pragma pack(push,8)
#include <System.hpp>	// Pascal unit
#include <Sysinit.hpp>	// Pascal unit
#include <Sysutils.hpp>	// Pascal unit
#include <Pfiblists.hpp>	// Pascal unit
#include <Classes.hpp>	// Pascal unit

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

namespace Fibcachemanage
{
//-- type declarations -------------------------------------------------------
typedef char *TBlockArray[1];

typedef TBlockArray *PBlockArray;

typedef int TIntArray[1];

typedef TIntArray *PIntArray;

struct TRecordPosition
{
	
public:
	int RecordNo;
	int InternalNo;
} ;

typedef TRecordPosition *PRecordPosition;

typedef TRecordPosition TRecPositions[1];

typedef TRecPositions *PRecPositions;

class DELPHICLASS TRecordsCache;
class PASCALIMPLEMENTATION TRecordsCache : public System::TObject 
{
	typedef System::TObject inherited;
	
private:
	Classes::TList* FMapRecords;
	Pfiblists::TStringCollection* FStringData;
	Pfiblists::TStringCollection* FLogStringData;
	Classes::TList* FBlocks;
	Classes::TList* FChangeLog;
	TRecPositions *FChangesPositions;
	int FOldBufRecordNumber;
	char *FOldBuffer;
	int FBlockSize;
	int FRecordSize;
	int FInOutRecordSize;
	int FRecordCount;
	int FChangesCount;
	TIntArray *FStringFieldOffsets;
	TIntArray *FStringFieldSize;
	int FRecInBlock;
	int FStrFieldCount;
	bool FSaveChangeLog;
	void __fastcall SetBlockCount(int NewCount);
	int __fastcall GetBlockCount(void);
	void __fastcall SetChangeLogBlockCount(int NewCount);
	int __fastcall InternalRecordNo(const int RecordNo);
	int __fastcall GetSize(void);
	PRecordPosition __fastcall GetChangePosition(int aRecordNo, bool Force);
	bool __fastcall FindChangeRecNo(const int ARecno, int &Index);
	void __fastcall InitializeMap(void);
	int __fastcall GetChangesBlockCount(void);
	
public:
	__fastcall TRecordsCache(int aBlockRecCount, int aRecordSize, int aBlockReadSize, int aStrCount);
	__fastcall virtual ~TRecordsCache(void);
	void __fastcall ShiftMapValues(int Distance);
	void __fastcall Assign(TRecordsCache* SourceCache);
	int __fastcall CreateNewBlock(void);
	char * __fastcall PrepareMemory(int RecordNo);
	bool __fastcall MemoryPrepared(int RecordNo);
	char * __fastcall PRecBuffer(const int RecordNo, bool Old);
	int __fastcall RecordPosition(const int RecordNo, bool IsInternalRecno = false);
	int __fastcall RecordBlock(const int RecordNo, bool ForceAllocMem, bool IsInternalRecno = false);
	void __fastcall SetStrOffset(int Index, int Offset, int DataSize);
	int __fastcall Capacity(void);
	void __fastcall ReadRecord(const int RecordNo, char * &Dest);
	void __fastcall ReadRecordBuffer(int RecordNo, char * &Dest, bool Old);
	void * __fastcall GetFieldData(const int RecordNo, const int FieldOffSet, const int StrIndex, void * &RecordData);
	void __fastcall WriteRecord(int RecordNo, const char * Source, bool ForceAllocMem);
	void __fastcall WriteField(int RecordNo, int FieldOffSet, const char * Data, int SizeData);
	void __fastcall SetStringValue(int Index, int RecordNo, const AnsiString Value);
	void __fastcall SetStringFromPChar(int Index, int RecordNo, const char * Value, int Len, bool Triming);
	void __fastcall SaveOldBuffer(int RecordNo);
	void __fastcall ClearOldBuffer(void);
	void __fastcall SaveToChangeLog(int aRecordNo);
	char * __fastcall OldBuffer(int RecordNo);
	char * __fastcall pRecBuff(int RecordNo);
	void __fastcall RevertRecord(int aRecordNo);
	void __fastcall ClearLog(void);
	void __fastcall SwapRecords(int OldRecordNo, int NewRecordNo);
	void __fastcall MoveRecord(int OldRecno, int NewRecno);
	void __fastcall SaveToStream(Classes::TStream* Stream, bool SeekBegin);
	void __fastcall LoadFromStream(Classes::TStream* Stream, bool SeekBegin);
	void __fastcall Insert(int RecordNo);
	void __fastcall CancelInsert(int RecordNo);
	int __fastcall BookMarkByRecord(int RecordNo);
	int __fastcall RecordByBookMark(int BookMark);
	bool __fastcall BookMarkValid(int BookMark);
	__property int ChangesBlockCount = {read=GetChangesBlockCount, write=SetChangeLogBlockCount, nodefault};
	__property int RecordSize = {read=FRecordSize, nodefault};
	__property int BlockCount = {read=GetBlockCount, write=SetBlockCount, nodefault};
	__property int RecordCount = {read=FRecordCount, nodefault};
	__property int Size = {read=GetSize, nodefault};
	__property bool SaveChangeLog = {read=FSaveChangeLog, write=FSaveChangeLog, nodefault};
};


class DELPHICLASS EMemManagerError;
class PASCALIMPLEMENTATION EMemManagerError : public Sysutils::Exception 
{
	typedef Sysutils::Exception inherited;
	
public:
	#pragma option push -w-inl
	/* Exception.Create */ inline __fastcall EMemManagerError(const AnsiString Msg) : Sysutils::Exception(Msg) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateFmt */ inline __fastcall EMemManagerError(const AnsiString Msg, System::TVarRec const * Args, const int Args_Size) : Sysutils::Exception(Msg, Args, Args_Size) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateRes */ inline __fastcall EMemManagerError(int Ident)/* overload */ : Sysutils::Exception(Ident) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateResFmt */ inline __fastcall EMemManagerError(int Ident, System::TVarRec const * Args, const int Args_Size)/* overload */ : Sysutils::Exception(Ident, Args, Args_Size) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateHelp */ inline __fastcall EMemManagerError(const AnsiString Msg, int AHelpContext) : Sysutils::Exception(Msg, AHelpContext) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateFmtHelp */ inline __fastcall EMemManagerError(const AnsiString Msg, System::TVarRec const * Args, const int Args_Size, int AHelpContext) : Sysutils::Exception(Msg, Args, Args_Size, AHelpContext) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateResHelp */ inline __fastcall EMemManagerError(int Ident, int AHelpContext)/* overload */ : Sysutils::Exception(Ident, AHelpContext) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateResFmtHelp */ inline __fastcall EMemManagerError(System::PResStringRec ResStringRec, System::TVarRec const * Args, const int Args_Size, int AHelpContext)/* overload */ : Sysutils::Exception(ResStringRec, Args, Args_Size, AHelpContext) { }
	#pragma option pop
	
public:
	#pragma option push -w-inl
	/* TObject.Destroy */ inline __fastcall virtual ~EMemManagerError(void) { }
	#pragma option pop
	
};


//-- var, const, procedure ---------------------------------------------------
static const Word MinBlockSize = 0x400;

}	/* namespace Fibcachemanage */
using namespace Fibcachemanage;
#pragma pack(pop)
#pragma option pop

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