#pragma once
#include "gosGml.hpp"
#include "History.h"

//===========================================================================//
// File:	 History.cpp													 //
// Project:  gosGml						                                     //
// Contents:																 //
//---------------------------------------------------------------------------//
// Date      Who    Modification                                             //
// 7/7/00   DP     Created													 //
//---------------------------------------------------------------------------//
// Copyright (C) 2000 Microsoft Corp.						                 //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//
#pragma warning(disable:4706)
History::History():
Cur(0)
{
	GS=new GStack<char>;
	GSF=new GStack<char>;
}

History::~History()
{
	delete GS;
	delete GSF;
	if(Cur)
		delete[] Cur;
}

char* History::Forward()
{
	char* Val=GSF->Pop();
	if(Val)
	{
		if(Cur)
			GS->Push(Cur);
		Cur=Val;
	}
	return Val;
}

char* History::Back()
{
	char* Val=GS->Pop();
	if(Val)
	{
		if(Cur)
			GSF->Push(Cur);
		Cur=Val;
	}
	return Val;
}

void History::Add(char* Entry)
{
	GSF->Clear();
	if(Cur)
		GS->Push(Cur);
	Cur=Entry;
}

void History::Clear()
{
	GS->Clear();
	GSF->Clear();
	if(Cur)
	{
		delete[] Cur;
		Cur=0;
	}
}

bool History::ForwardEmpty()
{
	return GSF->IsEmpty();
}

bool History::BackEmpty()
{
	return GS->IsEmpty();
}
#pragma warning(default:4706)