mirror of
https://gitlab.com/smart-pattern/valentina.git
synced 2024-09-19 23:34:04 +02:00
Declare variables inside the loop.
This commit is contained in:
parent
21f3a5dc78
commit
c696ba0e1a
|
@ -2611,8 +2611,7 @@ void TMainWindow::ExportToIndividual()
|
|||
VMeasurements individualMeasurements(m_mUnit, tmpData.data());
|
||||
|
||||
const QMap<int, QSharedPointer<VMeasurement>> orderedTable = OrderedMeasurements();
|
||||
QMap<int, QSharedPointer<VMeasurement>>::const_iterator iMap;
|
||||
for (iMap = orderedTable.constBegin(); iMap != orderedTable.constEnd(); ++iMap)
|
||||
for (auto iMap = orderedTable.constBegin(); iMap != orderedTable.constEnd(); ++iMap)
|
||||
{
|
||||
const QSharedPointer<VMeasurement> &meash = iMap.value();
|
||||
individualMeasurements.AddEmpty(meash->GetName());
|
||||
|
@ -4680,8 +4679,7 @@ auto TMainWindow::OrderedMeasurements() const -> QMap<int, QSharedPointer<VMeasu
|
|||
{
|
||||
const QMap<QString, QSharedPointer<VMeasurement>> table = m_data->DataMeasurementsWithSeparators();
|
||||
QMap<int, QSharedPointer<VMeasurement>> orderedTable;
|
||||
QMap<QString, QSharedPointer<VMeasurement>>::const_iterator iterMap;
|
||||
for (iterMap = table.constBegin(); iterMap != table.constEnd(); ++iterMap)
|
||||
for (auto iterMap = table.constBegin(); iterMap != table.constEnd(); ++iterMap)
|
||||
{
|
||||
const QSharedPointer<VMeasurement> &meash = iterMap.value();
|
||||
orderedTable.insert(meash->Index(), meash);
|
||||
|
|
|
@ -1401,10 +1401,9 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table,
|
|||
table->blockSignals(true);
|
||||
table->clearContents();
|
||||
|
||||
QMap<QString, QSharedPointer<VIncrement>>::const_iterator i;
|
||||
QMap<quint32, QString> map;
|
||||
// Sorting QHash by id
|
||||
for (i = increments.constBegin(); i != increments.constEnd(); ++i)
|
||||
for (auto i = increments.constBegin(); i != increments.constEnd(); ++i)
|
||||
{
|
||||
const QSharedPointer<VIncrement> &incr = i.value();
|
||||
if (takePreviewCalculations == incr->IsPreviewCalculation())
|
||||
|
|
|
@ -1950,10 +1950,9 @@ void MainWindow::ExportToCSVData(const QString &fileName, bool withHeader, int m
|
|||
|
||||
auto SavePreviewCalculation = [¤tRow, &csv, increments](bool save)
|
||||
{
|
||||
QMap<QString, QSharedPointer<VIncrement>>::const_iterator i;
|
||||
QMap<quint32, QString> map;
|
||||
// Sorting QHash by id
|
||||
for (i = increments.constBegin(); i != increments.constEnd(); ++i)
|
||||
for (auto i = increments.constBegin(); i != increments.constEnd(); ++i)
|
||||
{
|
||||
const QSharedPointer<VIncrement> &incr = i.value();
|
||||
if (incr->IsPreviewCalculation() == save)
|
||||
|
|
|
@ -905,8 +905,7 @@ auto MainWindowsNoGUI::PrepareDetailsForLayout(const QVector<DetailForLayout> &d
|
|||
layoutDetails.reserve(details.size());
|
||||
const QFuture<VLayoutPiece> future = futureWatcher.future();
|
||||
|
||||
QFuture<VLayoutPiece>::const_iterator i;
|
||||
for (i = future.constBegin(); i != future.constEnd(); ++i)
|
||||
for (auto i = future.constBegin(); i != future.constEnd(); ++i)
|
||||
{
|
||||
layoutDetails.append(*i);
|
||||
}
|
||||
|
|
|
@ -1910,8 +1910,6 @@ void QmuParserBase::Eval(qreal *results, int nBulkSize) const
|
|||
{
|
||||
CreateRPN();
|
||||
|
||||
int i = 0;
|
||||
|
||||
#ifdef QMUP_USE_OPENMP
|
||||
// #define DEBUG_OMP_STUFF
|
||||
#ifdef DEBUG_OMP_STUFF
|
||||
|
@ -1924,7 +1922,7 @@ void QmuParserBase::Eval(qreal *results, int nBulkSize) const
|
|||
omp_set_num_threads(nMaxThreads);
|
||||
|
||||
#pragma omp parallel for schedule(static, nBulkSize / nMaxThreads) private(nThreadID)
|
||||
for (i = 0; i < nBulkSize; ++i)
|
||||
for (int i = 0; i < nBulkSize; ++i)
|
||||
{
|
||||
int nThreadID = omp_get_thread_num();
|
||||
results[i] = ParseCmdCodeBulk(i, nThreadID);
|
||||
|
@ -1953,7 +1951,7 @@ void QmuParserBase::Eval(qreal *results, int nBulkSize) const
|
|||
#endif
|
||||
|
||||
#else
|
||||
for (i = 0; i < nBulkSize; ++i)
|
||||
for (int i = 0; i < nBulkSize; ++i)
|
||||
{
|
||||
results[i] = ParseCmdCodeBulk(i, 0);
|
||||
}
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
|
||||
#include "qmuparsertokenreader.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <QList>
|
||||
#include <QMessageLogger>
|
||||
#include <QStringList>
|
||||
#include <QtDebug>
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
|
@ -51,16 +51,27 @@ namespace qmu
|
|||
* @sa Assign
|
||||
* @throw nothrow
|
||||
*/
|
||||
QmuParserTokenReader::QmuParserTokenReader ( const QmuParserTokenReader &a_Reader )
|
||||
:m_pParser( a_Reader.m_pParser ), m_strFormula( a_Reader.m_strFormula ), m_iPos( a_Reader.m_iPos ),
|
||||
m_iSynFlags( a_Reader.m_iSynFlags ), m_bIgnoreUndefVar( a_Reader.m_bIgnoreUndefVar ),
|
||||
m_pFunDef( a_Reader.m_pFunDef ), m_pPostOprtDef( a_Reader.m_pPostOprtDef ),
|
||||
m_pInfixOprtDef( a_Reader.m_pInfixOprtDef ), m_pOprtDef( a_Reader.m_pOprtDef),
|
||||
m_pConstDef( a_Reader.m_pConstDef ), m_pStrVarDef( a_Reader.m_pStrVarDef ), m_pVarDef( a_Reader.m_pVarDef ),
|
||||
m_pFactory( a_Reader.m_pFactory ), m_pFactoryData( a_Reader.m_pFactoryData ), m_vIdentFun( a_Reader.m_vIdentFun ),
|
||||
m_UsedVar( a_Reader.m_UsedVar ), m_iBrackets( a_Reader.m_iBrackets ),
|
||||
m_cArgSep( a_Reader.m_cArgSep )
|
||||
{}
|
||||
QmuParserTokenReader::QmuParserTokenReader(const QmuParserTokenReader &a_Reader)
|
||||
: m_pParser(a_Reader.m_pParser),
|
||||
m_strFormula(a_Reader.m_strFormula),
|
||||
m_iPos(a_Reader.m_iPos),
|
||||
m_iSynFlags(a_Reader.m_iSynFlags),
|
||||
m_bIgnoreUndefVar(a_Reader.m_bIgnoreUndefVar),
|
||||
m_pFunDef(a_Reader.m_pFunDef),
|
||||
m_pPostOprtDef(a_Reader.m_pPostOprtDef),
|
||||
m_pInfixOprtDef(a_Reader.m_pInfixOprtDef),
|
||||
m_pOprtDef(a_Reader.m_pOprtDef),
|
||||
m_pConstDef(a_Reader.m_pConstDef),
|
||||
m_pStrVarDef(a_Reader.m_pStrVarDef),
|
||||
m_pVarDef(a_Reader.m_pVarDef),
|
||||
m_pFactory(a_Reader.m_pFactory),
|
||||
m_pFactoryData(a_Reader.m_pFactoryData),
|
||||
m_vIdentFun(a_Reader.m_vIdentFun),
|
||||
m_UsedVar(a_Reader.m_UsedVar),
|
||||
m_iBrackets(a_Reader.m_iBrackets),
|
||||
m_cArgSep(a_Reader.m_cArgSep)
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -71,11 +82,11 @@ QmuParserTokenReader::QmuParserTokenReader ( const QmuParserTokenReader &a_Reade
|
|||
* @param a_Reader Object to copy to this token reader.
|
||||
* @throw nothrow
|
||||
*/
|
||||
auto QmuParserTokenReader::operator= ( const QmuParserTokenReader &a_Reader ) -> QmuParserTokenReader&
|
||||
auto QmuParserTokenReader::operator=(const QmuParserTokenReader &a_Reader) -> QmuParserTokenReader &
|
||||
{
|
||||
if ( &a_Reader != this )
|
||||
if (&a_Reader != this)
|
||||
{
|
||||
Assign ( a_Reader );
|
||||
Assign(a_Reader);
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
@ -88,7 +99,7 @@ auto QmuParserTokenReader::operator= ( const QmuParserTokenReader &a_Reader ) ->
|
|||
* @param a_Reader Object from which the state should be copied.
|
||||
* @throw nothrow
|
||||
*/
|
||||
void QmuParserTokenReader::Assign ( const QmuParserTokenReader &a_Reader )
|
||||
void QmuParserTokenReader::Assign(const QmuParserTokenReader &a_Reader)
|
||||
{
|
||||
m_pParser = a_Reader.m_pParser;
|
||||
m_strFormula = a_Reader.m_strFormula;
|
||||
|
@ -124,11 +135,11 @@ void QmuParserTokenReader::Assign ( const QmuParserTokenReader &a_Reader )
|
|||
* @post #m_pParser==a_pParser
|
||||
* @param a_pParent Parent parser object of the token reader.
|
||||
*/
|
||||
QmuParserTokenReader::QmuParserTokenReader ( QmuParserBase *a_pParent )
|
||||
: m_pParser ( a_pParent )
|
||||
QmuParserTokenReader::QmuParserTokenReader(QmuParserBase *a_pParent)
|
||||
: m_pParser(a_pParent)
|
||||
{
|
||||
assert ( m_pParser );
|
||||
SetParent ( m_pParser );
|
||||
assert(m_pParser);
|
||||
SetParent(m_pParser);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -140,22 +151,22 @@ QmuParserTokenReader::QmuParserTokenReader ( QmuParserBase *a_pParent )
|
|||
* @return A new QParserTokenReader object.
|
||||
* @throw nothrow
|
||||
*/
|
||||
auto QmuParserTokenReader::Clone ( QmuParserBase *a_pParent ) const -> QmuParserTokenReader*
|
||||
auto QmuParserTokenReader::Clone(QmuParserBase *a_pParent) const -> QmuParserTokenReader *
|
||||
{
|
||||
std::unique_ptr<QmuParserTokenReader> ptr ( new QmuParserTokenReader ( *this ) );
|
||||
ptr->SetParent ( a_pParent );
|
||||
std::unique_ptr<QmuParserTokenReader> ptr(new QmuParserTokenReader(*this));
|
||||
ptr->SetParent(a_pParent);
|
||||
return ptr.release();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto QmuParserTokenReader::SaveBeforeReturn ( const token_type &tok ) -> QmuParserTokenReader::token_type&
|
||||
auto QmuParserTokenReader::SaveBeforeReturn(const token_type &tok) -> QmuParserTokenReader::token_type &
|
||||
{
|
||||
m_lastTok = tok;
|
||||
return m_lastTok;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void QmuParserTokenReader::AddValIdent ( identfun_type a_pCallback )
|
||||
void QmuParserTokenReader::AddValIdent(identfun_type a_pCallback)
|
||||
{
|
||||
// Use push_front is used to give user defined callbacks a higher priority than
|
||||
// the built in ones. Otherwise reading hex numbers would not work
|
||||
|
@ -163,11 +174,11 @@ void QmuParserTokenReader::AddValIdent ( identfun_type a_pCallback )
|
|||
// the rest impossible.
|
||||
// reference:
|
||||
// http://sourceforge.net/projects/muparser/forums/forum/462843/topic/4824956
|
||||
m_vIdentFun.push_front ( a_pCallback );
|
||||
m_vIdentFun.push_front(a_pCallback);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void QmuParserTokenReader::SetVarCreator ( facfun_type a_pFactory, void *pUserData )
|
||||
void QmuParserTokenReader::SetVarCreator(facfun_type a_pFactory, void *pUserData)
|
||||
{
|
||||
m_pFactory = a_pFactory;
|
||||
m_pFactoryData = pUserData;
|
||||
|
@ -180,7 +191,7 @@ void QmuParserTokenReader::SetVarCreator ( facfun_type a_pFactory, void *pUserDa
|
|||
* Sets the formula position index to zero and set Syntax flags to default for initial formula parsing.
|
||||
* @pre [assert] triggered if a_szFormula==0
|
||||
*/
|
||||
void QmuParserTokenReader::SetFormula ( const QString &a_strFormula )
|
||||
void QmuParserTokenReader::SetFormula(const QString &a_strFormula)
|
||||
{
|
||||
m_strFormula = a_strFormula;
|
||||
ReInit();
|
||||
|
@ -211,7 +222,7 @@ void QmuParserTokenReader::ReInit()
|
|||
auto QmuParserTokenReader::ReadNextToken(const QLocale &locale, bool cNumbers, const QChar &decimal,
|
||||
const QChar &thousand) -> QmuParserTokenReader::token_type
|
||||
{
|
||||
assert ( m_pParser );
|
||||
assert(m_pParser);
|
||||
|
||||
token_type tok;
|
||||
|
||||
|
@ -221,49 +232,49 @@ auto QmuParserTokenReader::ReadNextToken(const QLocale &locale, bool cNumbers, c
|
|||
++m_iPos;
|
||||
}
|
||||
|
||||
if ( IsEOF ( tok ) )
|
||||
if (IsEOF(tok))
|
||||
{
|
||||
return SaveBeforeReturn ( tok ); // Check for end of formula
|
||||
return SaveBeforeReturn(tok); // Check for end of formula
|
||||
}
|
||||
if ( IsOprt ( tok ) )
|
||||
if (IsOprt(tok))
|
||||
{
|
||||
return SaveBeforeReturn ( tok ); // Check for user defined binary operator
|
||||
return SaveBeforeReturn(tok); // Check for user defined binary operator
|
||||
}
|
||||
if ( IsFunTok ( tok ) )
|
||||
if (IsFunTok(tok))
|
||||
{
|
||||
return SaveBeforeReturn ( tok ); // Check for function token
|
||||
return SaveBeforeReturn(tok); // Check for function token
|
||||
}
|
||||
if ( IsBuiltIn ( tok ) )
|
||||
if (IsBuiltIn(tok))
|
||||
{
|
||||
return SaveBeforeReturn ( tok ); // Check built in operators / tokens
|
||||
return SaveBeforeReturn(tok); // Check built in operators / tokens
|
||||
}
|
||||
if ( IsArgSep ( tok ) )
|
||||
if (IsArgSep(tok))
|
||||
{
|
||||
return SaveBeforeReturn ( tok ); // Check for function argument separators
|
||||
return SaveBeforeReturn(tok); // Check for function argument separators
|
||||
}
|
||||
if ( IsValTok ( tok, locale, cNumbers, decimal, thousand ) )
|
||||
if (IsValTok(tok, locale, cNumbers, decimal, thousand))
|
||||
{
|
||||
return SaveBeforeReturn ( tok ); // Check for values / constant tokens
|
||||
return SaveBeforeReturn(tok); // Check for values / constant tokens
|
||||
}
|
||||
if ( IsVarTok ( tok ) )
|
||||
if (IsVarTok(tok))
|
||||
{
|
||||
return SaveBeforeReturn ( tok ); // Check for variable tokens
|
||||
return SaveBeforeReturn(tok); // Check for variable tokens
|
||||
}
|
||||
if ( IsStrVarTok ( tok ) )
|
||||
if (IsStrVarTok(tok))
|
||||
{
|
||||
return SaveBeforeReturn ( tok ); // Check for string variables
|
||||
return SaveBeforeReturn(tok); // Check for string variables
|
||||
}
|
||||
if ( IsString ( tok ) )
|
||||
if (IsString(tok))
|
||||
{
|
||||
return SaveBeforeReturn ( tok ); // Check for String tokens
|
||||
return SaveBeforeReturn(tok); // Check for String tokens
|
||||
}
|
||||
if ( IsInfixOpTok ( tok ) )
|
||||
if (IsInfixOpTok(tok))
|
||||
{
|
||||
return SaveBeforeReturn ( tok ); // Check for unary operators
|
||||
return SaveBeforeReturn(tok); // Check for unary operators
|
||||
}
|
||||
if ( IsPostOpTok ( tok ) )
|
||||
if (IsPostOpTok(tok))
|
||||
{
|
||||
return SaveBeforeReturn ( tok ); // Check for unary operators
|
||||
return SaveBeforeReturn(tok); // Check for unary operators
|
||||
}
|
||||
|
||||
// Check String for undefined variable token. Done only if a
|
||||
|
@ -273,9 +284,9 @@ auto QmuParserTokenReader::ReadNextToken(const QLocale &locale, bool cNumbers, c
|
|||
// (The GetUsedVar function must suppress the error for
|
||||
// undefined variables in order to collect all variable
|
||||
// names including the undefined ones.)
|
||||
if ( ( m_bIgnoreUndefVar || m_pFactory ) && IsUndefVarTok ( tok ) )
|
||||
if ((m_bIgnoreUndefVar || m_pFactory) && IsUndefVarTok(tok))
|
||||
{
|
||||
return SaveBeforeReturn ( tok );
|
||||
return SaveBeforeReturn(tok);
|
||||
}
|
||||
|
||||
// Check for unknown token
|
||||
|
@ -284,17 +295,17 @@ auto QmuParserTokenReader::ReadNextToken(const QLocale &locale, bool cNumbers, c
|
|||
//
|
||||
QString strTok;
|
||||
qmusizetype const iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos);
|
||||
if ( iEnd != m_iPos )
|
||||
if (iEnd != m_iPos)
|
||||
{
|
||||
Error ( ecUNASSIGNABLE_TOKEN, m_iPos, strTok );
|
||||
Error(ecUNASSIGNABLE_TOKEN, m_iPos, strTok);
|
||||
}
|
||||
|
||||
Error ( ecUNASSIGNABLE_TOKEN, m_iPos, m_strFormula.mid ( m_iPos ) );
|
||||
Error(ecUNASSIGNABLE_TOKEN, m_iPos, m_strFormula.mid(m_iPos));
|
||||
return {}; // never reached
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void QmuParserTokenReader::SetParent ( QmuParserBase *a_pParent )
|
||||
void QmuParserTokenReader::SetParent(QmuParserBase *a_pParent)
|
||||
{
|
||||
m_pParser = a_pParent;
|
||||
m_pFunDef = &a_pParent->m_FunDef;
|
||||
|
@ -318,8 +329,8 @@ void QmuParserTokenReader::SetParent ( QmuParserBase *a_pParent )
|
|||
*/
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_MSVC(4309)
|
||||
auto QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a_sTok,
|
||||
qmusizetype a_iPos ) const -> qmusizetype
|
||||
auto QmuParserTokenReader::ExtractToken(const QString &a_szCharSet, QString &a_sTok, qmusizetype a_iPos) const
|
||||
-> qmusizetype
|
||||
{
|
||||
qmusizetype iEnd = FindFirstNotOf(m_strFormula, a_szCharSet, a_iPos);
|
||||
|
||||
|
@ -345,17 +356,17 @@ auto QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a
|
|||
* alphabetic characters are allowed in operator tokens. To avoid this this function checks specifically
|
||||
* for operator tokens.
|
||||
*/
|
||||
auto QmuParserTokenReader::ExtractOperatorToken ( QString &a_sTok, qmusizetype a_iPos ) const -> qmusizetype
|
||||
auto QmuParserTokenReader::ExtractOperatorToken(QString &a_sTok, qmusizetype a_iPos) const -> qmusizetype
|
||||
{
|
||||
qmusizetype iEnd = FindFirstNotOf(m_strFormula, m_pParser->ValidOprtChars(), a_iPos);
|
||||
|
||||
if ( iEnd == -1 )
|
||||
if (iEnd == -1)
|
||||
{
|
||||
iEnd = m_strFormula.length();
|
||||
}
|
||||
|
||||
// Assign token string if there was something found
|
||||
if ( a_iPos != iEnd )
|
||||
if (a_iPos != iEnd)
|
||||
{
|
||||
a_sTok = m_strFormula.mid(a_iPos, iEnd - a_iPos);
|
||||
return iEnd;
|
||||
|
@ -363,7 +374,7 @@ auto QmuParserTokenReader::ExtractOperatorToken ( QString &a_sTok, qmusizetype a
|
|||
|
||||
// There is still the chance of having to deal with an operator consisting exclusively
|
||||
// of alphabetic characters.
|
||||
return ExtractToken (QStringLiteral("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), a_sTok, a_iPos );
|
||||
return ExtractToken(QStringLiteral("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), a_sTok, a_iPos);
|
||||
}
|
||||
QT_WARNING_POP
|
||||
|
||||
|
@ -373,43 +384,43 @@ QT_WARNING_POP
|
|||
* @param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token.
|
||||
* @return true if an operator token has been found.
|
||||
*/
|
||||
auto QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok ) -> bool
|
||||
auto QmuParserTokenReader::IsBuiltIn(token_type &a_Tok) -> bool
|
||||
{
|
||||
const QStringList pOprtDef = QmuParserBase::GetOprtDef();
|
||||
|
||||
// Compare token with function and operator strings
|
||||
// check string for operator/function
|
||||
for ( int i = 0; i < pOprtDef.size(); ++i )
|
||||
for (int i = 0; i < pOprtDef.size(); ++i)
|
||||
{
|
||||
qmusizetype const len = pOprtDef.at(i).length();
|
||||
if ( pOprtDef.at ( i ) == m_strFormula.mid ( m_iPos, len ) )
|
||||
if (pOprtDef.at(i) == m_strFormula.mid(m_iPos, len))
|
||||
{
|
||||
if (i >= cmLE && i <= cmASSIGN)
|
||||
{
|
||||
//if (len!=sTok.length())
|
||||
// if (len!=sTok.length())
|
||||
// continue;
|
||||
|
||||
// The assignement operator need special treatment
|
||||
if ( i == cmASSIGN && m_iSynFlags & noASSIGN )
|
||||
if (i == cmASSIGN && m_iSynFlags & noASSIGN)
|
||||
{
|
||||
Error ( ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at ( i ) );
|
||||
Error(ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at(i));
|
||||
}
|
||||
|
||||
if ( not m_pParser->HasBuiltInOprt())
|
||||
if (not m_pParser->HasBuiltInOprt())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( m_iSynFlags & noOPT )
|
||||
if (m_iSynFlags & noOPT)
|
||||
{
|
||||
// Maybe its an infix operator not an operator
|
||||
// Both operator types can share characters in
|
||||
// their identifiers
|
||||
if ( IsInfixOpTok ( a_Tok ) )
|
||||
if (IsInfixOpTok(a_Tok))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Error ( ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at ( i ) );
|
||||
Error(ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at(i));
|
||||
}
|
||||
|
||||
m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE;
|
||||
|
@ -417,12 +428,12 @@ auto QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok ) -> bool
|
|||
}
|
||||
else if (i == cmBO)
|
||||
{
|
||||
if ( m_iSynFlags & noBO )
|
||||
if (m_iSynFlags & noBO)
|
||||
{
|
||||
Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) );
|
||||
Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at(i));
|
||||
}
|
||||
|
||||
if ( m_lastTok.GetCode() == cmFUNC )
|
||||
if (m_lastTok.GetCode() == cmFUNC)
|
||||
{
|
||||
m_iSynFlags = noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE;
|
||||
}
|
||||
|
@ -435,43 +446,43 @@ auto QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok ) -> bool
|
|||
}
|
||||
else if (i == cmBC)
|
||||
{
|
||||
if ( m_iSynFlags & noBC )
|
||||
if (m_iSynFlags & noBC)
|
||||
{
|
||||
Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) );
|
||||
Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at(i));
|
||||
}
|
||||
|
||||
m_iSynFlags = noBO | noVAR | noVAL | noFUN | noINFIXOP | noSTR | noASSIGN;
|
||||
|
||||
if ( --m_iBrackets < 0 )
|
||||
if (--m_iBrackets < 0)
|
||||
{
|
||||
Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) );
|
||||
Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at(i));
|
||||
}
|
||||
}
|
||||
else if (i == cmELSE)
|
||||
{
|
||||
if ( m_iSynFlags & noELSE )
|
||||
if (m_iSynFlags & noELSE)
|
||||
{
|
||||
Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) );
|
||||
Error(ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at(i));
|
||||
}
|
||||
|
||||
m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE;
|
||||
}
|
||||
else if (i == cmIF)
|
||||
{
|
||||
if ( m_iSynFlags & noIF )
|
||||
if (m_iSynFlags & noIF)
|
||||
{
|
||||
Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) );
|
||||
Error(ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at(i));
|
||||
}
|
||||
|
||||
m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE;
|
||||
}
|
||||
else // The operator is listed in c_DefaultOprt, but not here. This is a bad thing...
|
||||
{
|
||||
Error ( ecINTERNAL_ERROR );
|
||||
Error(ecINTERNAL_ERROR);
|
||||
}
|
||||
|
||||
m_iPos += len;
|
||||
a_Tok.Set ( static_cast<ECmdCode>(i), pOprtDef.at ( i ) );
|
||||
a_Tok.Set(static_cast<ECmdCode>(i), pOprtDef.at(i));
|
||||
return true;
|
||||
} // if operator string found
|
||||
} // end of for all operator strings
|
||||
|
@ -480,21 +491,21 @@ auto QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok ) -> bool
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto QmuParserTokenReader::IsArgSep ( token_type &a_Tok ) -> bool
|
||||
auto QmuParserTokenReader::IsArgSep(token_type &a_Tok) -> bool
|
||||
{
|
||||
if ( m_strFormula.at ( m_iPos ) == m_cArgSep )
|
||||
if (m_strFormula.at(m_iPos) == m_cArgSep)
|
||||
{
|
||||
// copy the separator into null terminated string
|
||||
QString const szSep(m_cArgSep);
|
||||
|
||||
if ( m_iSynFlags & noARG_SEP )
|
||||
if (m_iSynFlags & noARG_SEP)
|
||||
{
|
||||
Error ( ecUNEXPECTED_ARG_SEP, m_iPos, szSep );
|
||||
Error(ecUNEXPECTED_ARG_SEP, m_iPos, szSep);
|
||||
}
|
||||
|
||||
m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN;
|
||||
m_iPos++;
|
||||
a_Tok.Set ( cmARG_SEP, szSep );
|
||||
a_Tok.Set(cmARG_SEP, szSep);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -509,16 +520,16 @@ auto QmuParserTokenReader::IsArgSep ( token_type &a_Tok ) -> bool
|
|||
* @param a_Tok [out] If an eof is found the corresponding token will be stored there.
|
||||
* @sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsString, IsInfixOpTok, IsPostOpTok
|
||||
*/
|
||||
auto QmuParserTokenReader::IsEOF ( token_type &a_Tok ) -> bool
|
||||
auto QmuParserTokenReader::IsEOF(token_type &a_Tok) -> bool
|
||||
{
|
||||
// check for EOF
|
||||
if ( m_iPos >= m_strFormula.size())
|
||||
if (m_iPos >= m_strFormula.size())
|
||||
{
|
||||
if ( m_iSynFlags & noEND )
|
||||
if (m_iSynFlags & noEND)
|
||||
{
|
||||
try
|
||||
{
|
||||
Error ( ecUNEXPECTED_EOF, m_iPos );
|
||||
Error(ecUNEXPECTED_EOF, m_iPos);
|
||||
}
|
||||
catch (qmu::QmuParserError &e)
|
||||
{
|
||||
|
@ -527,13 +538,13 @@ auto QmuParserTokenReader::IsEOF ( token_type &a_Tok ) -> bool
|
|||
}
|
||||
}
|
||||
|
||||
if ( m_iBrackets > 0 )
|
||||
if (m_iBrackets > 0)
|
||||
{
|
||||
Error ( ecMISSING_PARENS, m_iPos, QChar(')') );
|
||||
Error(ecMISSING_PARENS, m_iPos, QChar(')'));
|
||||
}
|
||||
|
||||
m_iSynFlags = 0;
|
||||
a_Tok.Set ( cmEND );
|
||||
a_Tok.Set(cmEND);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -545,27 +556,27 @@ auto QmuParserTokenReader::IsEOF ( token_type &a_Tok ) -> bool
|
|||
* @brief Check if a string position contains a unary infix operator.
|
||||
* @return true if a function token has been found false otherwise.
|
||||
*/
|
||||
auto QmuParserTokenReader::IsInfixOpTok ( token_type &a_Tok ) -> bool
|
||||
auto QmuParserTokenReader::IsInfixOpTok(token_type &a_Tok) -> bool
|
||||
{
|
||||
QString sTok;
|
||||
qmusizetype const iEnd = ExtractToken(m_pParser->ValidInfixOprtChars(), sTok, m_iPos);
|
||||
if ( iEnd == m_iPos )
|
||||
if (iEnd == m_iPos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// iteraterate over all postfix operator strings
|
||||
auto it = m_pInfixOprtDef->rbegin();
|
||||
for ( ; it != m_pInfixOprtDef->rend(); ++it )
|
||||
for (; it != m_pInfixOprtDef->rend(); ++it)
|
||||
{
|
||||
if ( sTok.indexOf ( it->first ) == 0 )
|
||||
if (sTok.indexOf(it->first) == 0)
|
||||
{
|
||||
a_Tok.Set ( it->second, it->first );
|
||||
a_Tok.Set(it->second, it->first);
|
||||
m_iPos += static_cast<int>(it->first.length());
|
||||
|
||||
if ( m_iSynFlags & noINFIXOP )
|
||||
if (m_iSynFlags & noINFIXOP)
|
||||
{
|
||||
Error ( ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString() );
|
||||
Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString());
|
||||
}
|
||||
|
||||
m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN;
|
||||
|
@ -584,33 +595,33 @@ auto QmuParserTokenReader::IsInfixOpTok ( token_type &a_Tok ) -> bool
|
|||
* @return true if a function token has been found false otherwise.
|
||||
* @pre [assert] m_pParser!=0
|
||||
*/
|
||||
auto QmuParserTokenReader::IsFunTok ( token_type &a_Tok ) -> bool
|
||||
auto QmuParserTokenReader::IsFunTok(token_type &a_Tok) -> bool
|
||||
{
|
||||
QString strTok;
|
||||
qmusizetype const iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos);
|
||||
if ( iEnd == m_iPos )
|
||||
if (iEnd == m_iPos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
auto item = m_pFunDef->find ( strTok );
|
||||
if ( item == m_pFunDef->end() )
|
||||
auto item = m_pFunDef->find(strTok);
|
||||
if (item == m_pFunDef->end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the next sign is an opening bracket
|
||||
if ( m_strFormula.at ( iEnd ) != '(' )
|
||||
if (m_strFormula.at(iEnd) != '(')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
a_Tok.Set ( item->second, strTok );
|
||||
a_Tok.Set(item->second, strTok);
|
||||
|
||||
m_iPos = iEnd;
|
||||
if ( m_iSynFlags & noFUN )
|
||||
if (m_iSynFlags & noFUN)
|
||||
{
|
||||
Error ( ecUNEXPECTED_FUN, m_iPos - static_cast<int>(a_Tok.GetAsString().length()), a_Tok.GetAsString() );
|
||||
Error(ecUNEXPECTED_FUN, m_iPos - static_cast<int>(a_Tok.GetAsString().length()), a_Tok.GetAsString());
|
||||
}
|
||||
|
||||
m_iSynFlags = noANY ^ noBO;
|
||||
|
@ -623,23 +634,22 @@ auto QmuParserTokenReader::IsFunTok ( token_type &a_Tok ) -> bool
|
|||
* @param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token.
|
||||
* @return true if an operator token has been found.
|
||||
*/
|
||||
auto QmuParserTokenReader::IsOprt ( token_type &a_Tok ) -> bool
|
||||
auto QmuParserTokenReader::IsOprt(token_type &a_Tok) -> bool
|
||||
{
|
||||
QString strTok;
|
||||
|
||||
qmusizetype const iEnd = ExtractOperatorToken(strTok, m_iPos);
|
||||
if ( iEnd == m_iPos )
|
||||
if (iEnd == m_iPos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the operator is a built in operator, if so ignore it here
|
||||
const QStringList &pOprtDef = QmuParserBase::GetOprtDef();
|
||||
for ( auto constIterator = pOprtDef.constBegin();
|
||||
m_pParser->HasBuiltInOprt() && constIterator != pOprtDef.constEnd();
|
||||
++constIterator )
|
||||
for (auto constIterator = pOprtDef.constBegin();
|
||||
m_pParser->HasBuiltInOprt() && constIterator != pOprtDef.constEnd(); ++constIterator)
|
||||
{
|
||||
if ( ( *constIterator ) == strTok )
|
||||
if ((*constIterator) == strTok)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -652,21 +662,21 @@ auto QmuParserTokenReader::IsOprt ( token_type &a_Tok ) -> bool
|
|||
// of the long ones.
|
||||
// Length sorting is done with ascending length so we use a reverse iterator here.
|
||||
auto it = m_pOprtDef->rbegin();
|
||||
for ( ; it != m_pOprtDef->rend(); ++it )
|
||||
for (; it != m_pOprtDef->rend(); ++it)
|
||||
{
|
||||
const QString &sID = it->first;
|
||||
if ( sID == m_strFormula.mid ( m_iPos, sID.length() ) )
|
||||
if (sID == m_strFormula.mid(m_iPos, sID.length()))
|
||||
{
|
||||
a_Tok.Set ( it->second, strTok );
|
||||
a_Tok.Set(it->second, strTok);
|
||||
|
||||
// operator was found
|
||||
if ( m_iSynFlags & noOPT )
|
||||
if (m_iSynFlags & noOPT)
|
||||
{
|
||||
// An operator was found but is not expected to occur at
|
||||
// this position of the formula, maybe it is an infix
|
||||
// operator, not a binary operator. Both operator types
|
||||
// can share characters in their identifiers.
|
||||
if ( IsInfixOpTok ( a_Tok ) )
|
||||
if (IsInfixOpTok(a_Tok))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -689,7 +699,7 @@ auto QmuParserTokenReader::IsOprt ( token_type &a_Tok ) -> bool
|
|||
/**
|
||||
* @brief Check if a string position contains a unary post value operator.
|
||||
*/
|
||||
auto QmuParserTokenReader::IsPostOpTok ( token_type &a_Tok ) -> bool
|
||||
auto QmuParserTokenReader::IsPostOpTok(token_type &a_Tok) -> bool
|
||||
{
|
||||
// <ibg 20110629> Do not check for postfix operators if they are not allowed at
|
||||
// the current expression index.
|
||||
|
@ -698,7 +708,7 @@ auto QmuParserTokenReader::IsPostOpTok ( token_type &a_Tok ) -> bool
|
|||
//
|
||||
// http://sourceforge.net/tracker/index.php?func=detail&aid=3343891&group_id=137191&atid=737979
|
||||
//
|
||||
if ( m_iSynFlags & noPOSTOP )
|
||||
if (m_iSynFlags & noPOSTOP)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -715,18 +725,18 @@ auto QmuParserTokenReader::IsPostOpTok ( token_type &a_Tok ) -> bool
|
|||
// Test if there could be a postfix operator
|
||||
QString sTok;
|
||||
qmusizetype const iEnd = ExtractToken(m_pParser->ValidOprtChars(), sTok, m_iPos);
|
||||
if ( iEnd == m_iPos )
|
||||
if (iEnd == m_iPos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// iteraterate over all postfix operator strings
|
||||
auto it = m_pPostOprtDef->rbegin();
|
||||
for ( ; it != m_pPostOprtDef->rend(); ++it )
|
||||
for (; it != m_pPostOprtDef->rend(); ++it)
|
||||
{
|
||||
if ( sTok.indexOf ( it->first ) == 0 )
|
||||
if (sTok.indexOf(it->first) == 0)
|
||||
{
|
||||
a_Tok.Set ( it->second, sTok );
|
||||
a_Tok.Set(it->second, sTok);
|
||||
m_iPos += it->first.length();
|
||||
|
||||
m_iSynFlags = noVAL | noVAR | noFUN | noBO | noPOSTOP | noSTR | noASSIGN;
|
||||
|
@ -746,30 +756,30 @@ auto QmuParserTokenReader::IsPostOpTok ( token_type &a_Tok ) -> bool
|
|||
* @param a_Tok [out] If a value token is found it will be placed here.
|
||||
* @return true if a value token has been found.
|
||||
*/
|
||||
auto QmuParserTokenReader::IsValTok ( token_type &a_Tok, const QLocale &locale, bool cNumbers, const QChar &decimal,
|
||||
const QChar &thousand ) -> bool
|
||||
auto QmuParserTokenReader::IsValTok(token_type &a_Tok, const QLocale &locale, bool cNumbers, const QChar &decimal,
|
||||
const QChar &thousand) -> bool
|
||||
{
|
||||
assert ( m_pConstDef );
|
||||
assert ( m_pParser );
|
||||
assert(m_pConstDef);
|
||||
assert(m_pParser);
|
||||
|
||||
QString strTok;
|
||||
qreal fVal ( 0 );
|
||||
qmusizetype iEnd ( 0 );
|
||||
qreal fVal(0);
|
||||
qmusizetype iEnd(0);
|
||||
|
||||
// 2.) Check for user defined constant
|
||||
// Read everything that could be a constant name
|
||||
iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos );
|
||||
if ( iEnd != m_iPos )
|
||||
iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos);
|
||||
if (iEnd != m_iPos)
|
||||
{
|
||||
auto item = m_pConstDef->find ( strTok );
|
||||
if ( item != m_pConstDef->end() )
|
||||
auto item = m_pConstDef->find(strTok);
|
||||
if (item != m_pConstDef->end())
|
||||
{
|
||||
m_iPos = iEnd;
|
||||
a_Tok.SetVal ( item->second, strTok );
|
||||
a_Tok.SetVal(item->second, strTok);
|
||||
|
||||
if ( m_iSynFlags & noVAL )
|
||||
if (m_iSynFlags & noVAL)
|
||||
{
|
||||
Error ( ecUNEXPECTED_VAL, m_iPos - strTok.length(), strTok );
|
||||
Error(ecUNEXPECTED_VAL, m_iPos - strTok.length(), strTok);
|
||||
}
|
||||
|
||||
m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN;
|
||||
|
@ -779,20 +789,19 @@ auto QmuParserTokenReader::IsValTok ( token_type &a_Tok, const QLocale &locale,
|
|||
|
||||
// 3.call the value recognition functions provided by the user
|
||||
// Call user defined value recognition functions
|
||||
auto item = m_vIdentFun.begin();
|
||||
for ( item = m_vIdentFun.begin(); item != m_vIdentFun.end(); ++item )
|
||||
for (auto item = m_vIdentFun.begin(); item != m_vIdentFun.end(); ++item)
|
||||
{
|
||||
qmusizetype const iStart = m_iPos;
|
||||
if ( ( *item ) ( m_strFormula.mid ( m_iPos ), &m_iPos, &fVal, locale, cNumbers, decimal, thousand ) == 1 )
|
||||
if ((*item)(m_strFormula.mid(m_iPos), &m_iPos, &fVal, locale, cNumbers, decimal, thousand) == 1)
|
||||
{
|
||||
// 2013-11-27 Issue 2: https://code.google.com/p/muparser/issues/detail?id=2
|
||||
strTok = m_strFormula.mid ( iStart, m_iPos-iStart );
|
||||
if ( m_iSynFlags & noVAL )
|
||||
strTok = m_strFormula.mid(iStart, m_iPos - iStart);
|
||||
if (m_iSynFlags & noVAL)
|
||||
{
|
||||
Error ( ecUNEXPECTED_VAL, m_iPos - strTok.length(), strTok );
|
||||
Error(ecUNEXPECTED_VAL, m_iPos - strTok.length(), strTok);
|
||||
}
|
||||
|
||||
a_Tok.SetVal ( fVal, strTok );
|
||||
a_Tok.SetVal(fVal, strTok);
|
||||
m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN;
|
||||
return true;
|
||||
}
|
||||
|
@ -807,83 +816,82 @@ auto QmuParserTokenReader::IsValTok ( token_type &a_Tok, const QLocale &locale,
|
|||
* @param a_Tok [out] If a variable token has been found it will be placed here.
|
||||
* @return true if a variable token has been found.
|
||||
*/
|
||||
auto QmuParserTokenReader::IsVarTok ( token_type &a_Tok ) -> bool
|
||||
auto QmuParserTokenReader::IsVarTok(token_type &a_Tok) -> bool
|
||||
{
|
||||
if ( m_pVarDef->empty())
|
||||
if (m_pVarDef->empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString strTok;
|
||||
qmusizetype iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos );
|
||||
if ( iEnd == m_iPos )
|
||||
qmusizetype iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos);
|
||||
if (iEnd == m_iPos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
auto item = m_pVarDef->find ( strTok );
|
||||
if ( item == m_pVarDef->end() )
|
||||
auto item = m_pVarDef->find(strTok);
|
||||
if (item == m_pVarDef->end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_iSynFlags & noVAR )
|
||||
if (m_iSynFlags & noVAR)
|
||||
{
|
||||
Error ( ecUNEXPECTED_VAR, m_iPos, strTok );
|
||||
Error(ecUNEXPECTED_VAR, m_iPos, strTok);
|
||||
}
|
||||
|
||||
m_pParser->OnDetectVar ( m_strFormula, m_iPos, iEnd );
|
||||
m_pParser->OnDetectVar(m_strFormula, m_iPos, iEnd);
|
||||
|
||||
m_iPos = iEnd;
|
||||
a_Tok.SetVar ( item->second, strTok );
|
||||
a_Tok.SetVar(item->second, strTok);
|
||||
m_UsedVar[item->first] = item->second; // Add variable to used-var-list
|
||||
|
||||
m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR;
|
||||
|
||||
// Zur Info hier die SynFlags von IsVal():
|
||||
// m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN;
|
||||
// Zur Info hier die SynFlags von IsVal():
|
||||
// m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN;
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok ) -> bool
|
||||
auto QmuParserTokenReader::IsStrVarTok(token_type &a_Tok) -> bool
|
||||
{
|
||||
if ( m_pStrVarDef == nullptr || m_pStrVarDef->empty() )
|
||||
if (m_pStrVarDef == nullptr || m_pStrVarDef->empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString strTok;
|
||||
qmusizetype const iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos);
|
||||
if ( iEnd == m_iPos )
|
||||
if (iEnd == m_iPos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
auto item = m_pStrVarDef->find ( strTok );
|
||||
if ( item == m_pStrVarDef->end() )
|
||||
auto item = m_pStrVarDef->find(strTok);
|
||||
if (item == m_pStrVarDef->end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_iSynFlags & noSTR )
|
||||
if (m_iSynFlags & noSTR)
|
||||
{
|
||||
Error ( ecUNEXPECTED_VAR, m_iPos, strTok );
|
||||
Error(ecUNEXPECTED_VAR, m_iPos, strTok);
|
||||
}
|
||||
|
||||
m_iPos = iEnd;
|
||||
if ( m_pParser->m_vStringVarBuf.empty())
|
||||
if (m_pParser->m_vStringVarBuf.empty())
|
||||
{
|
||||
Error ( ecINTERNAL_ERROR );
|
||||
Error(ecINTERNAL_ERROR);
|
||||
}
|
||||
|
||||
a_Tok.SetString ( m_pParser->m_vStringVarBuf[item->second], m_pParser->m_vStringVarBuf.size() );
|
||||
a_Tok.SetString(m_pParser->m_vStringVarBuf[item->second], m_pParser->m_vStringVarBuf.size());
|
||||
|
||||
m_iSynFlags = noANY ^ ( noBC | noOPT | noEND | noARG_SEP );
|
||||
m_iSynFlags = noANY ^ (noBC | noOPT | noEND | noARG_SEP);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Check wheter a token at a given position is an undefined variable.
|
||||
|
@ -892,31 +900,31 @@ auto QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok ) -> bool
|
|||
* @return true if a variable token has been found.
|
||||
* @throw nothrow
|
||||
*/
|
||||
auto QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok ) -> bool
|
||||
auto QmuParserTokenReader::IsUndefVarTok(token_type &a_Tok) -> bool
|
||||
{
|
||||
QString strTok;
|
||||
qmusizetype const iEnd(ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos));
|
||||
if ( iEnd == m_iPos )
|
||||
if (iEnd == m_iPos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_iSynFlags & noVAR )
|
||||
if (m_iSynFlags & noVAR)
|
||||
{
|
||||
// <ibg/> 20061021 added token string strTok instead of a_Tok.GetAsString() as the
|
||||
// token identifier.
|
||||
// related bug report:
|
||||
// http://sourceforge.net/tracker/index.php?func=detail&aid=1578779&group_id=137191&atid=737979
|
||||
Error ( ecUNEXPECTED_VAR, m_iPos - a_Tok.GetAsString().length(), strTok );
|
||||
Error(ecUNEXPECTED_VAR, m_iPos - a_Tok.GetAsString().length(), strTok);
|
||||
}
|
||||
|
||||
// If a factory is available implicitely create new variables
|
||||
if ( m_pFactory )
|
||||
if (m_pFactory)
|
||||
{
|
||||
try
|
||||
{
|
||||
qreal *fVar = m_pFactory ( strTok, m_pFactoryData );
|
||||
a_Tok.SetVar ( fVar, strTok );
|
||||
qreal *fVar = m_pFactory(strTok, m_pFactoryData);
|
||||
a_Tok.SetVar(fVar, strTok);
|
||||
|
||||
// Do not use m_pParser->DefineVar( strTok, fVar );
|
||||
// in order to define the new variable, it will clear the
|
||||
|
@ -924,7 +932,7 @@ auto QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok ) -> bool
|
|||
// from the list
|
||||
// This is safe because the new variable can never override an existing one
|
||||
// because they are checked first!
|
||||
( *m_pVarDef ) [strTok] = fVar;
|
||||
(*m_pVarDef)[strTok] = fVar;
|
||||
m_UsedVar[strTok] = fVar; // Add variable to used-var-list
|
||||
}
|
||||
catch (const qmu::QmuParserError &e)
|
||||
|
@ -935,7 +943,7 @@ auto QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok ) -> bool
|
|||
}
|
||||
else
|
||||
{
|
||||
a_Tok.SetVar ( &m_fZero, strTok );
|
||||
a_Tok.SetVar(&m_fZero, strTok);
|
||||
m_UsedVar[strTok] = nullptr; // Add variable to used-var-list
|
||||
}
|
||||
|
||||
|
@ -946,7 +954,6 @@ auto QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok ) -> bool
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Check wheter a token at a given position is a string.
|
||||
|
@ -954,44 +961,44 @@ auto QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok ) -> bool
|
|||
* @return true if a string token has been found.
|
||||
* @sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsEOF, IsInfixOpTok, IsPostOpTok
|
||||
*/
|
||||
auto QmuParserTokenReader::IsString ( token_type &a_Tok ) -> bool
|
||||
auto QmuParserTokenReader::IsString(token_type &a_Tok) -> bool
|
||||
{
|
||||
if ( m_strFormula[m_iPos] != '"' )
|
||||
if (m_strFormula[m_iPos] != '"')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString strBuf (m_strFormula.mid(m_iPos + 1));
|
||||
qmusizetype iEnd ( 0 ), iSkip ( 0 );
|
||||
QString strBuf(m_strFormula.mid(m_iPos + 1));
|
||||
qmusizetype iEnd(0), iSkip(0);
|
||||
|
||||
// parser over escaped '\"' end replace them with '"'
|
||||
for ( iEnd = strBuf.indexOf ( "\"" ); iEnd != 0 && iEnd != -1; iEnd = strBuf.indexOf ( "\"", iEnd ) )
|
||||
for (iEnd = strBuf.indexOf("\""); iEnd != 0 && iEnd != -1; iEnd = strBuf.indexOf("\"", iEnd))
|
||||
{
|
||||
if ( strBuf[iEnd - 1] != '\\' )
|
||||
if (strBuf[iEnd - 1] != '\\')
|
||||
{
|
||||
break;
|
||||
}
|
||||
strBuf.replace ( iEnd - 1, 2, "\"" );
|
||||
strBuf.replace(iEnd - 1, 2, "\"");
|
||||
iSkip++;
|
||||
}
|
||||
|
||||
if ( iEnd == -1 )
|
||||
if (iEnd == -1)
|
||||
{
|
||||
Error ( ecUNTERMINATED_STRING, m_iPos, "\"" );
|
||||
Error(ecUNTERMINATED_STRING, m_iPos, "\"");
|
||||
}
|
||||
|
||||
QString const strTok = strBuf.mid(0, iEnd);
|
||||
|
||||
if ( m_iSynFlags & noSTR )
|
||||
if (m_iSynFlags & noSTR)
|
||||
{
|
||||
Error ( ecUNEXPECTED_STR, m_iPos, strTok );
|
||||
Error(ecUNEXPECTED_STR, m_iPos, strTok);
|
||||
}
|
||||
|
||||
m_pParser->m_vStringBuf.push_back ( strTok ); // Store string in internal buffer
|
||||
a_Tok.SetString ( strTok, m_pParser->m_vStringBuf.size() );
|
||||
m_pParser->m_vStringBuf.push_back(strTok); // Store string in internal buffer
|
||||
a_Tok.SetString(strTok, m_pParser->m_vStringBuf.size());
|
||||
|
||||
m_iPos += strTok.length() + 2 + iSkip; // +2 wg Anfhrungszeichen; +iSkip fr entfernte escape zeichen
|
||||
m_iSynFlags = noANY ^ ( noARG_SEP | noBC | noOPT | noEND );
|
||||
m_iSynFlags = noANY ^ (noARG_SEP | noBC | noOPT | noEND);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1007,8 +1014,8 @@ auto QmuParserTokenReader::IsString ( token_type &a_Tok ) -> bool
|
|||
* @param a_sTok [in] The token string representation associated with the error.
|
||||
* @throw ParserException always throws thats the only purpose of this function.
|
||||
*/
|
||||
Q_NORETURN void QmuParserTokenReader::Error (EErrorCodes a_iErrc, qmusizetype a_iPos, const QString &a_sTok ) const
|
||||
Q_NORETURN void QmuParserTokenReader::Error(EErrorCodes a_iErrc, qmusizetype a_iPos, const QString &a_sTok) const
|
||||
{
|
||||
m_pParser->Error ( a_iErrc, a_iPos, a_sTok );
|
||||
m_pParser->Error(a_iErrc, a_iPos, a_sTok);
|
||||
}
|
||||
} // namespace qmu
|
||||
|
|
|
@ -234,8 +234,7 @@ auto DRW_Converter::toUtf8(const std::string &s) -> std::string
|
|||
{
|
||||
std::string result;
|
||||
unsigned int j = 0;
|
||||
unsigned int i = 0;
|
||||
for (i = 0; i < s.length(); i++)
|
||||
for (unsigned int i = 0; i < s.length(); i++)
|
||||
{
|
||||
auto c = static_cast<unsigned char>(s.at(i));
|
||||
if (c < 0x80)
|
||||
|
|
|
@ -620,10 +620,9 @@ template <class T> inline auto VAbstractPiece::CheckLoops(QVector<T> points) ->
|
|||
}
|
||||
|
||||
bool loopFound = false;
|
||||
qint32 i;
|
||||
const int maxLoops = 10000; // limit number of loops to be removed
|
||||
|
||||
for (i = 0; i < maxLoops; ++i)
|
||||
for (qint32 i = 0; i < maxLoops; ++i)
|
||||
{
|
||||
points = CheckLoop(points, loopFound);
|
||||
if (not loopFound)
|
||||
|
@ -646,8 +645,7 @@ template <class T> inline auto VAbstractPiece::CheckLoop(const QVector<T> &point
|
|||
QVector<T> ekvPoints;
|
||||
ekvPoints.reserve(points.size());
|
||||
|
||||
qint32 i;
|
||||
for (i = 0; i < points.size(); ++i)
|
||||
for (qint32 i = 0; i < points.size(); ++i)
|
||||
{
|
||||
/*Last three points no need to check.*/
|
||||
/*Triangle can not contain a loop*/
|
||||
|
|
|
@ -601,9 +601,8 @@ auto QxtCsvModel::toCSV(QIODevice *dest, QString &error, bool withHeader, QChar
|
|||
-> bool
|
||||
{
|
||||
const QxtCsvModelPrivate &d_ptr = qxt_d();
|
||||
int row, col, rows, cols;
|
||||
rows = rowCount();
|
||||
cols = columnCount();
|
||||
int rows = rowCount();
|
||||
int cols = columnCount();
|
||||
QString data;
|
||||
if (not dest->isOpen() && not dest->open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||
{
|
||||
|
@ -624,7 +623,7 @@ auto QxtCsvModel::toCSV(QIODevice *dest, QString &error, bool withHeader, QChar
|
|||
if (withHeader)
|
||||
{
|
||||
data = QString();
|
||||
for (col = 0; col < cols; ++col)
|
||||
for (int col = 0; col < cols; ++col)
|
||||
{
|
||||
if (col > 0)
|
||||
{
|
||||
|
@ -634,11 +633,11 @@ auto QxtCsvModel::toCSV(QIODevice *dest, QString &error, bool withHeader, QChar
|
|||
}
|
||||
stream << data << Qt::endl;
|
||||
}
|
||||
for (row = 0; row < rows; ++row)
|
||||
for (int row = 0; row < rows; ++row)
|
||||
{
|
||||
const QStringList &rowData = d_ptr.csvData[row];
|
||||
data = QString();
|
||||
for (col = 0; col < cols; ++col)
|
||||
for (int col = 0; col < cols; ++col)
|
||||
{
|
||||
if (col > 0)
|
||||
{
|
||||
|
|
|
@ -163,7 +163,6 @@ void PathArc(QPainterPath &path, qreal rx, qreal ry, qreal x_axis_rotation, int
|
|||
qreal x0, y0, x1, y1, xc, yc;
|
||||
qreal d, sfactor, sfactor_sq;
|
||||
qreal th0, th1, th_arc;
|
||||
int i, n_segs;
|
||||
qreal dx, dy, dx1, dy1, Px, Py, check;
|
||||
rx = qAbs(rx);
|
||||
ry = qAbs(ry);
|
||||
|
@ -223,8 +222,8 @@ void PathArc(QPainterPath &path, qreal rx, qreal ry, qreal x_axis_rotation, int
|
|||
{
|
||||
th_arc -= 2 * V_PI;
|
||||
}
|
||||
n_segs = qCeil(qAbs(th_arc / (V_PI * 0.5 + 0.001)));
|
||||
for (i = 0; i < n_segs; i++)
|
||||
int n_segs = qCeil(qAbs(th_arc / (V_PI * 0.5 + 0.001)));
|
||||
for (int i = 0; i < n_segs; i++)
|
||||
{
|
||||
PathArcSegment(path, xc, yc, th0 + i * th_arc / n_segs, th0 + (i + 1) * th_arc / n_segs, rx, ry,
|
||||
x_axis_rotation);
|
||||
|
|
|
@ -178,14 +178,13 @@ static void halfedge_free(halfedge_t *d)
|
|||
void del_free_halfedges(delaunay_t *del);
|
||||
void del_free_halfedges(delaunay_t *del)
|
||||
{
|
||||
quint32 i;
|
||||
halfedge_t *d, *sig;
|
||||
|
||||
/* if there is nothing to do */
|
||||
if (del->points == nullptr)
|
||||
return;
|
||||
|
||||
for (i = 0; i <= (del->end_point - del->start_point); i++)
|
||||
for (quint32 i = 0; i <= (del->end_point - del->start_point); i++)
|
||||
{
|
||||
/* free all the halfedges around the point */
|
||||
d = del->points[i]->he;
|
||||
|
@ -985,7 +984,6 @@ static void build_halfedge_face(delaunay_t *del, halfedge_t *d)
|
|||
void del_build_faces(delaunay_t *del);
|
||||
void del_build_faces(delaunay_t *del)
|
||||
{
|
||||
quint32 i;
|
||||
halfedge_t *curr;
|
||||
|
||||
del->num_faces = 0;
|
||||
|
@ -994,7 +992,7 @@ void del_build_faces(delaunay_t *del)
|
|||
/* build external face first */
|
||||
build_halfedge_face(del, del->rightmost_he->pair);
|
||||
|
||||
for (i = del->start_point; i <= del->end_point; i++)
|
||||
for (quint32 i = del->start_point; i <= del->end_point; i++)
|
||||
{
|
||||
curr = del->points[i]->he;
|
||||
|
||||
|
|
|
@ -446,7 +446,6 @@ auto scale_expansion_zeroelim(int elen, qreal *e, qreal b, qreal *h) -> int /* e
|
|||
qreal hh;
|
||||
INEXACT qreal product1;
|
||||
qreal product0;
|
||||
int eindex, hindex;
|
||||
qreal enow;
|
||||
INEXACT qreal bvirt;
|
||||
qreal avirt, bround, around;
|
||||
|
@ -457,12 +456,12 @@ auto scale_expansion_zeroelim(int elen, qreal *e, qreal b, qreal *h) -> int /* e
|
|||
|
||||
Split(b, bhi, blo);
|
||||
Two_Product_Presplit(e[0], b, bhi, blo, Q, hh);
|
||||
hindex = 0;
|
||||
int hindex = 0;
|
||||
if (hh != 0)
|
||||
{
|
||||
h[hindex++] = hh;
|
||||
}
|
||||
for (eindex = 1; eindex < elen; eindex++)
|
||||
for (int eindex = 1; eindex < elen; eindex++)
|
||||
{
|
||||
enow = e[eindex];
|
||||
Two_Product_Presplit(enow, b, bhi, blo, product1, product0);
|
||||
|
@ -495,10 +494,9 @@ auto scale_expansion_zeroelim(int elen, qreal *e, qreal b, qreal *h) -> int /* e
|
|||
auto estimate(int elen, qreal *e) -> qreal
|
||||
{
|
||||
qreal Q;
|
||||
int eindex;
|
||||
|
||||
Q = e[0];
|
||||
for (eindex = 1; eindex < elen; eindex++)
|
||||
for (int eindex = 1; eindex < elen; eindex++)
|
||||
{
|
||||
Q += e[eindex];
|
||||
}
|
||||
|
|
|
@ -428,8 +428,7 @@ void VContainer::ClearVariables(const QVector<VarType> &types)
|
|||
}
|
||||
else
|
||||
{
|
||||
QHash<QString, QSharedPointer<VInternalVariable>>::iterator i;
|
||||
for (i = d->variables.begin(); i != d->variables.end();)
|
||||
for (auto i = d->variables.begin(); i != d->variables.end();)
|
||||
{
|
||||
if (types.contains(i.value()->GetType()))
|
||||
{
|
||||
|
@ -712,8 +711,7 @@ template <typename T> auto VContainer::DataVar(const VarType &type) const -> QMa
|
|||
{
|
||||
QMap<QString, QSharedPointer<T>> map;
|
||||
// Sorting QHash by id
|
||||
QHash<QString, QSharedPointer<VInternalVariable>>::const_iterator i;
|
||||
for (i = d->variables.constBegin(); i != d->variables.constEnd(); ++i)
|
||||
for (auto i = d->variables.constBegin(); i != d->variables.constEnd(); ++i)
|
||||
{
|
||||
if (i.value()->GetType() == type)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "../vproperty_p.h"
|
||||
|
||||
VPE::VObjectProperty::VObjectProperty(const QString& name)
|
||||
VPE::VObjectProperty::VObjectProperty(const QString &name)
|
||||
: VProperty(name,
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QMetaType::UInt),
|
||||
|
@ -137,7 +137,7 @@ auto VPE::VObjectProperty::getObjects() const -> QMap<QString, quint32>
|
|||
}
|
||||
|
||||
//! Sets the value of the property
|
||||
void VPE::VObjectProperty::setValue(const QVariant& value)
|
||||
void VPE::VObjectProperty::setValue(const QVariant &value)
|
||||
{
|
||||
VProperty::d_ptr->VariantValue = value;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
|
@ -166,15 +166,14 @@ void VPE::VObjectProperty::currentIndexChanged(int index)
|
|||
{
|
||||
Q_UNUSED(index)
|
||||
auto *event = new UserChangeEvent();
|
||||
QCoreApplication::postEvent ( VProperty::d_ptr->editor, event );
|
||||
QCoreApplication::postEvent(VProperty::d_ptr->editor, event);
|
||||
}
|
||||
|
||||
void VPE::VObjectProperty::FillList(QComboBox *box, const QMap<QString, quint32> &list) const
|
||||
{
|
||||
box->clear();
|
||||
|
||||
QMap<QString, quint32>::const_iterator i;
|
||||
for (i = list.constBegin(); i != list.constEnd(); ++i)
|
||||
for (auto i = list.constBegin(); i != list.constEnd(); ++i)
|
||||
{
|
||||
box->addItem(i.key(), i.value());
|
||||
}
|
||||
|
|
|
@ -203,9 +203,8 @@ void DialogTool::FillComboBoxSplines(QComboBox *box) const
|
|||
box->blockSignals(true);
|
||||
|
||||
const auto *const objs = data->CalculationGObjects();
|
||||
QHash<quint32, QSharedPointer<VGObject>>::const_iterator i;
|
||||
QMap<QString, quint32> list;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
for (auto i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (i.key() != toolId && IsSpline(i.value()))
|
||||
{
|
||||
|
@ -224,9 +223,8 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box) const
|
|||
box->blockSignals(true);
|
||||
|
||||
const auto *const objs = data->CalculationGObjects();
|
||||
QHash<quint32, QSharedPointer<VGObject>>::const_iterator i;
|
||||
QMap<QString, quint32> list;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
for (auto i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (i.key() != toolId && IsSplinePath(i.value()))
|
||||
{
|
||||
|
@ -244,8 +242,7 @@ void DialogTool::FillComboBoxCurves(QComboBox *box) const
|
|||
SCASSERT(box != nullptr)
|
||||
const auto *const objs = data->CalculationGObjects();
|
||||
QMap<QString, quint32> list;
|
||||
QHash<quint32, QSharedPointer<VGObject>>::const_iterator i;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
for (auto i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (i.key() != toolId)
|
||||
{
|
||||
|
@ -780,9 +777,8 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, cons
|
|||
box->blockSignals(true);
|
||||
|
||||
const QHash<quint32, QSharedPointer<VGObject>> *objs = data->CalculationGObjects();
|
||||
QHash<quint32, QSharedPointer<VGObject>>::const_iterator i;
|
||||
QMap<QString, quint32> list;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
for (auto i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (rule == FillComboBox::NoChildren)
|
||||
{
|
||||
|
|
|
@ -331,8 +331,7 @@ auto VAbstractTool::PointsList() const -> QMap<QString, quint32>
|
|||
{
|
||||
const QHash<quint32, QSharedPointer<VGObject>> *objs = data.CalculationGObjects();
|
||||
QMap<QString, quint32> list;
|
||||
QHash<quint32, QSharedPointer<VGObject>>::const_iterator i;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
for (auto i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (i.key() != m_id)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue