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

// (DO NOT EDIT: machine generated header) 'CioinaComplexEval.pas' rev: 6.00

#ifndef CioinaComplexEvalHPP
#define CioinaComplexEvalHPP

#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <Variants.hpp>	// Pascal unit
#include <Classes.hpp>	// Pascal unit
#include <SysInit.hpp>	// Pascal unit
#include <System.hpp>	// Pascal unit

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

namespace Cioinacomplexeval
{
//-- type declarations -------------------------------------------------------
typedef Variant *PVariant;

typedef Variant *TVectorPVariant[536870910];

typedef PVariant *PVectorPVariant;

typedef DynamicArray<int >  PComand;

struct TRecord1;
typedef TRecord1 *PRecord1;

#pragma pack(push, 1)
struct TRecord1
{
	AnsiString StrExpr;
	AnsiString DerExpr;
	PVariant *ExtVect;
	int LenVect;
	bool Variab;
	bool PrFlag;
	bool PublFlag;
	DynamicArray<int >  Comand;
	DynamicArray<int >  Lista;
} ;
#pragma pack(pop)

#pragma pack(push, 1)
struct TRecord2
{
	PVariant *ProcInput;
	PVariant *ProcOut;
	int ProcParamCount;
	Word ProcId;
} ;
#pragma pack(pop)

struct TRecord3;
typedef TRecord3 *PRecord3;

#pragma pack(push, 1)
struct TRecord3
{
	AnsiString StrExpr;
	Variant *Value;
	bool ExternFlag;
	bool Protect;
} ;
#pragma pack(pop)

struct TUserVarRec;
typedef TUserVarRec *PTUserVarRec;

#pragma pack(push, 1)
struct TUserVarRec
{
	AnsiString StrExpr;
	Variant *Value;
	bool Protect;
} ;
#pragma pack(pop)

#pragma pack(push, 1)
struct WhileRecord
{
	int Proc;
	DynamicArray<int >  Test;
	DynamicArray<int >  Body;
} ;
#pragma pack(pop)

#pragma pack(push, 1)
struct IfRecord
{
	int Proc;
	DynamicArray<int >  Condition;
	DynamicArray<int >  ThenComand;
	DynamicArray<int >  ElseComand;
} ;
#pragma pack(pop)

#pragma pack(push, 1)
struct FuncRecord
{
	AnsiString Name;
	AnsiString Definition;
	int Proc;
	int PvCount;
	PVariant *PvInput;
	PVariant *PvOut;
	DynamicArray<int >  Body;
	unsigned StackIndex;
} ;
#pragma pack(pop)

typedef TRecord3 *TVector1[536870910];

typedef PRecord3 *PVector1;

typedef TRecord2 TVector3[153391688];

typedef TRecord2 *PVector3;

typedef Variant __fastcall (*TUserFunction)(PVectorPVariant Pv, int PvCount);

#pragma pack(push, 1)
struct TUserFuncRec
{
	AnsiString FuncName;
	TUserFunction FuncAddress;
	int VarCount;
	PVariant *PvInput;
} ;
#pragma pack(pop)

#pragma pack(push, 1)
struct TVarPropertyRec
{
	bool ProtectEndedWithNumber;
	bool ProtectEndedWithoutNumber;
} ;
#pragma pack(pop)

typedef DynamicArray<TUserFuncRec >  TUserFuncArray;

typedef DynamicArray<TUserVarRec >  TUserVarArray;

typedef DynamicArray<Variant >  TUserValuesArray;

typedef void __fastcall (__closure *TProcedureEvent)(System::TObject* Sender);

typedef void __fastcall (*TStdCallUserFunction)(PVectorPVariant Pv, int PvCount);

typedef DynamicArray<WhileRecord >  CioinaComplexEval__2;

typedef DynamicArray<IfRecord >  CioinaComplexEval__3;

typedef DynamicArray<FuncRecord >  CioinaComplexEval__4;

typedef DynamicArray<PVariant >  CioinaComplexEval__5;

typedef DynamicArray<PVectorPVariant >  CioinaComplexEval__6;

typedef DynamicArray<PRecord1 >  CioinaComplexEval__7;

typedef DynamicArray<Variant >  CioinaComplexEval__8;

class DELPHICLASS TCioinaComplexEval;
class PASCALIMPLEMENTATION TCioinaComplexEval : public System::TObject 
{
	typedef System::TObject inherited;
	
private:
	DynamicArray<TUserFuncRec >  UserFuncArray;
	DynamicArray<WhileRecord >  WhileArray;
	DynamicArray<IfRecord >  IfArray;
	DynamicArray<FuncRecord >  RTFuncArray;
	DynamicArray<PVariant >  TempPVariantAr;
	DynamicArray<PVectorPVariant >  TempPVectorAr;
	DynamicArray<PRecord1 >  ListStr;
	DynamicArray<Variant >  fStack;
	PRecord3 *VarVect;
	TRecord2 *ListaProc;
	int VarCount;
	int VectCount;
	int ElemVectCount;
	int ProcCount;
	int ExtCount;
	int MathValueCount;
	int NumAllocMem;
	int RuleFlag;
	int fErrorNumber;
	int StackIndex;
	int ExceptionId;
	PVariant *MathValue;
	AnsiString MathExpr;
	AnsiString DerExpr;
	AnsiString DerVar;
	AnsiString ErrorMessage;
	bool fMathVariabFlag;
	bool fMathPublFlag;
	bool fMathPrFlag;
	bool fMathLinearFlag;
	bool PowerOperator;
	bool Derivation;
	bool ErrorMsg;
	bool fSpaceLikeMultiply;
	bool fOriginalMathExpressionString;
	bool fCurrencyType;
	DynamicArray<int >  ComandArray;
	unsigned fMaxIterations;
	unsigned fMaxStack;
	#pragma pack(push, 1)
	TVarPropertyRec fProtectVariables;
	#pragma pack(pop)
	
	void __fastcall PuneValoarea(int i, const Variant &d);
	int __fastcall fVariableLowIndex(void);
	PVector1 __fastcall ScoateVectorVar(void);
	AnsiString __fastcall ScoateNumeVar(int i);
	void __fastcall PuneNumeVar(int i, AnsiString s);
	void __fastcall PuneNumePointerVar(int i, const AnsiString s, PVariant pr, bool Protect);
	AnsiString __fastcall UsedFunc(Word i);
	void __fastcall SetOriginalMathExpressionString(bool l);
	AnsiString __fastcall fUserFuncName(int i);
	int __fastcall fUserFuncVarCount(int i);
	int __fastcall fUserFuncCount(void);
	AnsiString __fastcall fRunTimeFuncName(int i);
	AnsiString __fastcall fRunTimeFuncDefinition(int i);
	int __fastcall fRunTimeFuncCount(void);
	int __fastcall fRunTimeFuncVarCount(int i);
	void __fastcall AddToListStr(int k, PVectorPVariant Pv, bool FlagVar, bool FlagPr, bool FlagPubl, const int * Comand, const int Comand_Size, const int * Lista, const int Lista_Size, const AnsiString s, const AnsiString ds);
	void __fastcall Initializare(void);
	HIDESBASE void __fastcall Free(void);
	AnsiString __fastcall fExceptionInfo(int i);
	unsigned __fastcall fDynamicMemoryInfo(void);
	PVectorPVariant __fastcall NewPointerVector(int i);
	PVariant __fastcall NewPointerVariant(void);
	void __fastcall NewProc(const TRecord2 &Rec2);
	bool __fastcall CompOper(const AnsiString s, int i, bool flag);
	bool __fastcall CompOperAsoc(const AnsiString s, int i);
	void __fastcall Simplify(AnsiString &s);
	AnsiString __fastcall DerSqrt(AnsiString s);
	AnsiString __fastcall DerLn(AnsiString s);
	AnsiString __fastcall DerPutere(AnsiString s1, AnsiString s2);
	AnsiString __fastcall DerProdus(AnsiString s1, AnsiString s2);
	AnsiString __fastcall DerImpar(AnsiString s1, AnsiString s2);
	AnsiString __fastcall DerSuma(AnsiString s1, AnsiString s2);
	AnsiString __fastcall DerDif(AnsiString s1, AnsiString s2);
	double __fastcall MyPower(double d1, double d2, double d3);
	int __fastcall PosOperInMathStr(const char ch, const AnsiString s);
	bool __fastcall isSameStr(AnsiString s1, AnsiString s2);
	bool __fastcall isEqual(double x, double y);
	bool __fastcall isNan(double d);
	bool __fastcall isInfinite(double d);
	double __fastcall Sign(double d);
	double __fastcall Floor(double d);
	double __fastcall Ceil(double d);
	bool __fastcall isComplexEqual(const Variant &x, const Variant &y);
	void __fastcall SetCurrencyType(bool b);
	bool __fastcall EvalExpres(int i1, int i2, char c, Variant &d, TRecord2 &Rec2, AnsiString &ds3);
	int __fastcall EvalString(const AnsiString s);
	Variant __fastcall ValFunct(int k, int i, TRecord2 &Rec2, AnsiString &ds);
	bool __fastcall Functii(AnsiString s, int i, Variant &d, TRecord2 &Rec2, AnsiString &ds);
	bool __fastcall PriorOper(int i, int j, const AnsiString s);
	bool __fastcall Separ(AnsiString &s, int i, int n, int &j, int &t, char ch);
	AnsiString __fastcall StergeNumaiParant(const AnsiString s1);
	bool __fastcall IsNumber(const AnsiString s);
	bool __fastcall IsIntegerNumber(const AnsiString s);
	bool __fastcall IsRealNumber(const AnsiString s);
	void __fastcall StergeSpatii(AnsiString &s);
	void __fastcall FormatareaExponentei(AnsiString &s, bool m41Flag);
	void __fastcall ExpresieParant(AnsiString &s);
	void __fastcall ParseBack(AnsiString &s);
	void __fastcall ParseForward(AnsiString &s, char ch1, char ch2);
	void __fastcall Compile(AnsiString &s);
	__property AnsiString NumeVar[int i] = {read=ScoateNumeVar};
	__property Variant Valoarea[int i] = {write=PuneValoarea};
	void __fastcall ExceptieMatematica(int i, int EId);
	void __fastcall ExceptieExprConst(char c, const Variant &d1, const Variant &d2, int EId);
	void __fastcall ExceptieFunctie(PVectorPVariant Pv, int t, int i, int EId);
	int __fastcall ExpresieSemanticCorecta(AnsiString s, int i);
	void __fastcall VerifySyntaxSemanticsRule(AnsiString MathStr, AnsiString VarStr, AnsiString DerStr, const TUserVarRec * RecordVar, const int RecordVar_Size, bool DerFlag, bool CheckUnknownVar);
	void __fastcall VerifySyntaxSemanticsRuleExit(char ch);
	void __fastcall Execute(void);
	void __fastcall ExecuteComand(const int * Comand, const int Comand_Size);
	void __fastcall FillValuesArray(const Variant * VarValues, const int VarValues_Size);
	AnsiString __fastcall Transform(const AnsiString s);
	AnsiString __fastcall MathematicaForm(const AnsiString PascalForm);
	AnsiString __fastcall GetMath(int Index);
	AnsiString __fastcall GetDerivative(int Index);
	AnsiString __fastcall GetVariable();
	int __fastcall fTotalFunctionCount(void);
	void __fastcall ReplaceFirstChar(AnsiString &s, const AnsiString OldPattern);
	
protected:
	virtual void __fastcall fClearMathLinkString(void);
	
public:
	Classes::TNotifyEvent OnVerifySyntaxSemanticsError;
	Classes::TNotifyEvent OnDoMathExpressionError;
	TStdCallUserFunction OnStdCallUserFunction;
	/*         class method */ static AnsiString __fastcall OwnerInfo(TMetaClass* vmt);
	/*         class method */ static AnsiString __fastcall VersionInfo(TMetaClass* vmt);
	/*         class method */ static AnsiString __fastcall TypeInfo(TMetaClass* vmt);
	/*         class method */ static AnsiString __fastcall DedicationInfo(TMetaClass* vmt);
	bool __fastcall IsValidIdentName(AnsiString s);
	bool __fastcall IsExistString(AnsiString &s, AnsiString &ss, bool flag);
	void __fastcall ExpressionReplace(AnsiString &s, const AnsiString OldPattern, const AnsiString NewPattern);
	Variant __fastcall DoMathExpression()/* overload */;
	Variant __fastcall DoMathExpression(TUserValuesArray VarValues)/* overload */;
	PVectorPVariant __fastcall DoVectorOfMathExpressions(void)/* overload */;
	PVectorPVariant __fastcall DoVectorOfMathExpressions(TUserValuesArray VarValues)/* overload */;
	Variant __fastcall DoRunTimeFunction(int i, TUserValuesArray Values);
	Variant __fastcall DoUserFunction(int i, TUserValuesArray Values);
	void __fastcall Clear(void);
	void __fastcall VerifySyntaxSemantics(AnsiString MathStr, AnsiString VarStr, bool CheckUnknownVar)/* overload */;
	void __fastcall VerifySyntaxSemantics(AnsiString MathStr)/* overload */;
	void __fastcall VerifySyntaxSemantics(AnsiString MathStr, TUserVarArray RecordVar, bool CheckUnknownVar)/* overload */;
	void __fastcall VerifySyntaxSemanticsAndDerivation(AnsiString MathStr, AnsiString VarStr, AnsiString DerStr, bool CheckUnknownVar)/* overload */;
	void __fastcall VerifySyntaxSemanticsAndDerivation(AnsiString MathStr, AnsiString DerStr)/* overload */;
	void __fastcall VerifySyntaxSemanticsAndDerivation(AnsiString MathStr, TUserVarArray RecordVar, AnsiString DerStr, bool CheckUnknownVar)/* overload */;
	void __fastcall DeleteParantheses(AnsiString &s);
	void __fastcall ClearMathExpressionString(void);
	void __fastcall ClearDerivativeExpressionString(void);
	__property bool ProtectVariablesEndedWithNumber = {read=fProtectVariables.ProtectEndedWithNumber, write=fProtectVariables.ProtectEndedWithNumber, nodefault};
	__property bool ProtectVariablesEndedWithoutNumber = {read=fProtectVariables.ProtectEndedWithoutNumber, write=fProtectVariables.ProtectEndedWithoutNumber, nodefault};
	__property TVarPropertyRec ProtectVariables = {read=fProtectVariables, write=fProtectVariables};
	__property bool SpaceLikeMultiply = {read=fSpaceLikeMultiply, write=fSpaceLikeMultiply, nodefault};
	__property int TotalFunctionCount = {read=fTotalFunctionCount, nodefault};
	__property unsigned MaxIterations = {read=fMaxIterations, write=fMaxIterations, nodefault};
	__property unsigned MaxStack = {read=fMaxStack, write=fMaxStack, nodefault};
	__property int VariableLowIndex = {read=fVariableLowIndex, nodefault};
	__property int VariableCount = {read=VarCount, nodefault};
	__property AnsiString VariableName[int i] = {read=ScoateNumeVar};
	__property PVector1 VariableArray = {read=ScoateVectorVar};
	__property int MathExpressionCount = {read=MathValueCount, nodefault};
	__property AnsiString MathExpressionString = {read=GetMath, index=0};
	__property AnsiString DerivativeExpressionString = {read=GetDerivative, index=0};
	__property AnsiString DerivativeVariableString = {read=DerVar};
	__property AnsiString MathematicaFormVariableNames = {read=GetVariable};
	__property AnsiString MathematicaFormMathExpressionString = {read=GetMath, index=1};
	__property AnsiString MathematicaFormDerivativeExpressionString = {read=GetDerivative, index=1};
	__property bool ErrorFlag = {read=ErrorMsg, nodefault};
	__property int ErrorNumber = {read=fErrorNumber, nodefault};
	__property AnsiString ErrorMessageInfo = {read=ErrorMessage};
	__property int UserFunctionCount = {read=fUserFuncCount, nodefault};
	__property int UserFunctionVarCount[int i] = {read=fUserFuncVarCount};
	__property AnsiString UserFunctionName[int i] = {read=fUserFuncName};
	__property int RunTimeFunctionCount = {read=fRunTimeFuncCount, nodefault};
	__property int RunTimeFunctionVarCount[int i] = {read=fRunTimeFuncVarCount};
	__property AnsiString RunTimeFunctionName[int i] = {read=fRunTimeFuncName};
	__property AnsiString RunTimeFunctionDefinition[int i] = {read=fRunTimeFuncDefinition};
	__property AnsiString BuiltInFunctionInfo[Word i] = {read=UsedFunc};
	__property bool IsMathExpressionVariable = {read=fMathVariabFlag, nodefault};
	__property bool IsMathExpressionPublic = {read=fMathPublFlag, nodefault};
	__property bool IsMathExpressionProtected = {read=fMathPrFlag, nodefault};
	__property bool IsMathExpressionLinear = {read=fMathLinearFlag, nodefault};
	__property int MathException = {read=ExceptionId, nodefault};
	__property AnsiString ExceptionInfo[int i] = {read=fExceptionInfo};
	__property bool SetPowerOperator = {read=PowerOperator, write=PowerOperator, nodefault};
	__property unsigned AllocDynamicMemoryInfo = {read=fDynamicMemoryInfo, nodefault};
	__property bool OriginalMathExpressionString = {read=fOriginalMathExpressionString, write=SetOriginalMathExpressionString, nodefault};
	__property bool CurrencyType = {read=fCurrencyType, write=SetCurrencyType, nodefault};
	__fastcall TCioinaComplexEval(void)/* overload */;
	__fastcall TCioinaComplexEval(TUserFuncArray FuncArray)/* overload */;
	__fastcall virtual ~TCioinaComplexEval(void);
};


//-- var, const, procedure ---------------------------------------------------
#define TrialMsg "Sorry but trial version can parse strings with limitated l"\
	"ength"
extern PACKAGE double VariantZero;
#define VariantZeroStr "(1.0*^-13)"
static const Word varComplex = 0x10f;
#define Incorrect "Incorrect real or complex type"
static const int MaxPVariant = 0x1ffffffe;
extern PACKAGE int MaxFuncParam;
extern PACKAGE Word MaxUserFunc;
static const Shortint OperCount = 0x7;
static const int MaxVar = 0x1ffffffe;
static const int MaxProc = 0x9249248;
static const Shortint FunCount = 0x5f;
extern PACKAGE System::SmallString<16>  aStr[95];
static const Shortint EX_NONMATH = 0x0;
static const Shortint EX_Overflow = 0x1;
static const Shortint EX_Underflow = 0x2;
static const Shortint EX_InvalidArgument = 0x3;
static const Shortint EX_ZeroDivide = 0x4;
static const Shortint EX_InvalidOp = 0x5;
static const Shortint ERR_NOERROR = 0x0;
static const Shortint ERR_NO_MATH_EXPRESSION_WAS_PARSED = 0xffffffff;
static const Shortint ERR_PARANTHESES_SYNTAX_ERROR = 0xfffffffe;
static const Shortint ERR_INVALID_DERIVATIVE_VARIABLE_NAME = 0xfffffffd;
static const Shortint ERR_MATH_EXPRESSION_IS_EMPTY = 0xfffffffc;
static const Shortint ERR_IDENTIFIER_CANNOT_BE_EMPTY = 0xfffffffb;
static const Shortint ERR_IDENTIFIER_LENGTH = 0xfffffffa;
static const Shortint ERR_NOT_PASCAL_IDENTIFIER = 0xfffffff9;
static const Shortint ERR_IDENTIFIER_CANNOT_BE_RESERVED_NAME = 0xfffffff8;
static const Shortint ERR_IDENTIFIER_ALREADY_EXISTS = 0xfffffff7;
static const Shortint ERR_DUBLICATING_USER_IDENTIFIER = 0xfffffff6;
static const Shortint ERR_UNKNOWN_EXPRESSION = 0xfffffff5;
static const Shortint ERR_BAD_EXPONENTIAL_FORMAT = 0xfffffff4;
static const Shortint ERR_SET_OriginalMathExpressionString_FALSE = 0xfffffff3;
static const Shortint ERR_MATH_EXPRESSION_WAS_ERASED = 0xfffffff2;
static const Shortint ERR_USE_VerifySyntaxSemanticsAndDerivation = 0xfffffff1;
static const Shortint ERR_DERIVATIVE_EXPRESSION_WAS_ERASED = 0xfffffff0;
static const Shortint ERR_VARIABLES_AND_VALUES_ARE_DIFFERENT = 0xffffffef;
static const Shortint ERR_MATH_EXPRESSIONS_ARRAY = 0xffffffee;
static const Shortint ERR_FUNCTION_NUMBER_MUST_BE_LESS = 0xffffffed;
static const Shortint ERR_FUNCTION_ADDRESS_CANNOT_BE_NIL = 0xffffffec;
static const Shortint ERR_PROTECTED_EXPRESSION = 0xffffffeb;
static const Shortint ERR_PARSE = 0xffffffea;
static const Shortint ERR_EXECUTE = 0xffffffe9;
static const Shortint ERR_DYNAMIC_MEMORY = 0xffffffe8;
static const Shortint ERR_MULTIPLY = 0xffffffe7;
static const Shortint ERR_DIVISION = 0xffffffe6;
static const Shortint ERR_PLUS = 0xffffffe5;
static const Shortint ERR_MINUS = 0xffffffe4;
static const Shortint ERR_POWER = 0xffffffe3;
static const Shortint ERR_EQUAL = 0xffffffe2;
static const Shortint ERR_UNKNOWN_FUNCTION = 0xffffffe1;
static const Shortint ERR_UNKNOWN_VARIABLE = 0xffffffe0;
static const Shortint ERR_BAD_SYNTAX = 0xffffffdf;
static const Shortint ERR_COMMA_SYNTAX = 0xffffffde;
static const Shortint ERR_SYSTEM_STACK_OVERFLOW = 0xffffffdd;
static const Shortint ERR_DEF_FUNC_NAME = 0xffffffdc;
static const Shortint ERR_DEF_FUNC_DUBLICATING = 0xffffffdb;
static const Shortint ERR_DEF_FUNC_IMPLEMENTING = 0xffffffda;
static const Shortint ERR_DEF_FUNC_ARG_COUNT = 0xffffffd9;
static const Shortint ERR_DEF_FUNC_ARG_NAME = 0xffffffd8;
static const Shortint ERR_DEF_FUNC_ARG_DUBLICATING = 0xffffffd7;
static const Shortint ERR_DEF_FUNCTION_STACK_OVERFLOW = 0xffffffd6;
extern PACKAGE AnsiString __fastcall VariantToStr(const Variant &v);
extern PACKAGE bool __fastcall isNull(const Variant &v);

}	/* namespace Cioinacomplexeval */
using namespace Cioinacomplexeval;
#pragma option pop	// -w-
#pragma option pop	// -Vx

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