/***************************************************************************
 *   Copyright (C) 2008 by Juergen Thies                                   *
 *   layout@juergenthies.de                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include <QDateTime>


void macro::layerTranslatorHandler_registerKeywords(keywords **keyword_){
 *keyword_= new keywords(*keyword_);
 (*keyword_)->keyword="layerTranslator";
 (*keyword_)->type=type;
 (*keyword_)->typeHandler=&macro::layerTranslatorHandler_typeHandler;
}

void macro::layerTranslatorHandler_typeHandler(int *counter,keywords **keyword_,bool single){
generalTypeProcessing(counter,keyword_,ptrLayerTranslator,varLayerTranslator,single);
}

returnValue macro::layerTranslatorHandler_classHandler(int *counter, keywords *keyword_,returnValue* r,bool left){
 QString s;
 returnValue ret;
 parserValue p;
if (r->type==ptrLayerTranslator){
   if (checkClassPointer(counter)) {
   }
   else { 
   	if (left) { compute(r,counter,keyword_);return ret;}
     	else return *r;
	}
   }
 else if (r->type==varLayerTranslator){
     if (checkDot(counter)) {
   }
   else {
   	if (left) {compute(r,counter,keyword_);return ret;}
     	else return *r;
	}
    }
 layerTranslator *c= r->getPtrLayerTranslator();
 p=next(counter);
 // methods
 if (((p.type==keyword)&&(p.value=="invert"))) {
 	testParenOpen(counter);
	testParenClose(counter);
	c->invert();
  	}
 else if (((p.type==keyword)&&(p.value=="map"))) {
 	testParenOpen(counter);
	returnValue p1=calculate(counter,keyword_);
	testParenClose(counter);
	c->map(p1.getInt());
  	}
 else if (((p.type==keyword)&&(p.value=="mapAll"))) {
 	testParenOpen(counter);
	returnValue p1=calculate(counter,keyword_);
	testParenClose(counter);
	c->mapAll(p1.getInt());
  	}
 else if (((p.type==keyword)&&(p.value=="mapLayer"))) {
 	testParenOpen(counter);
	returnValue p1=calculate(counter,keyword_);
	testComma(counter);
    returnValue p2=calculate(counter,keyword_);
	testParenClose(counter);
	c->mapLayer(p1.getInt(),p2.getInt());
  	}
 else {
  	error->addItem(tr("Class layerTranslator has no member")+p.value,1,message((*counter)));
	throw 1;
 	}
 if (left)  if (!checkSemicolon(counter)) {throw 15;}  
 return ret;
}

