/******************************************************************************
 BindingsList.h

	Interface for the BindingsList class

	Copyright © 1997 by Glenn W. Bach. All rights reserved.

 ******************************************************************************/

#ifndef _H_BindingsList
#define _H_BindingsList

#include <JPtrArray.h>
#include <jTypes.h>
#include <JString.h>

class PatternBinding;

class BindingsList : public JPtrArray<PatternBinding>
{
public:

	static JBoolean Create(BindingsList** list);
	virtual ~BindingsList();
	
	void	Save();
	void	Revert();
	void	DeleteBinding(const JIndex index);
	void	AddBinding(const JCharacter* pattern, const JCharacter* action, 
					const JCharacter* alternate, const JBoolean system);
	
	JBoolean	ChangePattern(const JIndex index, const JCharacter* pattern, JIndex* newindex);
	JBoolean	ChangeAction(const JIndex index, const JCharacter* action);
	JBoolean	ChangeAlternate(const JIndex index, const JCharacter* alternate);

protected:

	BindingsList(const JCharacter* bindingsfile);

private:

	JString						itsBindingsFile;
	JPtrArray<PatternBinding>* 	itsDuplicates;

private:

	void	LoadBindings(const JCharacter* bindingsfile, const JBoolean system);

	// not allowed

	BindingsList(const BindingsList& source);
	const BindingsList& operator=(const BindingsList& source);
};

#endif