예제 #1
0
/*! \void XCLProcessor::performSetStart(XCLSyntaxExpression* expr, QVector<XCLProcessParameter> param,XCLParsingItem* item)
 *  \brief Sets the startposition of the XCLSyntaxExpression \a expr to the value given by the parameter 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.
 *  \param state The current FileParserState&.
 *  \exception XCLException 

**/
void XCLProcessor::performSetStart(XCLSyntaxExpression* expr,
                                   QVector<XCLProcessParameter> param,
                                   FileParserState& item)
{

    XCLProcessParameter p=param.at(0);

    _UINT32 num;
    QString numstring;
 
 

    if (p.getValueReference().startsWith("#"))
    {
     
        XCLCalculator calc;
        numstring = calc.parseExpression(p.getValueReference(), item.index);
    
    }

    if(p.getListRef())
    {
        IndexedVector* iv;
        if(vectorHash.contains(p.getValueReference()))
        {
            iv = vectorHash.value(p.getValueReference());
        }
        else
	{
           iv = new IndexedVector();
	   iv->vector = item.index.get(p.getValueReference());
           iv->index=0;
	   vectorHash.insert( p.getValueReference(),iv);
	}
        if((_SINT32)iv->index >= iv->vector->size())
        {
	  throw XCLOutOfRangeException();
	}
        num = iv->vector->at(iv->index++)->getInterpretedValue().toInt();
    }
    else
    { 
        num=p.getValue(item.index).toInt(); 
    }

    expr->setStart(num);
    expr->setPositionType( XCLSyntaxExpression::FIXED );
}
예제 #2
0
BOOL XCELSetStartProcessingMethod::process(	XCELReader* reader,
						XCLSyntaxExpression* expr,
                        			QVector<XCLProcessParameter> param,
                        			QHash<QString,IndexedVector*> vectorHash)

{

FileParserState* state = reader->getState();

   XCLProcessParameter p=param.at(0);

    _UINT32 num;
    QString numstring;
 


    if (p.getValueReference().startsWith("#"))
    {
   
        XCLCalculator calc;
        numstring = calc.parseExpression(p.getValueReference(), state->index);
     
    }

    if(p.getListRef())
    {
  // std::cout<<"Enter listRef setStart processing\n";
        IndexedVector* iv;
        if(vectorHash.contains(p.getValueReference()))
        {
            iv = vectorHash.value(p.getValueReference());
          
        }
        else
	{
           iv = new IndexedVector();
	   iv->vector = state->index.get(p.getValueReference());
           iv->index=0;
	   vectorHash.insert( p.getValueReference(),iv);
	}
        // ### Dieses Statement ist eigentlich quatsch, weil iv->index niemals kleiner als 0 werden kann.
	// if(iv->index >= iv->vector->size() || iv->index < 0 )
	if((_SIZE)iv->index >= iv->vector->size())
        {
	    throw XCLOutOfRangeException("List Ref contains no more values");
	}
        num = iv->vector->at(iv->index++)->getInterpretedValue().toInt();
#ifdef PlanetsDebug
        std::cout<<"NUM: "<<num<<"\n";
#endif
    }
    /*else if(p.getStackRef())
    {
        IndexedVector* iv;
        if(vectorHash.contains(p.getValueReference()))
        {
            iv = vectorHash.value(p.getValueReference());
          
        }
        else
	{
           iv = new IndexedVector();

	   iv->vector = state->index.get(p.getValueReference());
      
           iv->index=iv->verctor.size()-1;
          
	   vectorHash.insert( p.getValueReference(),iv);
	}
        if(iv->index >= iv->vector->size())throw XCLOutOfRangeException();
        num=iv->vector->at(iv->index--)->getInterpretedValue().toInt();
     }*/
    else
    { 
//p.print();
  
        QString value=p.getValue(state->index); 
	num=value.toInt();


    }
    expr->setStart(num);
    expr->setPositionType( XCLSyntaxExpression::FIXED );

  return TRUE;
}
예제 #3
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");
}
}