/****************************************************************************
    Kalkulon - A programmable calculator for programmers

    This file is part of the Kalkulon core.

    If you find this source code useful, your are encouraged to use it in your own projects.
    Please give me credit!

    COPYRIGHT by Juergen Holetzeck 2003 - 2008
    e-mail:		contact@kalkulon.de
    homepage:	www.kalkulon.de
****************************************************************************/


// DataStack.cpp: Implementierung der Klasse CDataStack.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "DataStack.h"
#include "ErrBase.h"

using namespace Kalkulon;

//////////////////////////////////////////////////////////////////////
// Konstruktion/Destruktion
//////////////////////////////////////////////////////////////////////

CDataStack::CDataStack()
{

}

CDataStack::~CDataStack()
{

}


/////////////////////////////////////////////////////////////////////
// push & pop

DataObject CDataStack::pop()
{
    if(!datastack.empty())
        {
            DataObject d = std::move(datastack.top());
            datastack.pop();
            return d;
        }
    else
        throw ErrInternal(__LINE__, __FILE__);
}



void CDataStack::push(double d)
{
    DataObject data(d);
    datastack.push(data);
}



void CDataStack::push(const DataObject& data)
{
    datastack.push(data);
}

void CDataStack::push(DataObject&& data)
{
    datastack.push(std::move(data));
}


void CDataStack::clear()
{
    while(!datastack.empty())
    {
        #if _DEBUG
        DataObject d=datastack.top();
        #endif
        datastack.pop();
    }
}
