#include <math.h>
#include <stdlib.h>
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Default constructor
+*/
QtxStdOperations::QtxStdOperations()
{
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Destructor
+*/
QtxStdOperations::~QtxStdOperations()
{
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Fills list of brackets treated as open (when 'open' is 'true') or close ('open' is 'false')
+*/
void QtxStdOperations::bracketsList( QStringList& list, bool open ) const
{
if( open )
list.append( ")" );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Fills list with operation names by copying of internal list of operations
+*/
void QtxStdOperations::opersList( QStringList& list ) const
{
- list += myOpers;
+ list += myOpers;
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Add operation names from list to internal list of operations
+*/
void QtxStdOperations::addOperations( const QStringList& list )
{
QStringList::const_iterator anIt = list.begin(),
myOpers.append( *anIt );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Append operation names from 'list' to internal list of operations
+*/
void QtxStdOperations::addTypes( const ListOfTypes& list )
{
ListOfTypes::const_iterator anIt = list.begin(),
myTypes.append( *anIt );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ \return whether values with passed types are valid for arguments of operation
+ \param op - name of operation
+ \param t1 - type of first argument
+ \param t2 - type of second argument
+*/
QtxParser::Error QtxStdOperations::isValid( const QString& op,
const QVariant::Type t1,
const QVariant::Type t2 ) const
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Default constructor
+*/
QtxArithmetics::QtxArithmetics()
: QtxStdOperations()
{
addTypes( aTypes );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Destructor
+*/
QtxArithmetics::~QtxArithmetics()
{
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Creates numbers by it's string representation [redefined virtual]
+*/
bool QtxArithmetics::createValue( const QString& str, QtxValue& v ) const
{
bool ok = false;
return ok;
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ \return priority of arithmetic operation 'op'.
+ \param isBin indicate whether the operation is binary
+*/
int QtxArithmetics::prior( const QString& op, bool isBin ) const
{
if( isBin )
v1 = QVariant( v2, 0 );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Calculates result of operation
+ \return one of error states
+ \param op - name of operation
+ \param v1 - first operation argument (must be used also to store result)
+ \param v2 - second operation argument
+*/
QtxParser::Error QtxArithmetics::calculate( const QString& op,
QtxValue& v1, QtxValue& v2 ) const
{
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Default constructor
+*/
QtxLogic::QtxLogic()
: QtxStdOperations()
{
addTypes( aTypes );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Destructor
+*/
QtxLogic::~QtxLogic()
{
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Creates value 'true' or 'false' it's string representation [redefined virtual]
+*/
bool QtxLogic::createValue( const QString& str, QtxValue& v ) const
{
bool ok = true;
return ok;
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ \return priority of arithmetic operation 'op'.
+ \param isBin indicate whether the operation is binary
+*/
int QtxLogic::prior( const QString& op, bool isBin ) const
{
if( isBin )
return false;
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Calculates result of operation
+ \return one of error states
+ \param op - name of operation
+ \param v1 - first operation argument (must be used also to store result)
+ \param v2 - second operation argument
+*/
QtxParser::Error QtxLogic::calculate( const QString& op,
QtxValue& v1, QtxValue& v2 ) const
{
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Default constructor
+*/
QtxFunctions::QtxFunctions()
: QtxStdOperations()
{
addTypes( aTypes );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Destructor
+*/
QtxFunctions::~QtxFunctions()
{
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Creates numbers by it's string representation [redefined virtual]
+*/
bool QtxFunctions::createValue( const QString& str, QtxValue& v ) const
{
bool ok = false;
return ok;
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ \return priority of arithmetic operation 'op'.
+ \param isBin indicate whether the operation is binary
+*/
int QtxFunctions::prior( const QString& op, bool isBin ) const
{
if( isBin )
return 0;
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Calculates result of operation
+ \return one of error states
+ \param op - name of operation
+ \param v1 - first operation argument (must be used also to store result)
+ \param v2 - second operation argument
+*/
QtxParser::Error QtxFunctions::calculate( const QString& op,
QtxValue& v1, QtxValue& v2 ) const
{
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Default constructor
+*/
QtxStrings::QtxStrings()
: QtxStdOperations()
{
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Destructor
+*/
QtxStrings::~QtxStrings()
{
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Creates string QtxValue by it's Qt string representation [redefined virtual]
+*/
bool QtxStrings::createValue( const QString& str, QtxValue& v ) const
{
QChar st = str[0],
return QtxStdOperations::createValue( str, v );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ \return priority of arithmetic operation 'op'.
+ \param isBin indicate whether the operation is binary
+*/
int QtxStrings::prior( const QString& op, bool isBin ) const
{
if( isBin )
return 0;
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Calculates result of operation
+ \return one of error states
+ \param op - name of operation
+ \param v1 - first operation argument (must be used also to store result)
+ \param v2 - second operation argument
+*/
QtxParser::Error QtxStrings::calculate( const QString& op,
QtxValue& v1, QtxValue& v2 ) const
{
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Default constructor
+*/
QtxSets::QtxSets()
{
QStringList aList;
addTypes( aTypes );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Destructor
+*/
QtxSets::~QtxSets()
{
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Fills list of brackets treated as open (when 'open' is 'true') or close ('open' is 'false')
+*/
void QtxSets::bracketsList( QStringList& list, bool open ) const
{
if( open )
QtxStdOperations::bracketsList( list, open );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Creates set of QtxValues by their string representation [redefined virtual]
+*/
bool QtxSets::createValue( const QString& str, QtxValue& val ) const
{
return QtxStdOperations::createValue( str, val );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ \return priority of arithmetic operation 'op'.
+ \param isBin indicate whether the operation is binary
+*/
int QtxSets::prior( const QString& op, bool isBin ) const
{
if( isBin )
return 0;
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ \return whether values with passed types are valid for arguments of operation
+ \param op - name of operation
+ \param t1 - type of first argument
+ \param t2 - type of second argument
+*/
QtxParser::Error QtxSets::isValid( const QString& op,
const QVariant::Type t1,
const QVariant::Type t2 ) const
return QtxStdOperations::isValid( op, t1, t2 );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Adds new value 'v' to set 'set' [static]
+*/
void QtxSets::add( ValueSet& set, const QtxValue& v )
{
if( v.isValid() && set.contains( v )==0 )
set.append( v );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Adds values from set 's2' to set 's1'
+*/
void QtxSets::add( ValueSet& s1, const ValueSet& s2 )
{
ValueSet::const_iterator anIt = s2.begin(),
add( s1, *anIt );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Removes value 'v' from set 'set'
+*/
void QtxSets::remove( ValueSet& set, const QtxValue& v )
{
set.remove( v );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Removes values of set 's2' from set 's1'
+*/
void QtxSets::remove( ValueSet& s1, const ValueSet& s2 )
{
ValueSet::const_iterator anIt = s2.begin(),
s1.remove( *anIt );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
+/*!
+ Calculates result of operation
+ \return one of error states
+ \param op - name of operation
+ \param v1 - first operation argument (must be used also to store result)
+ \param v2 - second operation argument
+*/
QtxParser::Error QtxSets::calculate( const QString& op, QtxValue& v1, QtxValue& v2 ) const
{
QtxParser::Error err = QtxParser::OK;