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

// (DO NOT EDIT: machine generated header) 'SMClarion.pas' rev: 24.00 (Win32)

#ifndef SmclarionHPP
#define SmclarionHPP

#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>	// Pascal unit
#include <SysInit.hpp>	// Pascal unit
#include <System.Classes.hpp>	// Pascal unit
#include <Winapi.Windows.hpp>	// Pascal unit
#include <SMCells.hpp>	// Pascal unit

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

namespace Smclarion
{
//-- type declarations -------------------------------------------------------
enum TClarionFieldType : unsigned char { cftUnknown, cftLong, cftReal, cftString, cftPicString, cftByte, cftShort, cftGroup, cftDecimal, cftMemo, cftSubGroup };

typedef System::StaticArray<System::UnicodeString, 11> Smclarion__1;

#pragma pack(push,1)
struct DECLSPEC_DRECORD TClarionField
{
public:
	System::Byte FieldType;
	System::StaticArray<char, 16> FieldName;
	System::Word StartPos;
	System::Word Length;
	System::Byte Decimals;
	System::Byte Precision;
	System::Word ArrayNum;
	System::Word PicNum;
};
#pragma pack(pop)


typedef System::StaticArray<TClarionField, 512001> TClarionFields;

#pragma pack(push,1)
struct DECLSPEC_DRECORD TClarionKey
{
public:
	System::Byte NumComps;
	System::StaticArray<char, 16> KeyNames;
	System::Byte CompType;
	System::Byte CompLen;
};
#pragma pack(pop)


struct TClarionKeyItem;
typedef TClarionKeyItem *PClarionKeyItem;

#pragma pack(push,1)
struct DECLSPEC_DRECORD TClarionKeyItem
{
public:
	System::Byte FieldType;
	System::Word FieldNum;
	System::Word ElementOffset;
	System::Byte ElementLen;
};
#pragma pack(pop)


class DELPHICLASS TClarionKeyValue;
#pragma pack(push,4)
class PASCALIMPLEMENTATION TClarionKeyValue : public System::TObject
{
	typedef System::TObject inherited;
	
public:
	TClarionKey KeyInfo;
	System::Classes::TList* Items;
	void __fastcall AddItem(const TClarionKeyItem &cki);
	void __fastcall ClearItems(void);
	System::UnicodeString __fastcall GetTypeStr(void);
	__fastcall virtual ~TClarionKeyValue(void);
public:
	/* TObject.Create */ inline __fastcall TClarionKeyValue(void) : System::TObject() { }
	
};

#pragma pack(pop)

class DELPHICLASS TClarionKeys;
#pragma pack(push,4)
class PASCALIMPLEMENTATION TClarionKeys : public System::Classes::TList
{
	typedef System::Classes::TList inherited;
	
public:
	TClarionKeyValue* __fastcall AddKey(void);
	void __fastcall DeleteKey(TClarionKeyValue* Value);
	void __fastcall ClearItems(void);
	__fastcall virtual ~TClarionKeys(void);
public:
	/* TObject.Create */ inline __fastcall TClarionKeys(void) : System::Classes::TList() { }
	
};

#pragma pack(pop)

#pragma pack(push,1)
struct DECLSPEC_DRECORD TClarionPicture
{
public:
	System::Word PicLen;
	System::StaticArray<char, 256> PicStr;
};
#pragma pack(pop)


#pragma pack(push,1)
struct DECLSPEC_DRECORD TClarionArrayHeader
{
public:
	System::Word NumDim;
	System::Word TotalDim;
	System::Word ElementSize;
};
#pragma pack(pop)


class DELPHICLASS TClarionArrayItem;
#pragma pack(push,4)
class PASCALIMPLEMENTATION TClarionArrayItem : public System::TObject
{
	typedef System::TObject inherited;
	
public:
	System::Word MaxDim;
	System::Word LenDim;
public:
	/* TObject.Create */ inline __fastcall TClarionArrayItem(void) : System::TObject() { }
	/* TObject.Destroy */ inline __fastcall virtual ~TClarionArrayItem(void) { }
	
};

#pragma pack(pop)

class DELPHICLASS TClarionArray;
#pragma pack(push,4)
class PASCALIMPLEMENTATION TClarionArray : public System::TObject
{
	typedef System::TObject inherited;
	
public:
	TClarionArrayHeader Header;
	System::Classes::TList* Items;
public:
	/* TObject.Create */ inline __fastcall TClarionArray(void) : System::TObject() { }
	/* TObject.Destroy */ inline __fastcall virtual ~TClarionArray(void) { }
	
};

#pragma pack(pop)

#pragma pack(push,1)
struct DECLSPEC_DRECORD TClarionHeader
{
public:
	System::Word Signature;
	System::Word Attribute;
	System::Byte NumberOfKeys;
	unsigned NumberOfRecords;
	unsigned NumberOfDeleted;
	System::Word NumberOfFields;
	System::Word NumberOfPictures;
	System::Word NumberOfArrays;
	System::Word RecordSize;
	unsigned Offset;
	unsigned LogicalEOF;
	unsigned LogicalBOF;
	unsigned FirstFreeRec;
	System::StaticArray<char, 12> RecName;
	System::StaticArray<char, 12> MemoName;
	System::StaticArray<char, 3> FileNamePrefix;
	System::StaticArray<char, 3> RecNamePrefix;
	System::Word MemoLength;
	System::Word MemoColWidth;
	unsigned LockCount;
	unsigned LastUpdateTime;
	unsigned LastUpdateDate;
	System::Word CheckSum;
};
#pragma pack(pop)


enum TClarionRecordStatus : unsigned char { crsNew, crsOld, crsRevised, crsDeleted, crsHeld };

#pragma pack(push,1)
struct DECLSPEC_DRECORD TClarionRecordHeader
{
public:
	TClarionRecordStatus Status;
	unsigned NextDeleted;
};
#pragma pack(pop)


#pragma pack(push,1)
struct DECLSPEC_DRECORD TClarionMEMOHeader
{
public:
	System::Word Signature;
	unsigned FirstDeleted;
};
#pragma pack(pop)


#pragma pack(push,1)
struct DECLSPEC_DRECORD TClarionMEMORecord
{
public:
	unsigned NextBlock;
	System::StaticArray<char, 252> MemoBlock;
};
#pragma pack(pop)


class DELPHICLASS TClarion;
class PASCALIMPLEMENTATION TClarion : public Smcells::TSpreadSheetFile
{
	typedef Smcells::TSpreadSheetFile inherited;
	
private:
	System::Word FID;
	System::Classes::TStream* BLOBStream;
	bool FAutoPatchFieldNames;
	bool FDateAutodetect;
	System::UnicodeString FPassword;
	void __fastcall SetPassword(System::UnicodeString AValue);
	bool __fastcall CheckHeader(void);
	void __fastcall DecodeBuffer(void *Buffer, System::Word ASize);
	TClarionArray* __fastcall GetClarionArrayByField(int idx, const TClarionField &fld);
	void __fastcall ClearArrays(void);
	int __fastcall GetMemoBlockNo(int Value);
	
protected:
	System::Classes::TStream* FCurrentStream;
	virtual void __fastcall ReadBLOBValue(unsigned BlockNo, unsigned ASize, System::UnicodeString &s);
	void __fastcall GetFieldValue(const TClarionField &Field, const System::UnicodeString strBuffer, System::Variant &Value, Smcells::TSMICellType &CellType);
	
public:
	TClarionHeader DBHeader;
	TClarionFields Fields;
	TClarionKeys* Keys;
	System::Classes::TList* ArrayFields;
	__fastcall virtual TClarion(System::Classes::TComponent* AOwner);
	__fastcall virtual ~TClarion(void);
	virtual void __fastcall LoadFromStream(System::Classes::TStream* AStream);
	virtual void __fastcall LoadFromFile(const System::WideString FileName);
	virtual void __fastcall BeforeLoad(void);
	virtual void __fastcall AfterLoad(void);
	virtual bool __fastcall LoadRecord(int RecNo);
	virtual int __fastcall FindColumn(const System::UnicodeString AFieldName);
	virtual void __fastcall FillColumnList(System::Classes::TStrings* lst, const System::UnicodeString strFieldList);
	System::TDateTime __fastcall GetLastUpdate(void);
	bool __fastcall IsLocked(void);
	virtual bool __fastcall IsEncrypted(void);
	bool __fastcall IsOwned(void);
	bool __fastcall IsMemoExist(void);
	System::UnicodeString __fastcall GetStrFieldType(System::Byte AType);
	__classmethod System::TDateTime __fastcall GetDate(int Value);
	__classmethod System::TDateTime __fastcall GetTime(int Value);
	
__published:
	__property bool DateAutodetect = {read=FDateAutodetect, write=FDateAutodetect, default=0};
	__property bool AutoPatchFieldNames = {read=FAutoPatchFieldNames, write=FAutoPatchFieldNames, default=1};
	__property System::UnicodeString Password = {read=FPassword, write=SetPassword};
};


//-- var, const, procedure ---------------------------------------------------
extern PACKAGE Smclarion__1 arrClarionFieldTypeStr;
static const System::Int8 CS_LOCKED = System::Int8(0x1);
static const System::Int8 CS_OWNED = System::Int8(0x2);
static const System::Int8 CS_ENCRYPTED = System::Int8(0x4);
static const System::Int8 CS_MEMOEXIST = System::Int8(0x8);
static const System::Int8 CS_COMPRESSED = System::Int8(0x10);
static const System::Int8 CS_RECLAIM = System::Int8(0x20);
static const System::Int8 CS_READONLY = System::Int8(0x40);
static const System::Byte CS_CREATED = System::Byte(0x80);
}	/* namespace Smclarion */
#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_SMCLARION)
using namespace Smclarion;
#endif
#pragma pack(pop)
#pragma option pop

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