LibrePCB Developers Documentation
MathParser Class Reference

Mathematical expression parser. More...

#include <mathparser.h>

+ Collaboration diagram for MathParser:

Classes

struct  Result
 

Public Member Functions

 MathParser () noexcept
 
 MathParser (const MathParser &other)=delete
 
virtual ~MathParser () noexcept
 
void setLocale (const QLocale &locale) noexcept
 Set the locale to be used for parsing numbers. More...
 
Result parse (const QString &expression) const noexcept
 Parse expression. More...
 
MathParseroperator= (const MathParser &rhs)=delete
 

Private Attributes

QLocale mLocale
 The locale used for parsing numbers. More...
 

Detailed Description

Mathematical expression parser.

This class interprets mathematical expression strings (e.g. "2+3") and returns the result of the calculation. It is actually only a wrapper around the muparser library, so take a look at its documentation for details.

Constructor & Destructor Documentation

◆ MathParser() [1/2]

MathParser ( )
noexcept

◆ MathParser() [2/2]

MathParser ( const MathParser other)
delete

◆ ~MathParser()

~MathParser ( )
virtualnoexcept

Member Function Documentation

◆ setLocale()

void setLocale ( const QLocale &  locale)
noexcept

Set the locale to be used for parsing numbers.

This sets the thousand separator and decimal point to be used for the evaluation.

Parameters
localeThe locale to use.

◆ parse()

MathParser::Result parse ( const QString &  expression) const
noexcept

Parse expression.

Parameters
expressionThe expression to parse.
Returns
The result, either valid with a value, or invalid with an error message.
+ Here is the caller graph for this function:

◆ operator=()

MathParser & operator= ( const MathParser rhs)
delete

Member Data Documentation

◆ mLocale

QLocale mLocale
private

The locale used for parsing numbers.


The documentation for this class was generated from the following files: