/////////////////////////////////////////////////////////////////////////////
// Name:        No names yet.
// Purpose:     Contrib. demo
// Author:      Aleksandras Gluchovas
// Modified by:
// Created:     2000/02/08
// RCS-ID:      $Id: scriptproc.h,v 1.1 2001/02/25 18:52:22 aleksandras Exp $
// Copyright:   (c) Aleksandras Gluchovas
// Licence:   	GPL (version 2.0 or later)
/////////////////////////////////////////////////////////////////////////////

#ifndef __SCRIPTPROC_G__
#define __SCRIPTPROC_G__

#include "wx/dynarray.h"
#include "wx/hash.h"

#include "scripttempl.h"
#include "txtrecset.h"

class ScriptProcessor;

class BasicScriptProcessorTemplate : public ScriptTemplate
{
public:
	BasicScriptProcessorTemplate( ScriptProcessor* pProc );

protected:
	virtual wxString Handle_subscript( char* at, ScriptTemplate& templ );
	virtual wxString Handle_assign_var( char* at, ScriptTemplate& templ );
	virtual wxString Handle_inc_var( char* at, ScriptTemplate& templ );

protected:
	ScriptProcessor* mpProc;
};

class ScriptProcessor
{
public:
	ScriptProcessor();
	virtual ~ScriptProcessor();

	void SetProcessorTemplate( ScriptTemplate* pTopTempl );
	ScriptTemplate* GetProcessorTemplate();

	virtual bool LoadAndProcessConfig( const wxString& fname );
	virtual bool ProcessConfigContent( const wxString& text );

	// overridables

	virtual bool IsScriptSection( const wxString& name );
	virtual bool ProcessSection( Record& rec );

	// other methods

	virtual void CleanUp();
	virtual ScriptTemplate* FindSubscriptByName( const wxString& name );

protected:
	ScriptTemplateListT		mSubscripts;
	wxHashTable				mSubscriptHash;
	ScriptTemplate*			mpTopTempl;
};

#endif // __SCRIPTPROC_G__