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

// (DO NOT EDIT: machine generated header) 'QImport3XlsxMapParser.pas' rev: 34.00 (Windows)

#ifndef Qimport3xlsxmapparserHPP
#define Qimport3xlsxmapparserHPP

#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 <System.SysUtils.hpp>
#include <System.Classes.hpp>
#include <System.Types.hpp>
#include <QImport3StrTypes.hpp>
#include <QImport3Common.hpp>
#include <QImport3StrIDs.hpp>
#include <QImport3.hpp>

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

namespace Qimport3xlsxmapparser
{
//-- forward type declarations -----------------------------------------------
struct TXlsxCellPoint;
class DELPHICLASS TXlsxRangeItem;
class DELPHICLASS TXlsxRangeItems;
class DELPHICLASS TXlsxMapParserItem;
class DELPHICLASS TXlsxMapParserItems;
//-- type declarations -------------------------------------------------------
enum DECLSPEC_DENUM TXlsxRangeDirection : unsigned char { xdNone, xdCell, xdColDown, xdColUp, xdRowRight, xdRowLeft };

typedef System::Word TXlsxColumns;

typedef int TXlsxRows;

#pragma pack(push,1)
struct DECLSPEC_DRECORD TXlsxCellPoint
{
public:
	TXlsxColumns Col;
	TXlsxRows Row;
};
#pragma pack(pop)


class PASCALIMPLEMENTATION TXlsxRangeItem : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	System::WideString FSheetName;
	int FSheetIndex;
	int FFirstCol;
	int FFirstRow;
	int FLastCol;
	int FLastRow;
	TXlsxRangeDirection __fastcall GetDirection();
	System::WideString __fastcall GetCellRange(const int Col, const int Row);
	System::WideString __fastcall GetAsString();
	bool __fastcall SheetInRange(const int ASheetIndex, const System::WideString ASheetName);
	
public:
	__property System::WideString SheetName = {read=FSheetName, write=FSheetName};
	__property int SheetIndex = {read=FSheetIndex, write=FSheetIndex, nodefault};
	__property int FirstCol = {read=FFirstCol, write=FFirstCol, nodefault};
	__property int FirstRow = {read=FFirstRow, write=FFirstRow, nodefault};
	__property int LastCol = {read=FLastCol, write=FLastCol, nodefault};
	__property int LastRow = {read=FLastRow, write=FLastRow, nodefault};
	__property TXlsxRangeDirection Direction = {read=GetDirection, nodefault};
	__property System::WideString AsString = {read=GetAsString};
	bool __fastcall CellInRange(const TXlsxCellPoint &CellPoint, const int SheetIndex, const System::WideString SheetName);
	void __fastcall Reset();
public:
	/* TObject.Create */ inline __fastcall TXlsxRangeItem() : System::TObject() { }
	/* TObject.Destroy */ inline __fastcall virtual ~TXlsxRangeItem() { }
	
};


class PASCALIMPLEMENTATION TXlsxRangeItems : public System::TObject
{
	typedef System::TObject inherited;
	
public:
	TXlsxRangeItem* operator[](int Index) { return this->Items[Index]; }
	
private:
	System::Classes::TList* FList;
	TXlsxRangeItem* __fastcall GetItems(int Index);
	int __fastcall GetCount();
	System::WideString __fastcall GetAsString();
	
public:
	__fastcall TXlsxRangeItems();
	__fastcall virtual ~TXlsxRangeItems();
	__property TXlsxRangeItem* Items[int Index] = {read=GetItems/*, default*/};
	__property int Count = {read=GetCount, nodefault};
	TXlsxRangeItem* __fastcall Add();
	void __fastcall Delete(const int Index);
	void __fastcall Clear();
	__property System::WideString AsString = {read=GetAsString};
	bool __fastcall CellInRanges(const TXlsxCellPoint &CellPoint, const int SheetIndex, const System::WideString SheetName);
	void __fastcall Reset();
};


class PASCALIMPLEMENTATION TXlsxMapParserItem : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	TXlsxRangeItems* FRanges;
	int FCounter;
	void __fastcall DeleteCharFromBegin(const System::WideChar AChar, System::WideString &AString);
	void __fastcall Parse(const System::WideString MapString, const int SkipRows, const int SkipCols);
	int __fastcall Col2Int(const System::WideString ColData);
	int __fastcall Row2Int(const System::WideString RowData);
	bool __fastcall GetRangeString(const System::WideString MapString, System::WideString &RangeString);
	void __fastcall DeleteFieldDescribtion(System::WideString &MapString);
	void __fastcall DeleteSheetDescribtion(System::WideString &RangeString);
	System::WideString __fastcall GetLeftSide(const System::WideString RangeString);
	System::WideString __fastcall GetRightSide(const System::WideString RangeString);
	System::WideString __fastcall GetColData(const System::WideString RangeSide);
	System::WideString __fastcall GetRowData(const System::WideString RangeSide);
	void __fastcall TruncMapString(System::WideString &MapString);
	System::WideString __fastcall GetSheetName(const System::WideString RangeString);
	int __fastcall GetSheetIndex(const System::WideString RangeString);
	int __fastcall GetFirstCol(const System::WideString RangeString);
	int __fastcall GetFirstRow(const System::WideString RangeString);
	int __fastcall GetLastCol(const System::WideString RangeString);
	int __fastcall GetLastRow(const System::WideString RangeString);
	void __fastcall FillRange(TXlsxRangeItem* const Range, const System::WideString RangeString);
	void __fastcall SetSkipRange(TXlsxRangeItem* const Range, const int SkipRows, const int SkipCols);
	void __fastcall RepairOldRange(System::WideString &RangeString);
	
public:
	__fastcall TXlsxMapParserItem(const System::WideString MapString, const int SkipRows, const int SkipCols);
	__fastcall virtual ~TXlsxMapParserItem();
	__property TXlsxRangeItems* Ranges = {read=FRanges};
	bool __fastcall GetNextRange(int &Row, int &Col, int &SheetIndex, System::WideString &SheetName);
	void __fastcall PackRanges();
};


class PASCALIMPLEMENTATION TXlsxMapParserItems : public System::TObject
{
	typedef System::TObject inherited;
	
public:
	TXlsxMapParserItem* operator[](int Index) { return this->Items[Index]; }
	
private:
	System::Classes::TList* FList;
	TXlsxMapParserItem* __fastcall GetItems(int Index);
	int __fastcall GetCount();
	
public:
	__fastcall TXlsxMapParserItems();
	__fastcall virtual ~TXlsxMapParserItems();
	__property TXlsxMapParserItem* Items[int Index] = {read=GetItems/*, default*/};
	__property int Count = {read=GetCount, nodefault};
	TXlsxMapParserItem* __fastcall Add(const System::WideString MapString, const int SkipRows, const int SkipCols);
	void __fastcall Delete(const int Index);
	void __fastcall Clear();
};


//-- var, const, procedure ---------------------------------------------------
static const System::WideChar RangeDelim = (System::WideChar)(0x3b);
static const System::WideChar SheetPrefix = (System::WideChar)(0x5b);
static const System::WideChar SheetPostfix = (System::WideChar)(0x5d);
static const System::WideChar SheetIndexPrefix = (System::WideChar)(0x3a);
static const System::Int8 DefSheetPrefixPos = System::Int8(0x1);
static const System::Int8 DefSheetIndexPrefixPos = System::Int8(0x2);
#define RowStartFlag L"ROWSTART"
#define RowFinishFlag L"ROWFINISH"
#define ColStartFlag L"COLSTART"
#define ColFinishFlag L"COLFINISH"
static const System::WideChar LeftRightRangesDelim = (System::WideChar)(0x2d);
static const System::WideChar FieldNameDelim = (System::WideChar)(0x3d);
#define BeginColStr L"A1"
#define EndColStr L"XFD1"
#define BeginRowStr L"A1"
#define EndRowStr L"A1048576"
static const System::Int8 BeginRowInt = System::Int8(0x1);
static const System::Int8 BeginColInt = System::Int8(0x1);
static const System::Word EndColInt = System::Word(0x4000);
static const int EndRowInt = int(0x100000);
extern DELPHI_PACKAGE int __fastcall GetColIdFromString(const System::WideString Index);
extern DELPHI_PACKAGE int __fastcall GetRowIdFromString(const System::WideString Index);
extern DELPHI_PACKAGE System::WideString __fastcall GetColNameFromIndex(const int ColIndex);
}	/* namespace Qimport3xlsxmapparser */
#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_QIMPORT3XLSXMAPPARSER)
using namespace Qimport3xlsxmapparser;
#endif
#pragma pack(pop)
#pragma option pop

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