2014-04-25 14:58:14 +02:00
|
|
|
/***************************************************************************************************
|
|
|
|
**
|
|
|
|
** Original work Copyright (C) 2013 Ingo Berg
|
|
|
|
** Modified work Copyright 2014 Roman Telezhinsky <dismine@gmail.com>
|
|
|
|
**
|
|
|
|
** Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
|
|
** software and associated documentation files (the "Software"), to deal in the Software
|
|
|
|
** without restriction, including without limitation the rights to use, copy, modify,
|
|
|
|
** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
** permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
|
|
**
|
|
|
|
** The above copyright notice and this permission notice shall be included in all copies or
|
|
|
|
** substantial portions of the Software.
|
|
|
|
**
|
|
|
|
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
|
|
** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
|
** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
**
|
|
|
|
******************************************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QMUPARSER_H
|
|
|
|
#define QMUPARSER_H
|
|
|
|
|
|
|
|
#include "qmuparser_global.h"
|
|
|
|
|
|
|
|
//--- Parser includes --------------------------------------------------------------------------
|
|
|
|
#include "qmuparserbase.h"
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
\brief Definition of the standard floating point parser.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace qmu
|
|
|
|
{
|
|
|
|
/** \brief Mathematical expressions parser.
|
|
|
|
|
|
|
|
Standard implementation of the mathematical expressions parser.
|
|
|
|
Can be used as a reference implementation for subclassing the parser.
|
|
|
|
|
|
|
|
<small>
|
|
|
|
(C) 2011 Ingo Berg<br>
|
|
|
|
muparser(at)gmx.de
|
|
|
|
</small>
|
|
|
|
*/
|
|
|
|
/* final */ class QMUPARSERSHARED_EXPORT QmuParser : public QmuParserBase
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
QmuParser();
|
|
|
|
virtual void InitCharSets();
|
|
|
|
virtual void InitFun();
|
|
|
|
virtual void InitConst();
|
|
|
|
virtual void InitOprt();
|
|
|
|
virtual void OnDetectVar(string_type *pExpr, int &nStart, int &nEnd);
|
|
|
|
|
2014-04-25 17:01:23 +02:00
|
|
|
qreal Diff(qreal *a_Var, qreal a_fPos, qreal a_fEpsilon = 0) const;
|
2014-04-25 14:58:14 +02:00
|
|
|
protected:
|
|
|
|
// Trigonometric functions
|
2014-04-25 17:01:23 +02:00
|
|
|
static qreal Tan2(qreal, qreal);
|
2014-04-25 14:58:14 +02:00
|
|
|
// hyperbolic functions
|
2014-04-25 17:01:23 +02:00
|
|
|
static qreal Sinh(qreal);
|
|
|
|
static qreal Cosh(qreal);
|
|
|
|
static qreal Tanh(qreal);
|
2014-04-25 14:58:14 +02:00
|
|
|
// arcus hyperbolic functions
|
2014-04-25 17:01:23 +02:00
|
|
|
static qreal ASinh(qreal);
|
|
|
|
static qreal ACosh(qreal);
|
|
|
|
static qreal ATanh(qreal);
|
2014-04-25 14:58:14 +02:00
|
|
|
// Logarithm functions
|
2014-04-25 17:01:23 +02:00
|
|
|
static qreal Log2(qreal); // Logarithm Base 2
|
|
|
|
static qreal Log10(qreal); // Logarithm Base 10
|
2014-04-25 14:58:14 +02:00
|
|
|
// misc
|
2014-04-25 17:01:23 +02:00
|
|
|
static qreal Abs(qreal);
|
|
|
|
static qreal Rint(qreal);
|
|
|
|
static qreal Sign(qreal);
|
2014-04-25 14:58:14 +02:00
|
|
|
// Prefix operators
|
|
|
|
// !!! Unary Minus is a MUST if you want to use negative signs !!!
|
2014-04-25 17:01:23 +02:00
|
|
|
static qreal UnaryMinus(qreal);
|
2014-04-25 14:58:14 +02:00
|
|
|
// Functions with variable number of arguments
|
2014-04-25 17:01:23 +02:00
|
|
|
static qreal Sum(const qreal*, int); // sum
|
|
|
|
static qreal Avg(const qreal*, int); // mean value
|
|
|
|
static qreal Min(const qreal*, int); // minimum
|
|
|
|
static qreal Max(const qreal*, int); // maximum
|
2014-04-25 14:58:14 +02:00
|
|
|
|
2014-04-25 17:01:23 +02:00
|
|
|
static int IsVal(const char_type* a_szExpr, int *a_iPos, qreal *a_fVal);
|
2014-04-25 14:58:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace qmu
|
|
|
|
|
|
|
|
#endif // QMUPARSER_H
|