예제 #1
0
QByteArray* XCELProcessorInterface::switchToSource(const QString& uri)
{
	QString u = uri;

	// Stops Method, if no file is given (empty stack?)
	if (u.length() == 0)
	{
		std::cout << "No file given!" << "\"\n";
		return NULL;
	}

	//std::cout<<"Try to switch Source \""<<u.toStdString()<<"\"\n";
	if(streamManager->open(u.toStdString()))
	{
		// return the complete file as a QByteArray
		BYTE* ba = streamManager->getStream();
		QByteArray* byteArray = new QByteArray((char*)ba,streamManager->getStreamSize());
		return byteArray;
		// return streamManager->getStream();
	}
	else
	{
		std::cout << "Error opening input file \""<<u.toStdString()<<"\".\nTo extract the input file, ensure that the file path is correct. If the input file name contains specific characters, these must be masked and the inputfile name must be set in quotation marks.\n\n";
		throw XCLException("Exception in XCELProcessorInterface: CStreamReader cannot open input file!");
		return NULL;
	}
}
예제 #2
0
/**
 * Set the value of end
 * @param new_var the new value of end
 */
void XCLSyntaxExpression::setEnd ( _LENGTH new_var )
{
  if(new_var > LENGTH_MAX)throw XCLException("End out of Range");
  end = new_var;
  if(length !=LENGTH_MAX)
    start=end-length+1;
  else if(start != LENGTH_MAX)
    length=end-start+1;
}
예제 #3
0
/**
 * Set the value of length
 * @param new_var the new value of length
 */
void XCLSyntaxExpression::setLength ( _LENGTH new_var )
{
  if(new_var > LENGTH_MAX)throw XCLException("Length out of Range");
  length = new_var;
  if(start != LENGTH_MAX)
    end=start+length-1;
  else if(end != LENGTH_MAX)
    start=end-length+1;
}
예제 #4
0
const XCLFilter XCLSyntaxExpression::getFilter(const _UINT32 filterno)
{
  _LENGTH size = filterChain.size();
  if (filterno < size)
  {
    XCLFilter temp =  filterChain.at(filterno);
    return temp;
  }
  else
  {
    throw XCLException("no filter found");
  }
}
예제 #5
0
/**
 * Set the value of start
 * @param new_var the new value of start
 */
void XCLSyntaxExpression::setStart ( _LENGTH new_var )
{

  if(new_var > LENGTH_MAX)throw XCLException("Start out of Range");
  start=new_var;
/*  if(length != LENGTH_MAX)
 {
std::cout<<"XCLSyntaxExpression::setStart Length "<<length<<"\n";
    end=start+length-1;
}
  else if(end != LENGTH_MAX)
    length = end-start+1;*/
  // positionType=FIXED;

}
예제 #6
0
XCLSyntaxExpression* XCELProcessorInterface::getNewGramm(XCLSyntaxProcess* element,
							QHash<QString,XCLSyntaxExpression*>* grammarIndex,
							FileParserState& state)
{
//Fetch referenced grammatical Expression
  XCLSyntaxExpression* newGramm;
  if (grammarIndex->contains(element->getXcelReference()))
    newGramm=grammarIndex->value(element->getXcelReference());
  else
    throw XCLException("No expression with the name '"+element->getXcelReference()+"' found! Please check the 'XcelRef's in the XCEL-file!");

  newGramm->setParent(NULL);
  QVector<XCLProcessMethod> methods=element->getMethods();


  if(!methods.isEmpty())
    executeGrammarMethods(newGramm,state,element);


//--Fetch End
return newGramm;
}
예제 #7
0
/*! \void XCELMainProcessor::process(XCLSyntaxExpression* expr, XCLParsingItem* item, const QVector<XCLProcessMethod>& methods, FileParserState&& state)
 *  \brief Called by the Factory class to manage the processing of methods performed on an existing XCLSyntaxEpression.
 *  \param expr A pointer to the XCLSyntaxExpression, the processing method will be performed on.
 *  \param item A pointer to the parent XCLParsingItem.
 *  \param methods A list of the methods which have to be executed on the XCLSyntaxExpression expr.
 *  \param actState A reference to the current FileParserState&.
 *  \exception XCLException 
 
Calls for each method found in the list the appropriate function to perform the particular task.
**/
void XCELMainProcessor::executeGrammarMethods( XCLSyntaxExpression* expr, FileParserState& state, XCLSyntaxProcess* element)
{
  QVector<XCLProcessMethod> m=element->getMethods();
  _LENGTH size = m.size();
  XCELProcessingMethod* meth;
  for (_LENGTH i=0;i<size;i++)
  {
    QString name=(m[i].getName());
    QList<XCELProcessingMethod*> meths = methodRegister.values(name);
    if(meths.size()==0)
	{
		std::cout<<"No Method with name: "<<name.toStdString()<<" found\n";
		return;
	}
    if(meths.size()>1)
    {
      //anzahl der Parameter prüfen
    }
    else
    {
      meth = meths.at(0);
      try
      {	
#ifdef PlanetsDebug
        std::cout<<m[i].getName().toStdString()<<"\n";
#endif
        if(!meth->process(reader,expr,m[i].getParameters(),vectorHash))
          throw XCLException(m[i].getName());
      }
      catch(XCLException exception)
      {
        exception.message();
      }
    }
  }
  // useless statement for less compiler-warnings
  (void)state;

}
예제 #8
0
void XCELMainProcessor::processConfigureParserProcessing( XCLSyntaxProcess* process, FileParserState& state)
{
  QVector<XCLProcessMethod> m=process->getMethods();
  _LENGTH size = m.size();
  XCELProcessingMethod* meth;
  for (_LENGTH i=0;i<size;i++)
  {
    QString name=(m[i].getName());
  //  std::cout<<name.toStdString()<<"\n";
    QList<XCELProcessingMethod*> meths = methodRegister.values(name);
    if(meths.size()==0)
	{
		std::cout<<"No Method with name: "<<name.toStdString()<<" found\n";
		return;
	}
    if(meths.size()>1)
    {
      //anzahl der Parameter prüfen
    }
    else
    {
      meth = meths.at(0);
      if(!meth->process(reader,NULL,m[i].getParameters(),vectorHash))
      {	
	/**
	* 	Durch die ABfrage, ob ein bestimmtes Element bereits im Index ist, soll das 
	*	erneute Lesen verhindert werden.
	*/
	std::cout<<"Message causes exception: "<<m[i].getName().toStdString()<<"\n";
	 throw XCLException(m[i].getName());
      }
    }
  }
  // useless statement for less compiler-warnings
  (void)state;
}
예제 #9
0
/*! \void XCLProcessor::performSetLength(XCLSyntaxExpression* expr, QVector<XCLProcessParameter> param,XCLParsingItem* item)
 *  \brief Sets the length of the XCLSyntaxExpression \a expr to the value given by the parameters of the method.
 *  \param expr A pointer to the XCLSyntaxExpression, the processing method will be performed on.
 *  \param param A list of parameters for this method.
 *  \param item A pointer to the parent XCLParsingItem.
 *  \exception XCLException 


**/
void XCLProcessor::performSetLength(XCLSyntaxExpression* expr, QVector<XCLProcessParameter> param,FileParserState& item)
{
    _UINT32 count=0;
    QString count2; // referenced or calculated value as QString

    BOOL isBigEndian;
    QString interpretation;
try
{
    //Value and DataType is given   
    if(param.size()==2)
    {
        XCLProcessParameter p1=param.at(0); //the value
        XCLProcessParameter p2=param.at(1); //the data type

        QString type = p2.getValue(item.index);

        //value has to be calculated
        if (p1.getValueType() == XCLProcessParameter::MATHEX)
        {
        
            XCLCalculator calc;
            count2 = calc.parseExpression(p1.getValue(), item.index);
           
        //    count=XCLStringConverter::string2Number<_UINT32>(count2,"uint64",expr->getIsBigEndian()); //something funny returns here ???
            count=count2.toInt();
        }
        else
        {   
            XCLInputNormalizer normalizer;
            isBigEndian = (item.index.get(p1.getValueReference()))->at(0)->getIsBigEndian();
            interpretation = (item.index.get(p1.getValueReference()))->at(0)->getInterpretation();

            if (isBigEndian)
            {
       

		QByteArray ba = p1.getValueAsBA(&item.index);

		count = (normalizer.normalizeValue((UCHAR*)ba.data(),ba.size(),interpretation, isBigEndian)->toInt());
                //count = p1.getValue(item.index).toLong();
            }
            else
            {
         

		QByteArray ba = p1.getValueAsBA(&item.index);

		count = (normalizer.normalizeValue((UCHAR*)ba.data(),ba.size(),interpretation, isBigEndian)->toInt());

            }            
        }

        _UINT8 typeLength = getTypeLength(type);
     

        expr->setLength(count*typeLength);
     

    }
    else if (param.size()==1)
    {
        XCLProcessParameter p=param.at(0);
        
        //value has to be calculated
        if (p.getValueType() == XCLProcessParameter::MATHEX)
        {
            XCLCalculator calc;
            count = calc.parseExpression(p.getValue(), item.index);
       
            expr->setLength(count);
        }
        else
        {
            _UINT32 num1=p.getValue(item.index).toLong();
      
            expr->setLength(num1); 
    
        }

    }
    else
    {
throw XCLException("Possible candidates for setLength are: setLength( length ) or setLength( count , type )\n");

    }
}
catch(XCLException exception)
{
exception.message();
throw XCLException("XCLProcessor couln´t execute setLength()\n");
}
}