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

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

#ifndef FibmiscellaneousHPP
#define FibmiscellaneousHPP

#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 <Windows.hpp>	// Pascal unit
#include <Sysutils.hpp>	// Pascal unit
#include <Classes.hpp>	// Pascal unit
#include <Ibase.hpp>	// Pascal unit
#include <Ib_intf.hpp>	// Pascal unit
#include <Ib_externals.hpp>	// Pascal unit
#include <Db.hpp>	// Pascal unit
#include <Fib.hpp>	// Pascal unit
#include <Fibdatabase.hpp>	// Pascal unit
#include <Fibquery.hpp>	// Pascal unit
#include <Stdfuncs.hpp>	// Pascal unit
#include <Ib_errorcodes.hpp>	// Pascal unit

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

namespace Fibmiscellaneous
{
//-- type declarations -------------------------------------------------------
class DELPHICLASS TFIBBlobStream;
class PASCALIMPLEMENTATION TFIBBlobStream : public Classes::TStream 
{
	typedef Classes::TStream inherited;
	
private:
	Fibdatabase::TFIBDatabase* FDatabase;
	Fibdatabase::TFIBTransaction* FTransaction;
	Fibdatabase::TFIBTransaction* FUpdateTransaction;
	Ibase::TGDS_QUAD FBlobID;
	int FBlobMaxSegmentSize;
	int FBlobNumSegments;
	int FBlobSize;
	int FOldBlobSize;
	short FBlobType;
	int FBlobSubType;
	char *FBuffer;
	char *FOldBuffer;
	bool FBlobInitialized;
	void * *FBlobHandle;
	Db::TBlobStreamMode FMode;
	bool FModified;
	int FPosition;
	Classes::TList* FBlobStreamList;
	int FIndexInList;
	int FFieldNo;
	bool FNeedSaveOldBuffer;
	AnsiString FTableName;
	AnsiString FFieldName;
	DynamicArray<Variant >  FKeyValues;
	bool FLoadedFromCache;
	bool FIsClientField;
	Ibase::PISC_TR_HANDLE __fastcall GetUpdateTRHandle(void);
	AnsiString __fastcall GetRecKeyValuesAsStr();
	
protected:
	void __fastcall DoOnDatabaseFree(System::TObject* Sender);
	void __fastcall CreateBlob(void);
	void __fastcall EnsureBlobInitialized(void);
	void __fastcall GetBlobInfo(void);
	Fibdatabase::TFIBDatabase* __fastcall GetDatabase(void);
	Ibase::PISC_DB_HANDLE __fastcall GetDBHandle(void);
	Fibdatabase::TFIBTransaction* __fastcall GetTransaction(void);
	Fibdatabase::TFIBTransaction* __fastcall GetUpdateTransaction(void);
	Ibase::PISC_TR_HANDLE __fastcall GetTRHandle(void);
	void __fastcall CheckHandles(bool ReadTransaction = true);
	void __fastcall OpenBlob(void);
	void __fastcall SetBlobID(const Ibase::TGDS_QUAD &Value);
	void __fastcall ReplaceBlobID(const Ibase::TGDS_QUAD &Value);
	void __fastcall SetDatabase(Fibdatabase::TFIBDatabase* Value);
	void __fastcall SetMode(Db::TBlobStreamMode Value);
	void __fastcall SetTransaction(Fibdatabase::TFIBTransaction* Value);
	void __fastcall SetUpdateTransaction(Fibdatabase::TFIBTransaction* Value);
	AnsiString __fastcall GetAsString();
	void __fastcall SaveOldBuffer(void);
	
public:
	__fastcall TFIBBlobStream(int aFieldNo, Classes::TList* aBlobStreamList, const AnsiString aTableName, const AnsiString aFieldName, Stdfuncs::PDynArray PKeyValues);
	__fastcall TFIBBlobStream(void);
	__fastcall virtual ~TFIBBlobStream(void);
	int __fastcall Call(int ErrCode, bool RaiseError);
	void __fastcall CheckReadable(void);
	void __fastcall CheckWritable(void);
	void __fastcall DoFinalize(bool ClearModified, bool ForceWrite);
	void __fastcall Finalize(void);
	void __fastcall CloseBlob(void);
	void __fastcall Cancel(void);
	void __fastcall FreeOldBuffer(void);
	bool __fastcall LoadFromFile(const AnsiString Filename, bool IsCacheFile = false);
	bool __fastcall LoadFromStream(Classes::TStream* Stream, bool IsCacheStream = false);
	virtual int __fastcall Read(void *Buffer, int Count);
	int __fastcall ReadOldBuffer(void *Buffer, int Count);
	AnsiString __fastcall GenerateSwapFileName(bool ForceDir);
	void __fastcall SaveToSwapFile(void);
	void __fastcall SaveToFile(const AnsiString Filename, bool FullInfo = false);
	void __fastcall SaveToStream(Classes::TStream* Stream, bool IsCacheStream = false);
	virtual int __fastcall Seek(int Offset, Word Origin)/* overload */;
	int __fastcall SeekInOldBuffer(int Offset, Word Origin);
	virtual void __fastcall SetSize(int NewSize)/* overload */;
	void __fastcall Truncate(void);
	virtual int __fastcall Write(const void *Buffer, int Count);
	__property bool BlobInitialized = {read=FBlobInitialized, nodefault};
	__property Ib_externals::PVoid Handle = {read=FBlobHandle};
	__property Ib_externals::PVoid BlobHandle = {read=FBlobHandle};
	__property Ibase::TGDS_QUAD BlobID = {read=FBlobID, write=SetBlobID};
	__property int BlobMaxSegmentSize = {read=FBlobMaxSegmentSize, nodefault};
	__property int BlobNumSegments = {read=FBlobNumSegments, nodefault};
	__property int BlobSize = {read=FBlobSize, nodefault};
	__property short BlobType = {read=FBlobType, nodefault};
	__property int BlobSubType = {read=FBlobSubType, write=FBlobSubType, nodefault};
	__property Fibdatabase::TFIBDatabase* Database = {read=GetDatabase, write=SetDatabase};
	__property Ibase::PISC_DB_HANDLE DBHandle = {read=GetDBHandle};
	__property Db::TBlobStreamMode Mode = {read=FMode, write=SetMode, nodefault};
	__property bool Modified = {read=FModified, nodefault};
	__property Fibdatabase::TFIBTransaction* Transaction = {read=GetTransaction, write=SetTransaction};
	__property Fibdatabase::TFIBTransaction* UpdateTransaction = {read=GetUpdateTransaction, write=SetUpdateTransaction};
	__property Ibase::PISC_TR_HANDLE TRHandle = {read=GetTRHandle};
	__property Ibase::PISC_TR_HANDLE UpdateTRHandle = {read=GetUpdateTRHandle};
	__property AnsiString AsString = {read=GetAsString};
	__property int FieldNo = {read=FFieldNo, nodefault};
	__property int IndexInList = {read=FIndexInList, nodefault};
	__property AnsiString FieldName = {read=FFieldName, write=FFieldName};
	__property AnsiString TableName = {read=FTableName, write=FTableName};
	__property Stdfuncs::TDynArray RecordKeyValues = {read=FKeyValues, write=FKeyValues};
	__property bool IsClientField = {read=FIsClientField, write=FIsClientField, nodefault};
	
/* Hoisted overloads: */
	
public:
	inline __int64 __fastcall  Seek(const __int64 Offset, Classes::TSeekOrigin Origin){ return TStream::Seek(Offset, Origin); }
	
protected:
	inline void __fastcall  SetSize(const __int64 NewSize){ TStream::SetSize(NewSize); }
	
};


class DELPHICLASS TFIBOutputDelimitedFile;
class PASCALIMPLEMENTATION TFIBOutputDelimitedFile : public Fibquery::TFIBBatchOutputStream 
{
	typedef Fibquery::TFIBBatchOutputStream inherited;
	
protected:
	unsigned FHandle;
	bool FOutputTitles;
	AnsiString FColDelimiter;
	AnsiString FRowDelimiter;
	
public:
	__fastcall virtual ~TFIBOutputDelimitedFile(void);
	virtual void __fastcall ReadyStream(void);
	virtual bool __fastcall WriteColumns(void);
	__property AnsiString ColDelimiter = {read=FColDelimiter, write=FColDelimiter};
	__property bool OutputTitles = {read=FOutputTitles, write=FOutputTitles, nodefault};
	__property AnsiString RowDelimiter = {read=FRowDelimiter, write=FRowDelimiter};
public:
	#pragma option push -w-inl
	/* TFIBBatch.Create */ inline __fastcall TFIBOutputDelimitedFile(void) : Fibquery::TFIBBatchOutputStream() { }
	#pragma option pop
	
};


class DELPHICLASS TFIBInputDelimitedFile;
class PASCALIMPLEMENTATION TFIBInputDelimitedFile : public Fibquery::TFIBBatchInputStream 
{
	typedef Fibquery::TFIBBatchInputStream inherited;
	
protected:
	AnsiString FColDelimiter;
	AnsiString FRowDelimiter;
	bool FEOF;
	Classes::TFileStream* FFile;
	char FLookAhead;
	bool FReadBlanksAsNull;
	bool FSkipTitles;
	
public:
	__fastcall virtual ~TFIBInputDelimitedFile(void);
	int __fastcall GetColumn(AnsiString &Col);
	virtual bool __fastcall ReadParameters(void);
	virtual void __fastcall ReadyStream(void);
	__property AnsiString ColDelimiter = {read=FColDelimiter, write=FColDelimiter};
	__property bool ReadBlanksAsNull = {read=FReadBlanksAsNull, write=FReadBlanksAsNull, nodefault};
	__property AnsiString RowDelimiter = {read=FRowDelimiter, write=FRowDelimiter};
	__property bool SkipTitles = {read=FSkipTitles, write=FSkipTitles, nodefault};
public:
	#pragma option push -w-inl
	/* TFIBBatch.Create */ inline __fastcall TFIBInputDelimitedFile(void) : Fibquery::TFIBBatchInputStream() { }
	#pragma option pop
	
};


class DELPHICLASS TFIBOutputRawFile;
class PASCALIMPLEMENTATION TFIBOutputRawFile : public Fibquery::TFIBBatchOutputStream 
{
	typedef Fibquery::TFIBBatchOutputStream inherited;
	
protected:
	unsigned FHandle;
	int FVersion;
	
public:
	__fastcall TFIBOutputRawFile(void);
	__fastcall TFIBOutputRawFile(int aVersion);
	__fastcall virtual ~TFIBOutputRawFile(void);
	virtual void __fastcall ReadyStream(void);
	virtual bool __fastcall WriteColumns(void);
};


typedef DynamicArray<int >  FIBMiscellaneous__6;

class DELPHICLASS TFIBInputRawFile;
class PASCALIMPLEMENTATION TFIBInputRawFile : public Fibquery::TFIBBatchInputStream 
{
	typedef Fibquery::TFIBBatchInputStream inherited;
	
protected:
	unsigned FHandle;
	char FVersion;
	Classes::TList* FMap;
	DynamicArray<int >  SkippedLen;
	
public:
	__fastcall virtual ~TFIBInputRawFile(void);
	virtual bool __fastcall ReadParameters(void);
	virtual void __fastcall ReadyStream(void);
public:
	#pragma option push -w-inl
	/* TFIBBatch.Create */ inline __fastcall TFIBInputRawFile(void) : Fibquery::TFIBBatchInputStream() { }
	#pragma option pop
	
};


//-- var, const, procedure ---------------------------------------------------
static const Word DefaultBlobSegmentSize = 0xffff;
extern PACKAGE Ibase::TGDS_QUAD NullQUID;
extern PACKAGE bool __fastcall EquelQUADs(const Ibase::TGDS_QUAD &Value1, const Ibase::TGDS_QUAD &Value2);
extern PACKAGE void __fastcall ValidateBlobCacheDirectory(Fibdatabase::TFIBDatabase* Database);
extern PACKAGE void __fastcall GetBlobInfo(Ib_intf::_di_IIBClientLibrary ClientLibrary, Ibase::PISC_BLOB_HANDLE hBlobHandle, int &NumSegments, int &MaxSegmentSize, int &TotalSize, short &BlobType);
extern PACKAGE void __fastcall ReadBlob(Ib_intf::_di_IIBClientLibrary ClientLibrary, Ibase::PISC_BLOB_HANDLE hBlobHandle, char * Buffer, int BlobSize);
extern PACKAGE void __fastcall WriteBlob(Ib_intf::_di_IIBClientLibrary ClientLibrary, Ibase::PISC_BLOB_HANDLE hBlobHandle, char * Buffer, int BlobSize);
extern PACKAGE bool __fastcall BlobExist(Ib_intf::_di_IIBClientLibrary ClientLibrary, Ib_externals::PVoid DBHandle, Ib_externals::PVoid TRHandle, const Ibase::TGDS_QUAD &blob_id);

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

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